LLVM: lib/IR/DebugInfo.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
40#include
41#include
42#include
43
44using namespace llvm;
47
49
50
51 if (!V->isUsedByMetadata())
52 return {};
54 if (!L)
55 return {};
56
61
62 return Declares;
63}
64
66
67
68 if (!V->isUsedByMetadata())
69 return {};
71 if (!L)
72 return {};
73
78
79 return DEclareValues;
80}
81
83
84
85 if (!V->isUsedByMetadata())
86 return {};
88 if (!L)
89 return {};
90
93 if (DVR->isValueOfVariable())
95
96 return Values;
97}
98
99template
100static void
103
104
105 if (!V->isUsedByMetadata())
106 return;
107
108
109
110
111
112
114
115
116 auto AppendUsers = [&EncounteredDbgVariableRecords,
117 &DbgVariableRecords](Metadata *MD) {
118
120 for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers()) {
121 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
122 if (EncounteredDbgVariableRecords.insert(DVR).second)
123 DbgVariableRecords.push_back(DVR);
124 }
125 }
126 };
127
129 AppendUsers(L);
130 for (Metadata *AL : L->getAllArgListUsers()) {
131 AppendUsers(AL);
134 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
135 if (EncounteredDbgVariableRecords.insert(DVR).second)
136 DbgVariableRecords.push_back(DVR);
137 }
138 }
139}
140
145
150
156
168
169
170
171
172
174 CUs.clear();
175 SPs.clear();
176 GVs.clear();
177 TYs.clear();
178 Scopes.clear();
179 NodesSeen.clear();
180}
181
183 for (auto *CU : M.debug_compile_units())
184 processCompileUnit(CU);
185 for (auto &F : M.functions()) {
188
189
193 }
194}
195
196void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
197 if (!addCompileUnit(CU))
198 return;
199 for (auto *DIG : CU->getGlobalVariables()) {
200 if (!addGlobalVariable(DIG))
201 continue;
202 auto *GV = DIG->getVariable();
203 processScope(GV->getScope());
204 processType(GV->getType());
205 }
206 for (auto *ET : CU->getEnumTypes())
207 processType(ET);
208 for (auto *RT : CU->getRetainedTypes())
210 processType(T);
211 else
213 for (auto *Import : CU->getImportedEntities())
214 processImportedEntity(Import);
215}
216
221
222 if (auto DbgLoc = I.getDebugLoc())
224
225 for (const DbgRecord &DPR : I.getDbgRecordRange())
227}
228
230 if ()
231 return;
232 processScope(Loc->getScope());
234}
235
241
242void DebugInfoFinder::processType(DIType *DT) {
243 if (!addType(DT))
244 return;
245 processScope(DT->getScope());
247 for (DIType *Ref : ST->getTypeArray())
248 processType(Ref);
249 return;
250 }
252 processType(DCT->getBaseType());
253 for (Metadata *D : DCT->getElements()) {
255 processType(T);
258 }
259 return;
260 }
262 processType(DDT->getBaseType());
263 }
264}
265
267 auto *Entity = Import->getEntity();
269 processType(T);
273 processScope(NS->getScope());
275 processScope(M->getScope());
276}
277
278void DebugInfoFinder::processScope(DIScope *Scope) {
279 if (!Scope)
280 return;
282 processType(Ty);
283 return;
284 }
286 addCompileUnit(CU);
287 return;
288 }
291 return;
292 }
293 if (!addScope(Scope))
294 return;
296 processScope(LB->getScope());
298 processScope(NS->getScope());
300 processScope(M->getScope());
301 }
302}
303
305 if (!addSubprogram(SP))
306 return;
307 processScope(SP->getScope());
308
309
310
311
312
313
314
315
316 processCompileUnit(SP->getUnit());
317 processType(SP->getType());
318 for (auto *Element : SP->getTemplateParams()) {
320 processType(TType->getType());
322 processType(TVal->getType());
323 }
324 }
325
326 SP->forEachRetainedNode(
329 [this](const DIImportedEntity *IE) { processImportedEntity(IE); });
330}
331
333 if (!NodesSeen.insert(DV).second)
334 return;
335 processScope(DV->getScope());
336 processType(DV->getType());
337}
338
339bool DebugInfoFinder::addType(DIType *DT) {
340 if (!DT)
341 return false;
342
343 if (!NodesSeen.insert(DT).second)
344 return false;
345
346 TYs.push_back(DT);
347 return true;
348}
349
351 if ()
352 return false;
353 if (!NodesSeen.insert(CU).second)
354 return false;
355
356 CUs.push_back(CU);
357 return true;
358}
359
361 if (!NodesSeen.insert(DIG).second)
362 return false;
363
364 GVs.push_back(DIG);
365 return true;
366}
367
368bool DebugInfoFinder::addSubprogram(DISubprogram *SP) {
369 if (!SP)
370 return false;
371
372 if (!NodesSeen.insert(SP).second)
373 return false;
374
375 SPs.push_back(SP);
376 return true;
377}
378
379bool DebugInfoFinder::addScope(DIScope *Scope) {
380 if (!Scope)
381 return false;
382
383
384 if (Scope->getNumOperands() == 0)
385 return false;
386 if (!NodesSeen.insert(Scope).second)
387 return false;
388 Scopes.push_back(Scope);
389 return true;
390}
391
392
393
394
395
396
397
398
402
403 if (!M || M->getNumOperands() < 1 || (M->getOperand(0)))
404 return MetadataIn;
405
406 bool Updated = false;
409 if (!MD) {
411 continue;
412 }
415 if (NewMD)
417 Updated |= NewMD != MD;
418 }
419
420 assert(!M->isDistinct() && "M should not be distinct.");
421 return Updated ? MDNode::get(M->getContext(), MDs) : MetadataIn;
422}
423
427 "Loop ID needs at least one operand");
429 "Loop ID should refer to itself");
430
431
433
435 if (!MD)
437 else if (Metadata *NewMD = Updater(
440 }
441
443
445 return NewLoopID;
446}
447
450 MDNode *OrigLoopID = I.getMetadata(LLVMContext::MD_loop);
451 if (!OrigLoopID)
452 return;
454 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
455}
456
457
458
463 if ()
464 return false;
466 return true;
467 if (!Visited.insert(N).second)
468 return false;
469 for (auto &OpIt : N->operands()) {
472
473
474 Reachable.insert(N);
475 }
476 }
477 return Reachable.count(N);
478}
479
485 if ()
486 return false;
488 return true;
489 if (!DIReachable.count(N))
490 return false;
491 if (!Visited.insert(N).second)
492 return false;
493 for (auto &OpIt : N->operands()) {
495 if (Op == MD)
496 continue;
498 return false;
499 }
500 }
502 return true;
503}
504
509 return nullptr;
510
511 if (!DIReachable.count(MD))
512 return MD;
513
515 if ()
516 return MD;
517
519 bool HasSelfRef = false;
520 for (unsigned i = 0; i < N->getNumOperands(); ++i) {
522 if () {
523 Args.push_back(nullptr);
524 } else if (A == MD) {
525 assert(i == 0 && "expected i==0 for self-reference");
526 HasSelfRef = true;
527 Args.push_back(nullptr);
528 } else if (Metadata *NewArg =
530 Args.push_back(NewArg);
531 }
532 }
533 if (Args.empty() || (HasSelfRef && Args.size() == 1))
534 return nullptr;
535
538 if (HasSelfRef)
540 return NewMD;
541}
542
544 assert(->operands().empty() && "Missing self reference?");
546
547 if (!Visited.insert(N).second)
548 return N;
549
550
551
552
553
555 [&Visited, &DILocationReachable](const MDOperand &Op) {
556 return isDILocationReachable(
557 Visited, DILocationReachable, Op.get());
558 }))
559 return N;
560
562
563
565 [&Visited, &AllDILocation,
566 &DILocationReachable](const MDOperand &Op) {
567 return isAllDILocation(Visited, AllDILocation,
568 DILocationReachable, Op.get());
569 }))
570 return nullptr;
571
573 N, [&AllDILocation, &DILocationReachable](Metadata *MD) -> Metadata * {
574 return stripLoopMDLoc(AllDILocation, DILocationReachable, MD);
575 });
576}
577
580 if (F.hasMetadata(LLVMContext::MD_dbg)) {
582 F.setSubprogram(nullptr);
583 }
584
588 if (I.getDebugLoc()) {
591 }
592 if (auto *LoopID = I.getMetadata(LLVMContext::MD_loop)) {
593 auto *NewLoopID = LoopIDsMap.lookup(LoopID);
594 if (!NewLoopID)
596 if (NewLoopID != LoopID)
597 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
598 }
599
600 if (I.hasMetadataOtherThanDebugLoc()) {
601
602 I.setMetadata("heapallocsite", nullptr);
603
604 I.setMetadata(LLVMContext::MD_DIAssignID, nullptr);
605 }
606 I.dropDbgRecords();
607 }
608 }
610}
611
615
617
618
619 if (NMD.getName().starts_with("llvm.dbg.") ||
620 NMD.getName() == "llvm.gcov") {
621 NMD.eraseFromParent();
623 }
624 }
625
628
629 for (auto &GV : M.globals()) {
630 Changed |= GV.eraseMetadata(LLVMContext::MD_dbg);
631 }
632
633 if (GVMaterializer *Materializer = M.getMaterializer())
634 Materializer->setStripDebugInfo();
635
637}
638
639namespace {
640
641
642class DebugTypeInfoRemoval {
644
645public:
646
647 MDNode *EmptySubroutineType;
648
649private:
650
651
652
653
655
656
657
658
659
660
661
662
663public:
667
669 if (!M)
670 return nullptr;
671 auto Replacement = Replacements.find(M);
672 if (Replacement != Replacements.end())
673 return Replacement->second;
674
675 return M;
676 }
678
679
680
681 void traverseAndRemap(MDNode *N) { traverse(N); }
682
683private:
684
685 DISubprogram *getReplacementSubprogram(DISubprogram *MDS) {
688 DISubprogram *Declaration = nullptr;
690 DIType *ContainingType =
693 auto Variables = nullptr;
694 auto TemplateParams = nullptr;
695
696
697 auto distinctMDSubprogram = [&]() {
698 return DISubprogram::getDistinct(
700 FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(),
701 ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
702 MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
703 Variables);
704 };
705
707 return distinctMDSubprogram();
708
709 auto *NewMDS = DISubprogram::get(
711 FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(), ContainingType,
712 MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
713 MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
714
715 StringRef OldLinkageName = MDS->getLinkageName();
716
717
718 auto OrigLinkage = NewToLinkageName.find(NewMDS);
719 if (OrigLinkage != NewToLinkageName.end()) {
720 if (OrigLinkage->second == OldLinkageName)
721
722 return NewMDS;
723
724
725
726 return distinctMDSubprogram();
727 }
728
729 NewToLinkageName.insert({NewMDS, MDS->getLinkageName()});
730 return NewMDS;
731 }
732
733
734 DICompileUnit *getReplacementCU(DICompileUnit *CU) {
735
737 return nullptr;
738
740 MDTuple *EnumTypes = nullptr;
741 MDTuple *RetainedTypes = nullptr;
742 MDTuple *GlobalVariables = nullptr;
743 MDTuple *ImportedEntities = nullptr;
744 return DICompileUnit::getDistinct(
748 RetainedTypes, GlobalVariables, ImportedEntities, CU->getMacros(),
752 }
753
754 DILocation *getReplacementMDLocation(DILocation *MLD) {
755 auto *Scope = map(MLD->getScope());
756 auto *InlinedAt = map(MLD->getInlinedAt());
758 return DILocation::getDistinct(MLD->getContext(), MLD->getLine(),
759 MLD->getColumn(), Scope, InlinedAt);
760 return DILocation::get(MLD->getContext(), MLD->getLine(), MLD->getColumn(),
761 Scope, InlinedAt);
762 }
763
764
765 MDNode *getReplacementMDNode(MDNode *N) {
767 Ops.reserve(N->getNumOperands());
768 for (auto &I : N->operands())
769 if (I)
772 return Ret;
773 }
774
775
776 void remap(MDNode *N) {
777 if (Replacements.count(N))
778 return;
779
780 auto doRemap = [&](MDNode *N) -> MDNode * {
781 if ()
782 return nullptr;
784 remap(MDSub->getUnit());
785 return getReplacementSubprogram(MDSub);
786 }
788 return EmptySubroutineType;
790 return getReplacementCU(CU);
792 return N;
794
795 return mapNode(MDLB->getScope());
797 return getReplacementMDLocation(MLD);
798
799
800
802 return nullptr;
803
804 return getReplacementMDNode(N);
805 };
806
807
808
811 }
812
813
814 void traverse(MDNode *);
815};
816
817}
818
819void DebugTypeInfoRemoval::traverse(MDNode *N) {
820 if ( || Replacements.count(N))
821 return;
822
823
824
827 return Child == MDS->getRetainedNodes().get();
828 return false;
829 };
830
833
834
836 while (!ToVisit.empty()) {
838 if (!Opened.insert(N).second) {
839
840 remap(N);
842 continue;
843 }
844 for (auto &I : N->operands())
846 if (!Opened.count(MDN) && !Replacements.count(MDN) && (N, MDN) &&
849 }
850}
851
854
855
856 for (auto NMI = M.named_metadata_begin(), NME = M.named_metadata_end();
857 NMI != NME;) {
859 ++NMI;
860
861 if (NMD->getName() == "llvm.dbg.cu")
862 continue;
863 }
864
865
866 for (auto &GV : M.globals())
867 GV.eraseMetadata(LLVMContext::MD_dbg);
868
869 DebugTypeInfoRemoval Mapper(M.getContext());
872 return nullptr;
873 Mapper.traverseAndRemap(Node);
874 auto *NewNode = Mapper.mapNode(Node);
876 Node = NewNode;
877 return NewNode;
878 };
879
880
881
882 for (auto &F : M) {
883 if (auto *SP = F.getSubprogram()) {
884 Mapper.traverseAndRemap(SP);
887 F.setSubprogram(NewSP);
888 }
889 for (auto &BB : F) {
890 for (auto &I : BB) {
892 auto *Scope = DL.getScope();
893 MDNode *InlinedAt = DL.getInlinedAt();
894 Scope = remap(Scope);
895 InlinedAt = remap(InlinedAt);
897 Scope, InlinedAt);
898 };
899
900 if (I.getDebugLoc() != DebugLoc())
901 I.setDebugLoc(remapDebugLoc(I.getDebugLoc()));
902
903
906 return remapDebugLoc(Loc).get();
907 return MD;
908 });
909
910
911 if (I.hasMetadataOtherThanDebugLoc())
912 I.setMetadata("heapallocsite", nullptr);
913
914
915 I.dropDbgRecords();
916 }
917 }
918 }
919
920
921
922 for (auto &NMD : M.named_metadata()) {
924 for (MDNode *Op : NMD.operands())
926
928 continue;
929
930 NMD.clearOperands();
932 if (Op)
933 NMD.addOperand(Op);
934 }
936}
937
940 M.getModuleFlag("Debug Info Version")))
941 return Val->getZExtValue();
942 return 0;
943}
944
948
951
952
954
956 for (const Instruction *I : SourceInstructions) {
957 if (auto *MD = I->getMetadata(LLVMContext::MD_DIAssignID))
960 "Merging with instruction from another function not allowed");
961 }
962
963
964 if (auto *MD = getMetadata(LLVMContext::MD_DIAssignID))
966
968 return;
969
972 if (AssignID != MergeID)
974 }
975 setMetadata(LLVMContext::MD_DIAssignID, MergeID);
976}
977
979
982 if () {
984 return;
985 }
986
987
988
989 bool MayLowerToCall = false;
992 MayLowerToCall =
994 }
995
996 if (!MayLowerToCall) {
998 return;
999 }
1000
1001
1002
1004 if (SP)
1005
1006
1007
1009 else
1010
1011
1012
1013
1014
1015
1017}
1018
1019
1020
1021
1022
1024 switch (lang) {
1025#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
1026 case LLVMDWARFSourceLanguage##NAME: \
1027 return ID;
1028#include "llvm/BinaryFormat/Dwarf.def"
1029#undef HANDLE_DW_LANG
1030 }
1032}
1033
1037
1041
1045
1050
1054
1058
1062
1066
1070
1072 delete unwrap(Builder);
1073}
1074
1076 unwrap(Builder)->finalize();
1077}
1078
1083
1086 LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen,
1087 LLVMBool isOptimized, const char *Flags, size_t FlagsLen,
1088 unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen,
1090 LLVMBool DebugInfoForProfiling, const char *SysRoot, size_t SysRootLen,
1091 const char *SDK, size_t SDKLen) {
1093
1094 return wrap(unwrap(Builder)->createCompileUnit(
1096 StringRef(Producer, ProducerLen), isOptimized, StringRef(Flags, FlagsLen),
1097 RuntimeVer, StringRef(SplitName, SplitNameLen),
1099 SplitDebugInlining, DebugInfoForProfiling,
1102}
1103
1106 size_t FilenameLen, const char *Directory,
1107 size_t DirectoryLen) {
1108 return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen),
1109 StringRef(Directory, DirectoryLen)));
1110}
1111
1114 switch (CSKind) {
1121 }
1123}
1124
1126 LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen,
1127 const char *Directory, size_t DirectoryLen, LLVMChecksumKind ChecksumKind,
1128 const char *Checksum, size_t ChecksumLen, const char *Source,
1129 size_t SourceLen) {
1133 std::optional Src;
1134 if (SourceLen > 0)
1135 Src = StringRef(Source, SourceLen);
1136 return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen),
1137 StringRef(Directory, DirectoryLen),
1138 CSInfo, Src));
1139}
1140
1143 const char *Name, size_t NameLen,
1144 const char *ConfigMacros, size_t ConfigMacrosLen,
1145 const char *IncludePath, size_t IncludePathLen,
1146 const char *APINotesFile, size_t APINotesFileLen) {
1147 return wrap(unwrap(Builder)->createModule(
1149 StringRef(ConfigMacros, ConfigMacrosLen),
1150 StringRef(IncludePath, IncludePathLen),
1151 StringRef(APINotesFile, APINotesFileLen)));
1152}
1153
1156 const char *Name, size_t NameLen,
1158 return wrap(unwrap(Builder)->createNameSpace(
1160}
1161
1164 size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
1168 return wrap(unwrap(Builder)->createFunction(
1173 nullptr, nullptr));
1174}
1175
1176
1184
1189 unsigned Discriminator) {
1192 Discriminator));
1193}
1194
1200 unsigned Line) {
1204 Line));
1205}
1206
1211 auto Elts =
1212 (NumElements > 0)
1213 ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1214 : nullptr;
1218}
1219
1223 unsigned NumElements) {
1224 auto Elts =
1225 (NumElements > 0)
1226 ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1227 : nullptr;
1230 Line, Elts));
1231}
1232
1235 LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen,
1237 auto Elts =
1238 (NumElements > 0)
1239 ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1240 : nullptr;
1241 return wrap(unwrap(Builder)->createImportedDeclaration(
1243 Line, {Name, NameLen}, Elts));
1244}
1245
1251 unwrap(InlinedAt)));
1252}
1253
1257
1261
1265
1269
1273
1276 *Len = Dir.size();
1277 return Dir.data();
1278}
1279
1282 *Len = Name.size();
1283 return Name.data();
1284}
1285
1288 *Len = Src->size();
1289 return Src->data();
1290 }
1291 *Len = 0;
1292 return "";
1293}
1294
1297 unsigned Line,
1299 const char *Name, size_t NameLen,
1300 const char *Value, size_t ValueLen) {
1301 return wrap(
1304 {Name, NameLen}, {Value, ValueLen}));
1305}
1306
1311 return wrap(unwrap(Builder)->createTempMacroFile(
1313}
1314
1316 const char *Name, size_t NameLen,
1319 return wrap(unwrap(Builder)->createEnumerator({Name, NameLen}, Value,
1320 IsUnsigned != 0));
1321}
1322
1326 uint64_t NumWords = (SizeInBits + 63) / 64;
1327 return wrap(unwrap(Builder)->createEnumerator(
1328 {Name, NameLen},
1329 APSInt(APInt(SizeInBits, ArrayRef(Words, NumWords)), IsUnsigned != 0)));
1330}
1331
1334 size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1337auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1338 NumElements});
1339return wrap(unwrap(Builder)->createEnumerationType(
1341 LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI(ClassTy)));
1342}
1343
1352
1359 return wrap(unwrap(Builder)->createSubrangeType(
1364}
1365
1366
1368 if (!MD)
1369 return nullptr;
1372 return E;
1375}
1376
1384 auto Subs =
1385 unwrap(Builder)->getOrCreateArray({unwrap(Subscripts), NumSubscripts});
1386 return wrap(unwrap(Builder)->createArrayType(
1391}
1392
1396 auto Elts =
1397 unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements});
1398 unwrap(Builder)->replaceArrays(CT, Elts);
1399}
1400
1403 size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1405 LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
1406 const char *UniqueId, size_t UniqueIdLen) {
1407 auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1408 NumElements});
1409 return wrap(unwrap(Builder)->createUnionType(
1412 Elts, RunTimeLang, {UniqueId, UniqueIdLen}));
1413}
1414
1415
1420 unsigned NumSubscripts) {
1421 auto Subs = unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1422 NumSubscripts});
1423 return wrap(unwrap(Builder)->createArrayType(Size, AlignInBits,
1425}
1426
1431 unsigned NumSubscripts) {
1432 auto Subs = unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1433 NumSubscripts});
1434 return wrap(unwrap(Builder)->createVectorType(Size, AlignInBits,
1436}
1437
1440 size_t NameLen, uint64_t SizeInBits,
1443 return wrap(unwrap(Builder)->createBasicType({Name, NameLen},
1444 SizeInBits, Encoding,
1446}
1447
1451 const char *Name, size_t NameLen) {
1452 return wrap(unwrap(Builder)->createPointerType(
1454 {Name, NameLen}));
1455}
1456
1459 size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1462 unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder,
1463 const char *UniqueId, size_t UniqueIdLen) {
1464 auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1465 NumElements});
1466 return wrap(unwrap(Builder)->createStructType(
1471}
1472
1479 {Name, NameLen}, unwrapDI(File), LineNo, SizeInBits, AlignInBits,
1481}
1482
1485 size_t NameLen) {
1486 return wrap(unwrap(Builder)->createUnspecifiedType({Name, NameLen}));
1487}
1488
1499
1502 const char *Name, size_t NameLen,
1507 return wrap(unwrap(Builder)->createObjCIVar(
1509 SizeInBits, AlignInBits, OffsetInBits,
1512}
1513
1516 const char *Name, size_t NameLen,
1518 const char *GetterName, size_t GetterNameLen,
1519 const char *SetterName, size_t SetterNameLen,
1520 unsigned PropertyAttributes,
1522 return wrap(unwrap(Builder)->createObjCProperty(
1524 {GetterName, GetterNameLen}, {SetterName, SetterNameLen},
1526}
1527
1534
1537 const char *Name, size_t NameLen,
1540 return wrap(unwrap(Builder)->createTypedef(
1543}
1544
1550 return wrap(unwrap(Builder)->createInheritance(
1553}
1554
1559 unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
1560 const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
1561 return wrap(unwrap(Builder)->createForwardDecl(
1564 AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
1565}
1566
1571 unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
1572 LLVMDIFlags Flags, const char *UniqueIdentifier,
1573 size_t UniqueIdentifierLen) {
1574 return wrap(unwrap(Builder)->createReplaceableCompositeType(
1578 {UniqueIdentifier, UniqueIdentifierLen}));
1579}
1580
1587
1594
1597 return wrap(unwrap(Builder)->createNullPtrType());
1598}
1599
1607 return wrap(unwrap(Builder)->createMemberPointerType(
1611}
1612
1616 const char *Name, size_t NameLen,
1620 uint64_t StorageOffsetInBits,
1622 return wrap(unwrap(Builder)->createBitFieldMemberType(
1625 SizeInBits, OffsetInBits, StorageOffsetInBits,
1627}
1628
1630 LLVMMetadataRef Scope, const char *Name, size_t NameLen,
1636 const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
1637 auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1638 NumElements});
1639 return wrap(unwrap(Builder)->createClassType(
1641 LineNumber, SizeInBits, AlignInBits, OffsetInBits,
1645 {UniqueIdentifier, UniqueIdentifierLen}));
1646}
1647
1653
1657
1660 *Length = Str.size();
1661 return Str.data();
1662}
1663
1667
1671
1675
1679
1683
1690
1695 unsigned NumParameterTypes,
1697 auto Elts = unwrap(Builder)->getOrCreateTypeArray({unwrap(ParameterTypes),
1698 NumParameterTypes});
1699 return wrap(unwrap(Builder)->createSubroutineType(
1701}
1702
1708
1712 return wrap(unwrap(Builder)->createConstantValueExpression(Value));
1713}
1714
1720 return wrap(unwrap(Builder)->createGlobalVariableExpression(
1724 nullptr, AlignInBits));
1725}
1726
1730
1735
1739
1743
1747
1753
1757
1761 Node->replaceAllUsesWith(unwrap(Replacement));
1763}
1764
1770 return wrap(unwrap(Builder)->createTempGlobalVariableFwdDecl(
1774}
1775
1783 : nullptr);
1784
1785
1786
1787
1788
1790 "Function unexpectedly in old debug info format");
1792}
1793
1800
1801
1802
1803
1804
1806 "Function unexpectedly in old debug info format");
1808}
1809
1813 DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
1817 : nullptr);
1818
1819
1820
1821
1822
1824 "Function unexpectedly in old debug info format");
1826}
1827
1831 DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
1835
1836
1837
1838
1839
1841 "Function unexpectedly in old debug info format");
1843}
1844
1849 return wrap(unwrap(Builder)->createAutoVariable(
1853}
1854
1857 size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo,
1859 return wrap(unwrap(Builder)->createParameterVariable(
1863}
1864
1866 int64_t Lo, int64_t Count) {
1868}
1869
1876
1880
1884
1888
1894
1898
1900 if (Loc)
1902 else
1904}
1905
1908 const char *Name, size_t NameLen,
1911 return wrap(unwrap(Builder)->createLabel(
1913 unwrapDI(File), LineNo, 0, false,
1914 std::nullopt, AlwaysPreserve));
1915}
1916
1923 InsertBefore
1925 : nullptr);
1926
1927
1928
1929
1930
1932 "Function unexpectedly in old debug info format");
1934}
1935
1943
1944
1945
1946
1947
1949 "Function unexpectedly in old debug info format");
1951}
1952
1955#define HANDLE_METADATA_LEAF(CLASS) \
1956 case Metadata::CLASS##Kind: \
1957 return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
1958#include "llvm/IR/Metadata.def"
1959 default:
1961 }
1962}
1963
1965 assert(ID && "Expected non-null ID");
1967 auto &Map = Ctx.pImpl->AssignmentIDToInstrs;
1968
1969 auto MapIt = Map.find(ID);
1970 if (MapIt == Map.end())
1971 return make_range(nullptr, nullptr);
1972
1973 return make_range(MapIt->second.begin(), MapIt->second.end());
1974}
1975
1978 DVR->eraseFromParent();
1979}
1980
1982
1984
1985
1986
1988 for (auto *I : InstVec)
1989 I->setMetadata(LLVMContext::MD_DIAssignID, New);
1990
1992}
1993
1999 if (DVR.isDbgAssign())
2000 DVR.eraseFromParent();
2001
2002 I.setMetadata(LLVMContext::MD_DIAssignID, nullptr);
2003 }
2004 }
2005}
2006
2010 std::optionalDIExpression::FragmentInfo &Result) {
2011
2013 return false;
2014
2015 int64_t AddrOffsetInBits;
2016 {
2017 int64_t AddrOffsetInBytes;
2019
2021 AddrOffsetInBytes, PostOffsetOps))
2022 return false;
2023 AddrOffsetInBits = AddrOffsetInBytes * 8;
2024 }
2025
2027
2028 int64_t BitExtractOffsetInBits = 0;
2031
2032 int64_t OffsetFromLocationInBits;
2034 DL, Dest, SliceOffsetInBits, SliceSizeInBits, Addr, AddrOffsetInBits,
2035 BitExtractOffsetInBits, VarFrag, Result, OffsetFromLocationInBits);
2036}
2037
2038
2039
2040
2043 auto GetNewID = [&Map](Metadata *Old) {
2045 if (DIAssignID *NewID = Map.lookup(OldID))
2046 return NewID;
2048 Map[OldID] = NewID;
2049 return NewID;
2050 };
2051
2053 if (DVR.isDbgAssign())
2054 DVR.setAssignId(GetNewID(DVR.getAssignID()));
2055 }
2056 if (auto *ID = I.getMetadata(LLVMContext::MD_DIAssignID))
2057 I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(ID));
2058}
2059
2060
2061
2062
2063static std::optional
2067 return std::nullopt;
2068 APInt GEPOffset(DL.getIndexTypeSizeInBits(StoreDest->getType()), 0);
2070 DL, GEPOffset, true);
2071
2073 return std::nullopt;
2074
2076
2078 return std::nullopt;
2080 return AssignmentInfo(DL, Alloca, OffsetInBytes * 8, SizeInBits);
2081 return std::nullopt;
2082}
2083
2086 const Value *StoreDest = I->getRawDest();
2087
2089 if (!ConstLengthInBytes)
2090
2091 return std::nullopt;
2092 uint64_t SizeInBits = 8 * ConstLengthInBytes->getZExtValue();
2094}
2095
2098 TypeSize SizeInBits = DL.getTypeSizeInBits(SI->getValueOperand()->getType());
2100}
2101
2107
2108
2112 auto *ID = StoreLikeInst.getMetadata(LLVMContext::MD_DIAssignID);
2113 assert(ID && "Store instruction must have DIAssignID metadata");
2114 (void)ID;
2115
2116 const uint64_t StoreStartBit = Info.OffsetInBits;
2117 const uint64_t StoreEndBit = Info.OffsetInBits + Info.SizeInBits;
2118
2119 uint64_t FragStartBit = StoreStartBit;
2120 uint64_t FragEndBit = StoreEndBit;
2121
2122 bool StoreToWholeVariable = Info.StoreToWholeAlloca;
2124
2125
2126
2127 const uint64_t VarStartBit = 0;
2129
2130
2131 FragEndBit = std::min(FragEndBit, VarEndBit);
2132
2133
2134 if (FragStartBit >= FragEndBit)
2135 return;
2136
2137 StoreToWholeVariable = FragStartBit <= VarStartBit && FragEndBit >= *Size;
2138 }
2139
2141 if (!StoreToWholeVariable) {
2143 FragEndBit - FragStartBit);
2144 assert(R.has_value() && "failed to create fragment expression");
2145 Expr = *R;
2146 }
2149 &StoreLikeInst, Val, VarRec.Var, Expr, Dest, AddrExpr, VarRec.DL);
2150 (void)Assign;
2151 LLVM_DEBUG(if (Assign) errs() << " > INSERT: " << *Assign << "\n");
2152}
2153
2154#undef DEBUG_TYPE
2155#define DEBUG_TYPE "assignment-tracking"
2156
2159 bool DebugPrints) {
2160
2161 if (Vars.empty())
2162 return;
2163
2164 auto &Ctx = Start->getContext();
2165 auto &Module = *Start->getModule();
2166
2167
2170
2171
2173 for (auto BBI = Start; BBI != End; ++BBI) {
2175
2176 std::optional Info;
2177 Value *ValueComponent = nullptr;
2178 Value *DestComponent = nullptr;
2180
2181
2182
2184 ValueComponent = Poison;
2185 DestComponent = AI;
2188 ValueComponent = SI->getValueOperand();
2189 DestComponent = SI->getPointerOperand();
2192
2193 ValueComponent = Poison;
2194 DestComponent = MI->getOperand(0);
2197
2198
2200 if (ConstValue && ConstValue->isZero())
2201 ValueComponent = ConstValue;
2202 else
2203 ValueComponent = Poison;
2204 DestComponent = MI->getOperand(0);
2205 } else {
2206
2207 continue;
2208 }
2209
2210 assert(ValueComponent && DestComponent);
2211 LLVM_DEBUG(errs() << "SCAN: Found store-like: " << I << "\n");
2212
2213
2214 if (!Info.has_value()) {
2217 << " | SKIP: Untrackable store (e.g. through non-const gep)\n");
2218 continue;
2219 }
2220 LLVM_DEBUG(errs() << " | BASE: " << *Info->Base << "\n");
2221
2222
2223 auto LocalIt = Vars.find(Info->Base);
2224 if (LocalIt == Vars.end()) {
2227 << " | SKIP: Base address not associated with local variable\n");
2228 continue;
2229 }
2230
2233 if () {
2235 I.setMetadata(LLVMContext::MD_DIAssignID, ID);
2236 }
2237
2238 for (const VarRecord &R : LocalIt->second)
2239 emitDbgAssign(*Info, ValueComponent, DestComponent, I, R, DIB);
2240 }
2241 }
2242}
2243
2244bool AssignmentTrackingPass::runOnFunction(Function &F) {
2245
2246 if (F.hasFnAttribute(Attribute::OptimizeNone))
2247 return false;
2248
2250 auto *DL = &F.getDataLayout();
2251
2252
2253
2255
2256
2259
2260
2261
2262 if (Declare.getExpression()->getNumElements() != 0)
2263 return;
2264 if (!Declare.getAddress())
2265 return;
2268
2269 if (!Alloca->isStaticAlloca())
2270 return;
2271
2272 if (auto Sz = Alloca->getAllocationSize(*DL); Sz && Sz->isScalable())
2273 return;
2274 DVRDeclares[Alloca].insert(&Declare);
2275 Vars[Alloca].insert(VarRecord(&Declare));
2276 }
2277 };
2278 for (auto &BB : F) {
2279 for (auto &I : BB) {
2280 for (DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
2281 if (DVR.isDbgDeclare())
2282 ProcessDeclare(DVR);
2283 }
2284 }
2285 }
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2297
2298
2299 for (auto &[Insts, Declares] : DVRDeclares) {
2301 for (auto *Declare : Declares) {
2302
2303
2304
2305
2306
2307
2308
2310 return DebugVariableAggregate(Assign) ==
2311 DebugVariableAggregate(Declare);
2312 }));
2313
2314
2315 Declare->eraseFromParent();
2317 }
2318 };
2320}
2321
2323 "debug-info-assignment-tracking";
2324
2330
2335
2339
2342 if (!runOnFunction(F))
2344
2345
2346
2347
2349
2350
2351
2354 return PA;
2355}
2356
2360 for (auto &F : M)
2361 Changed |= runOnFunction(F);
2362
2365
2366
2368
2369
2370
2373 return PA;
2374}
2375
2376#undef DEBUG_TYPE
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &ImportedModules)
static void setAssignmentTrackingModuleFlag(Module &M)
Definition DebugInfo.cpp:2325
static DISubprogram::DISPFlags pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized)
Definition DebugInfo.cpp:1047
static void findDbgIntrinsics(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Definition DebugInfo.cpp:101
static Metadata * stripLoopMDLoc(const SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
Definition DebugInfo.cpp:506
static llvm::DIFile::ChecksumKind map_from_llvmChecksumKind(LLVMChecksumKind CSKind)
Definition DebugInfo.cpp:1113
static MDNode * updateLoopMetadataDebugLocationsImpl(MDNode *OrigLoopID, function_ref< Metadata *(Metadata *)> Updater)
Definition DebugInfo.cpp:424
static MDNode * stripDebugLocFromLoopID(MDNode *N)
Definition DebugInfo.cpp:543
static const char * AssignmentTrackingModuleFlag
Definition DebugInfo.cpp:2322
static DINode::DIFlags map_from_llvmDIFlags(LLVMDIFlags Flags)
Definition DebugInfo.cpp:1038
static unsigned map_from_llvmDWARFsourcelanguage(LLVMDWARFSourceLanguage lang)
Definition DebugInfo.cpp:1023
static void emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest, Instruction &StoreLikeInst, const VarRecord &VarRec, DIBuilder &DIB)
Returns nullptr if the assignment shouldn't be attributed to this variable.
Definition DebugInfo.cpp:2109
static LLVMDIFlags map_to_llvmDIFlags(DINode::DIFlags Flags)
Definition DebugInfo.cpp:1042
static bool getAssignmentTrackingModuleFlag(const Module &M)
Definition DebugInfo.cpp:2331
PointerUnion< DIExpression *, DIVariable * > unwrapExprVar(LLVMMetadataRef MD)
MD may be nullptr, a DIExpression or DIVariable.
Definition DebugInfo.cpp:1367
static bool isAllDILocation(SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
Definition DebugInfo.cpp:480
static Metadata * updateLoopMetadataDebugLocationsRecursive(Metadata *MetadataIn, function_ref< Metadata *(Metadata *)> Updater)
Recursively handle DILocations in followup metadata etc.
Definition DebugInfo.cpp:399
static bool isDILocationReachable(SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &Reachable, Metadata *MD)
Return true if a node is a DILocation or if a DILocation is indirectly referenced by one of the node'...
Definition DebugInfo.cpp:459
DIT * unwrapDI(LLVMMetadataRef Ref)
Definition DebugInfo.cpp:1034
static std::optional< AssignmentInfo > getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest, TypeSize SizeInBits)
Collect constant properties (base, size, offset) of StoreDest.
Definition DebugInfo.cpp:2064
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first DebugLoc that has line number information, given a range of instructions.
uint64_t IntrinsicInst * II
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
FunctionLoweringInfo::StatepointRelocationRecord RecordType
static uint32_t getFlags(const Symbol *Sym)
Class for arbitrary precision integers.
bool isNegative() const
Determine sign of this APInt.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
An arbitrary precision integer that knows its signedness.
an instruction to allocate memory on the stack
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition DebugInfo.cpp:2340
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
Represents analyses that only rely on functions' control flow.
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
static DIAssignID * getDistinct(LLVMContext &Context)
bool getDebugInfoForProfiling() const
StringRef getFlags() const
static LLVM_ABI std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
bool getRangesBaseAddress() const
DIMacroNodeArray getMacros() const
unsigned getRuntimeVersion() const
bool getSplitDebugInlining() const
StringRef getSysRoot() const
StringRef getProducer() const
DISourceLanguageName getSourceLanguage() const
uint64_t getDWOId() const
StringRef getSplitDebugFilename() const
DbgVariableFragmentInfo FragmentInfo
static LLVM_ABI bool calculateFragmentIntersect(const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a...
static LLVM_ABI std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
LLVM_ABI bool extractLeadingOffset(int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps) const
Assuming that the expression operates on an address, extract a constant offset and the successive ops...
ChecksumKind
Which algorithm (e.g.
A pair of DIGlobalVariable and DIExpression.
An imported module (C++ using directive or similar).
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DILocalScope * getScope() const
Get the local scope for this variable.
Tagged DWARF-like metadata node.
Base class for scope-like contexts.
LLVM_ABI StringRef getName() const
Wrapper structure that holds a language name and its version.
Subprogram description. Uses SubclassData1.
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
DISPFlags
Debug info subprogram flags.
Type array for a subprogram.
DIScope * getScope() const
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
A parsed version of the target data layout string in and methods for querying it.
Base class for non-instruction debug metadata records that have positions within IR.
LLVM_ABI LLVMContext & getContext()
DebugLoc getDebugLoc() const
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI Value * getAddress() const
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
DbgVariableFragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
static LLVM_ABI DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DIExpression * getAddressExpression() const
LLVM_ABI void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
Definition DebugInfo.cpp:217
LLVM_ABI void processModule(const Module &M)
Process entire module and collect debug info anchors.
Definition DebugInfo.cpp:182
LLVM_ABI void processSubprogram(DISubprogram *SP)
Process subprogram.
Definition DebugInfo.cpp:304
LLVM_ABI void processLocation(const Module &M, const DILocation *Loc)
Process debug info location.
Definition DebugInfo.cpp:229
LLVM_ABI void reset()
Clear all lists.
Definition DebugInfo.cpp:173
LLVM_ABI void processVariable(const DILocalVariable *DVI)
Process a DILocalVariable.
Definition DebugInfo.cpp:332
LLVM_ABI void processDbgRecord(const Module &M, const DbgRecord &DR)
Process a DbgRecord.
Definition DebugInfo.cpp:236
LLVM_ABI DILocation * get() const
Get the underlying DILocation.
LLVM_ABI MDNode * getScope() const
static LLVM_ABI DebugLoc getMergedLocation(DebugLoc LocA, DebugLoc LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
LLVM_ABI DILocation * getInlinedAt() const
static DebugLoc getDropped()
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
BasicBlockListType::iterator iterator
DISubprogram * getSubprogram() const
Get the attached subprogram.
LLVM_ABI void mergeDIAssignID(ArrayRef< const Instruction * > SourceInstructions)
Merge the DIAssignID metadata from this instruction and those attached to instructions in SourceInstr...
Definition DebugInfo.cpp:949
LLVM_ABI void dropLocation()
Drop the instruction's debug location.
Definition DebugInfo.cpp:980
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_ABI void updateLocationAfterHoist()
Updates the debug location given that the instruction has been hoisted from a block to a predecessor ...
Definition DebugInfo.cpp:978
Instruction(const Instruction &)=delete
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM_ABI void applyMergedLocation(DebugLoc LocA, DebugLoc LocB)
Merge 2 debug locations and apply it to the Instruction.
Definition DebugInfo.cpp:945
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static LLVM_ABI void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
const MDOperand & getOperand(unsigned I) const
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
Tracking metadata reference owned by Metadata.
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
This is the common base class for memset/memcpy/memmove.
A Module instance is used to store all the information related to an LLVM module.
@ Max
Takes the max of the two values, which are required to be integers.
LLVM_ABI StringRef getName() const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
void push_back(EltTy NewVal)
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef Decl, LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported function, type, or variable.
Definition DebugInfo.cpp:1233
LLVM_C_ABI LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location)
Get the "inline at" location associated with this debug location.
Definition DebugInfo.cpp:1266
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal, uint32_t AlignInBits)
Create debugging information entry for a C++ static data member.
Definition DebugInfo.cpp:1489
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for an array.
Definition DebugInfo.cpp:1417
LLVM_C_ABI unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram)
Get the line associated with a given subprogram.
Definition DebugInfo.cpp:1885
LLVM_C_ABI LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location)
Get the local scope associated with this debug location.
Definition DebugInfo.cpp:1262
LLVM_C_ABI unsigned LLVMDITypeGetLine(LLVMMetadataRef DType)
Get the source line where this DIType is declared.
Definition DebugInfo.cpp:1676
LLVMDWARFMacinfoRecordType
Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, int64_t Value, LLVMBool IsUnsigned)
Create debugging information entry for an enumerator.
Definition DebugInfo.cpp:1315
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder, uint64_t Value)
Create a new descriptor for the specified variable that does not have an address, but does have a con...
Definition DebugInfo.cpp:1710
LLVM_C_ABI void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder)
Construct any deferred debug info descriptors.
Definition DebugInfo.cpp:1075
LLVM_C_ABI void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP)
Set the subprogram attached to a function.
Definition DebugInfo.cpp:1881
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSetType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy)
Create debugging information entry for a set.
Definition DebugInfo.cpp:1344
LLVM_C_ABI void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder, LLVMMetadataRef Subprogram)
Finalize a specific subprogram.
Definition DebugInfo.cpp:1079
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateMacro(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMDWARFMacinfoRecordType RecordType, const char *Name, size_t NameLen, const char *Value, size_t ValueLen)
Create debugging information entry for a macro.
Definition DebugInfo.cpp:1295
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition DebugInfo.cpp:1828
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
Create a DWARF unspecified type.
Definition DebugInfo.cpp:1484
LLVM_C_ABI LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M)
Construct a builder for a module, and do not allow for unresolved nodes attached to the module.
Definition DebugInfo.cpp:1055
LLVM_C_ABI LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t NumElements)
Create a new temporary MDNode.
Definition DebugInfo.cpp:1748
LLVM_C_ABI LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope)
Get the metadata of the file associated with a given scope.
Definition DebugInfo.cpp:1270
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition DebugInfo.cpp:1776
LLVM_C_ABI LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M)
Construct a builder for a module and collect unresolved nodes attached to the module in order to reso...
Definition DebugInfo.cpp:1059
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateLabel(LLVMDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve)
Create a new descriptor for a label.
Definition DebugInfo.cpp:1906
LLVM_C_ABI const char * LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len)
Get the source of a given file.
Definition DebugInfo.cpp:1286
LLVM_C_ABI unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location)
Get the column number of this debug location.
Definition DebugInfo.cpp:1258
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder, uint64_t *Addr, size_t Length)
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition DebugInfo.cpp:1703
LLVM_C_ABI const char * LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len)
Get the name of a given file.
Definition DebugInfo.cpp:1280
LLVM_C_ABI LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func)
Get the metadata of the subprogram attached to a function.
Definition DebugInfo.cpp:1877
LLVMDWARFSourceLanguage
Source languages known by DWARF.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd)
Insert a new llvm.dbg.label intrinsic call.
Definition DebugInfo.cpp:1936
LLVM_C_ABI LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst)
Get the debug location for the given instruction.
Definition DebugInfo.cpp:1895
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition DebugInfo.cpp:1794
LLVM_C_ABI void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder)
Deallocates the DIBuilder and everything it owns.
Definition DebugInfo.cpp:1071
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateUnionType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, const char *UniqueId, size_t UniqueIdLen)
Create debugging information entry for a union.
Definition DebugInfo.cpp:1401
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition DebugInfo.cpp:1810
LLVM_C_ABI LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE)
Retrieves the DIVariable associated with this global variable expression.
Definition DebugInfo.cpp:1727
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create an array of DI Nodes.
Definition DebugInfo.cpp:1870
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateFunction(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool IsLocalToUnit, LLVMBool IsDefinition, unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized)
Create a new descriptor for the specified subprogram.
Definition DebugInfo.cpp:1162
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags)
Create a new descriptor for a function parameter variable.
Definition DebugInfo.cpp:1855
LLVM_C_ABI uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType)
Get the size of this DIType in bits.
Definition DebugInfo.cpp:1664
LLVM_C_ABI void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TempTargetMetadata, LLVMMetadataRef Replacement)
Replace all uses of temporary metadata.
Definition DebugInfo.cpp:1758
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create a type array.
Definition DebugInfo.cpp:1684
LLVM_C_ABI LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE)
Retrieves the DIExpression associated with this global variable expression.
Definition DebugInfo.cpp:1731
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateFileWithChecksum(LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, size_t DirectoryLen, LLVMChecksumKind ChecksumKind, const char *Checksum, size_t ChecksumLen, const char *Source, size_t SourceLen)
Create a file descriptor to hold debugging information for a file.
Definition DebugInfo.cpp:1125
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Type)
Create debugging information entry for a bit field member.
Definition DebugInfo.cpp:1614
LLVMDIFlags
Debug info flags.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, size_t DirectoryLen)
Create a file descriptor to hold debugging information for a file.
Definition DebugInfo.cpp:1105
LLVM_C_ABI unsigned LLVMDebugMetadataVersion(void)
The current debug metadata version number.
Definition DebugInfo.cpp:1051
LLVM_C_ABI unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module)
The version of debug metadata that's present in the provided Module.
Definition DebugInfo.cpp:1063
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition DebugInfo.cpp:1501
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Decl, uint32_t AlignInBits)
Create a new descriptor for the specified global variable that is temporary and meant to be RAUWed.
Definition DebugInfo.cpp:1765
LLVM_C_ABI void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram, LLVMMetadataRef SubroutineType)
Replace the subprogram subroutine type.
Definition DebugInfo.cpp:1889
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create a permanent forward-declared type.
Definition DebugInfo.cpp:1556
LLVM_C_ABI LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var)
Get the metadata of the scope associated with a given variable.
Definition DebugInfo.cpp:1740
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits)
Create a new descriptor for the specified variable.
Definition DebugInfo.cpp:1715
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef Builder, LLVMDWARFSourceLanguage Lang, LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen, LLVMBool isOptimized, const char *Flags, size_t FlagsLen, unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen, LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining, LLVMBool DebugInfoForProfiling, const char *SysRoot, size_t SysRootLen, const char *SDK, size_t SDKLen)
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition DebugInfo.cpp:1084
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, const char *GetterName, size_t GetterNameLen, const char *SetterName, size_t SetterNameLen, unsigned PropertyAttributes, LLVMMetadataRef Ty)
Create debugging information entry for Objective-C property.
Definition DebugInfo.cpp:1515
LLVMChecksumKind
The kind of checksum to emit.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module.
Definition DebugInfo.cpp:1220
LLVM_C_ABI LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var)
Get the metadata of the file associated with a given variable.
Definition DebugInfo.cpp:1736
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t LowerBound, int64_t Count)
Create a descriptor for a value range.
Definition DebugInfo.cpp:1865
LLVM_C_ABI unsigned LLVMDILocationGetLine(LLVMMetadataRef Location)
Get the line number of this debug location.
Definition DebugInfo.cpp:1254
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMValueRef InsertBefore)
Insert a new llvm.dbg.label intrinsic call.
Definition DebugInfo.cpp:1917
LLVM_C_ABI unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var)
Get the source line where this DIVariable is declared.
Definition DebugInfo.cpp:1744
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a qualified type, e.g.
Definition DebugInfo.cpp:1582
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create debugging information entry for a class.
Definition DebugInfo.cpp:1629
LLVM_C_ABI LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata)
Obtain the enumerated type of a Metadata instance.
Definition DebugInfo.cpp:1953
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts, LLVMMetadataRef DataLocation, LLVMMetadataRef Associated, LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride)
Create debugging information entry for a dynamic array.
Definition DebugInfo.cpp:1377
LLVMDWARFEmissionKind
The amount of debug information to emit.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef BaseTy, LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound, LLVMMetadataRef Stride, LLVMMetadataRef Bias)
Create a descriptor for a subrange with dynamic bounds.
Definition DebugInfo.cpp:1353
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty)
Create debugging information entry for a member.
Definition DebugInfo.cpp:1473
LLVM_C_ABI const char * LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length)
Get the name of this DIType.
Definition DebugInfo.cpp:1658
LLVM_C_ABI uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType)
Get the offset of this DIType in bits.
Definition DebugInfo.cpp:1668
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create a temporary forward-declared type.
Definition DebugInfo.cpp:1568
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
Create debugging information temporary entry for a macro file.
Definition DebugInfo.cpp:1308
LLVM_C_ABI LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType)
Get the flags associated with this DIType.
Definition DebugInfo.cpp:1680
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, const char *ConfigMacros, size_t ConfigMacrosLen, const char *IncludePath, size_t IncludePathLen, const char *APINotesFile, size_t APINotesFileLen)
Creates a new descriptor for a module with the specified parent scope.
Definition DebugInfo.cpp:1142
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeType, LLVMMetadataRef ClassType, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags)
Create debugging information entry for a pointer to member.
Definition DebugInfo.cpp:1601
LLVM_C_ABI uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD)
Get the dwarf::Tag of a DINode.
Definition DebugInfo.cpp:1654
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, const uint64_t Words[], LLVMBool IsUnsigned)
Create debugging information entry for an enumerator of arbitrary precision.
Definition DebugInfo.cpp:1323
LLVM_C_ABI void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T, LLVMMetadataRef *Elements, unsigned NumElements)
Replace arrays.
Definition DebugInfo.cpp:1393
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, LLVMBool ExportSymbols)
Creates a new descriptor for a namespace with the specified parent scope.
Definition DebugInfo.cpp:1154
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateStructType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen)
Create debugging information entry for a struct.
Definition DebugInfo.cpp:1457
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Discriminator)
Create a descriptor for a lexical block with a new file attached.
Definition DebugInfo.cpp:1186
LLVM_C_ABI void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode)
Deallocate a temporary node.
Definition DebugInfo.cpp:1754
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, LLVMBool Implicit)
Create a uniqued DIType* clone with FlagObjectPointer.
Definition DebugInfo.cpp:1528
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Scope, uint32_t AlignInBits)
Create debugging information entry for a typedef.
Definition DebugInfo.cpp:1536
unsigned LLVMDWARFTypeEncoding
An LLVM DWARF type encoding.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags, uint32_t AlignInBits)
Create a new descriptor for a local auto variable.
Definition DebugInfo.cpp:1845
LLVM_C_ABI void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc)
Set the debug location for the given instruction.
Definition DebugInfo.cpp:1899
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
Create subroutine type.
Definition DebugInfo.cpp:1692
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for a vector type.
Definition DebugInfo.cpp:1428
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace, const char *Name, size_t NameLen)
Create debugging information entry for a pointer.
Definition DebugInfo.cpp:1448
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder)
Create C++11 nullptr type.
Definition DebugInfo.cpp:1596
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef ClassTy)
Create debugging information entry for an enumeration.
Definition DebugInfo.cpp:1332
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef ImportedEntity, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module that aliases another imported entity descriptor.
Definition DebugInfo.cpp:1207
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder, LLVMMetadataRef Ty, LLVMMetadataRef BaseTy, uint64_t BaseOffset, uint32_t VBPtrOffset, LLVMDIFlags Flags)
Create debugging information entry to establish inheritance relationship between two types.
Definition DebugInfo.cpp:1546
unsigned LLVMMetadataKind
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition DebugInfo.cpp:1589
LLVM_C_ABI LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module)
Strip debug info in the module if it exists.
Definition DebugInfo.cpp:1067
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, LLVMDWARFTypeEncoding Encoding, LLVMDIFlags Flags)
Create debugging information entry for a basic type.
Definition DebugInfo.cpp:1439
LLVM_C_ABI uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType)
Get the alignment of this DIType in bits.
Definition DebugInfo.cpp:1672
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Column)
Create a descriptor for a lexical block with the specified parent context.
Definition DebugInfo.cpp:1177
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagArtificial set.
Definition DebugInfo.cpp:1649
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line, unsigned Column, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt)
Creates a new DebugLocation that describes a source location.
Definition DebugInfo.cpp:1247
LLVM_C_ABI const char * LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len)
Get the directory of a given file.
Definition DebugInfo.cpp:1274
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
Create a descriptor for an imported namespace.
Definition DebugInfo.cpp:1196
@ LLVMGenericDINodeMetadataKind
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
struct LLVMOpaqueDIBuilder * LLVMDIBuilderRef
Represents an LLVM debug info builder.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
Assignment Tracking (at).
LLVM_ABI void deleteAll(Function *F)
Remove all Assignment Tracking related intrinsics and metadata from F.
Definition DebugInfo.cpp:1994
LLVM_ABI AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
Definition DebugInfo.cpp:1964
iterator_range< SmallVectorImpl< Instruction * >::iterator > AssignmentInstRange
A range of instructions.
LLVM_ABI void trackAssignments(Function::iterator Start, Function::iterator End, const StorageToVarsMap &Vars, const DataLayout &DL, bool DebugPrints=false)
Track assignments to Vars between Start and End.
Definition DebugInfo.cpp:2157
LLVM_ABI void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
Definition DebugInfo.cpp:2041
SmallVector< DbgVariableRecord * > getDVRAssignmentMarkers(const Instruction *Inst)
Return a range of dbg_assign records for which Inst performs the assignment they encode.
LLVM_ABI void deleteAssignmentMarkers(const Instruction *Inst)
Delete the llvm.dbg.assign intrinsics linked to Inst.
Definition DebugInfo.cpp:1976
LLVM_ABI std::optional< AssignmentInfo > getAssignmentInfo(const DataLayout &DL, const MemIntrinsic *I)
Definition DebugInfo.cpp:2084
DenseMap< const AllocaInst *, SmallSetVector< VarRecord, 2 > > StorageToVarsMap
Map of backing storage to a set of variables that are stored to it.
LLVM_ABI void RAUW(DIAssignID *Old, DIAssignID *New)
Replace all uses (and attachments) of Old with New.
Definition DebugInfo.cpp:1981
LLVM_ABI bool calculateFragmentIntersect(const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign, std::optional< DIExpression::FragmentInfo > &Result)
Calculate the fragment of the variable in DAI covered from (Dest + SliceOffsetInBits) to to (Dest + S...
Definition DebugInfo.cpp:2007
Calculates the starting offsets for various sections within the .debug_names section.
void prune(LinkGraph &G)
Removes dead symbols/blocks/addressables.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void findDbgValues(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the dbg.values describing a value.
Definition DebugInfo.cpp:141
LLVM_ABI bool stripDebugInfo(Function &F)
Definition DebugInfo.cpp:578
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
@ Import
Import information from summary.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
auto cast_or_null(const Y &Val)
auto dyn_cast_or_null(const Y &Val)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FunctionAddr VTableAddr Count
LLVM_ABI bool stripNonLineTableDebugInfo(Module &M)
Downgrade the debug info in a module to contain only line table information.
Definition DebugInfo.cpp:852
LLVM_ABI TinyPtrVector< DbgVariableRecord * > findDVRValues(Value *V)
As above, for DVRValues.
Definition DebugInfo.cpp:82
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
Definition DebugInfo.cpp:938
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition DebugInfo.cpp:612
@ Ref
The access may reference the value stored in memory.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Attribute unwrap(LLVMAttributeRef Attr)
LLVM_ABI bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
Definition DebugInfo.cpp:2336
LLVM_ABI DebugLoc getDebugValueLoc(DbgVariableRecord *DVR)
Produce a DebugLoc to use for each dbg.declare that is promoted to a dbg.value.
Definition DebugInfo.cpp:157
DWARFExpression::Operation Op
LLVM_ABI TinyPtrVector< DbgVariableRecord * > findDVRDeclareValues(Value *V)
As above, for DVRDeclareValues.
Definition DebugInfo.cpp:65
ArrayRef(const T &OneElt) -> ArrayRef< T >
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
LLVMAttributeRef wrap(Attribute Attr)
LLVM_ABI TinyPtrVector< DbgVariableRecord * > findDVRDeclares(Value *V)
Finds dbg.declare records declaring local variables as living in the memory that 'V' points to.
Definition DebugInfo.cpp:48
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
PointerUnion< Instruction *, DbgRecord * > DbgInstPtr
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
LLVM_ABI void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
Definition DebugInfo.cpp:448
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.
Definition DebugInfo.cpp:146
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition DebugInfo.cpp:151
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A single checksum, represented by a Kind and a Value (a string).
Describes properties of a store that has a static size and offset into a some base storage.
Helper struct for trackAssignments, below.