LLVM: lib/IR/DebugInfoMetadata.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
26
27#include
28#include
29
30using namespace llvm;
31
32namespace llvm {
33
35 "enable-fs-discriminator", cl::Hidden,
36 cl::desc("Enable adding flow sensitive discriminators"));
37
38
39
42 cl::desc("Preserve line and column number when merging locations."));
43}
44
48
50 std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
51
54 Fragment(DVR->getExpression()->getFragmentInfo()),
56
60
61DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
64 : MDNode(C, DILocationKind, Storage, MDs), AtomGroup(AtomGroup),
65 AtomRank(AtomRank) {
66 assert(AtomRank <= 7 && "AtomRank number should fit in 3 bits");
67 if (AtomGroup)
68 C.updateDILocationAtomGroupWaterline(AtomGroup + 1);
69
71 "Expected a scope and optional inlined-at");
72
73 assert(Column < (1u << 16) && "Expected 16-bit column");
74
75 SubclassData32 = Line;
76 SubclassData16 = Column;
77
78 setImplicitCode(ImplicitCode);
79}
80
82
83 if (Column >= (1u << 16))
84 Column = 0;
85}
86
88 unsigned Column, Metadata *Scope,
89 Metadata *InlinedAt, bool ImplicitCode,
90 uint64_t AtomGroup, uint8_t AtomRank,
91 StorageType Storage, bool ShouldCreate) {
92
94
96 if (auto *N = getUniqued(Context.pImpl->DILocations,
99 AtomGroup, AtomRank)))
100 return N;
101 if (!ShouldCreate)
102 return nullptr;
103 } else {
104 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
105 }
106
114 Storage, Context.pImpl->DILocations);
115}
116
118 if (Locs.empty())
119 return nullptr;
120 if (Locs.size() == 1)
121 return Locs[0];
122 auto *Merged = Locs[0];
125 if (Merged == nullptr)
126 break;
127 }
128 return Merged;
129}
130
133 TempMDNode ClonedScope = LBB->clone();
137}
138
139using LineColumn = std::pair<unsigned , unsigned >;
140
141
144
148 return {LB->getLine(), LB->getColumn()};
150 return {SP->getLine(), 0u};
151
153}
154
155
156template
157static std::pair<DIScope *, LineColumn>
159 MatcherT Matcher;
160
162 DIScope *S2 = L2->getScope();
163
164 LineColumn Loc1(L1->getLine(), L1->getColumn());
165 for (; S1; S1 = S1->getScope()) {
167 Matcher.insert(S1, Loc1);
169 break;
170 }
171
172 LineColumn Loc2(L2->getLine(), L2->getColumn());
173 for (; S2; S2 = S2->getScope()) {
175
176 if (DIScope *S = Matcher.match(S2, Loc2))
177 return std::make_pair(S, Loc2);
178
180 break;
181 }
182 return std::make_pair(nullptr, LineColumn(L2->getLine(), L2->getColumn()));
183}
184
185
188
190
192 return Scopes.contains(S) ? S : nullptr;
193 }
194};
195
196
199 8>
201
205
208
209 if (ScopesAtLoc == Scopes.end())
210 return nullptr;
211
212
213 if (ScopesAtLoc->second.contains(S))
214 return S;
215
216 if (!ScopesAtLoc->second.empty())
217 return *ScopesAtLoc->second.begin();
218
220 }
221};
222
224 if (LocA == LocB)
225 return LocA;
226
227
228
229
230
231
233 if (!LocA || !LocB)
234 return LocA ? LocA : LocB;
235
236 auto A = std::make_tuple(LocA->getLine(), LocA->getColumn(),
237 LocA->getDiscriminator(), LocA->getFilename(),
238 LocA->getDirectory());
239 auto B = std::make_tuple(LocB->getLine(), LocB->getColumn(),
240 LocB->getDiscriminator(), LocB->getFilename(),
241 LocB->getDirectory());
242 return A < B ? LocA : LocB;
243 }
244
245 if (!LocA || !LocB)
246 return nullptr;
247
249
251 LocVec ALocs;
252 LocVec BLocs;
254 4>
255 ALookup;
256
257
258
259
260 for (auto [L, I] = std::make_pair(LocA, 0U); L; L = L->getInlinedAt(), I++) {
261 ALocs.push_back(L);
263 {L->getScope()->getSubprogram(), L->getInlinedAt()}, I);
264 assert(Res.second && "Multiple <SP, InlinedAt> pairs in a location chain?");
265 (void)Res;
266 }
267
268 LocVec::reverse_iterator ARIt = ALocs.rend();
269 LocVec::reverse_iterator BRIt = BLocs.rend();
270
271
272
273
274
275 for (auto [L, I] = std::make_pair(LocB, 0U); L; L = L->getInlinedAt(), I++) {
276 BLocs.push_back(L);
277
278 if (ARIt != ALocs.rend())
279
280 continue;
281
282 auto IT = ALookup.find({L->getScope()->getSubprogram(), L->getInlinedAt()});
284 continue;
285
286
287 ARIt = LocVec::reverse_iterator(ALocs.begin() + IT->second + 1);
288 BRIt = LocVec::reverse_iterator(BLocs.begin() + I + 1);
289
290
291
292
293
294 break;
295 }
296
297
298
299 auto *LocAIA = LocA->getInlinedAt();
300 auto *LocBIA = LocB->getInlinedAt();
301 auto MergeLocPair = [&C, LocAIA,
302 LocBIA](const DILocation *L1, const DILocation *L2,
303 DILocation *InlinedAt) -> DILocation * {
304 if (L1 == L2)
305 return DILocation::get(C, L1->getLine(), L1->getColumn(), L1->getScope(),
307 L1->getAtomGroup(), L1->getAtomRank());
308
309
310
311 if (L1->getScope()->getSubprogram() != L2->getScope()->getSubprogram())
312 return nullptr;
313
314
316 assert(Scope && "No common scope in the same subprogram?");
317
318
319 if (Scope->getFile() != L1->getFile() || L1->getFile() != L2->getFile()) {
320 auto [CommonLocScope, CommonLoc] =
322
323
324
325
327 LBB && LBB != Scope)
329
330 Scope = CommonLocScope;
331
332
333
334 if (Scope->getFile() != L1->getFile() || L1->getFile() != L2->getFile())
337 }
338
339 bool SameLine = L1->getLine() == L2->getLine();
340 bool SameCol = L1->getColumn() == L2->getColumn();
341 unsigned Line = SameLine ? L1->getLine() : 0;
342 unsigned Col = SameLine && SameCol ? L1->getColumn() : 0;
343 bool IsImplicitCode = L1->isImplicitCode() && L2->isImplicitCode();
344
345
346
347 if (!SameLine || !(L1->getAtomGroup() || L2->getAtomGroup()))
349 0, 0);
350
353
354
355 if (LocBIA == LocAIA && InlinedAt == LocBIA) {
356
357
358
359
360 bool UseL1Atom = [L1, L2]() {
361 if (L1->getAtomRank() == L2->getAtomRank()) {
362
363 if (!L1->getAtomGroup() || !L2->getAtomGroup())
364 return !L2->getAtomGroup();
365 return L1->getAtomGroup() < L2->getAtomGroup();
366 }
367
368 if (!L1->getAtomRank() || !L2->getAtomRank())
369 return !L2->getAtomRank();
370 return L1->getAtomRank() < L2->getAtomRank();
371 }();
372 Group = UseL1Atom ? L1->getAtomGroup() : L2->getAtomGroup();
373 Rank = UseL1Atom ? L1->getAtomRank() : L2->getAtomRank();
374 } else {
375
376
377
378
379 Group = C.incNextDILocationAtomGroup();
380 Rank = 1;
381 }
383 Group, Rank);
384 };
385
386 DILocation *Result = ARIt != ALocs.rend() ? (*ARIt)->getInlinedAt() : nullptr;
387
388
389
390 for (; ARIt != ALocs.rend() && BRIt != BLocs.rend(); ++ARIt, ++BRIt) {
391 DILocation *Tmp = MergeLocPair(*ARIt, *BRIt, Result);
392
393 if (!Tmp)
394
395
396
397 break;
398
399 Result = Tmp;
400 }
401
402 if (Result)
403 return Result;
404
405
406
407
408
409
410
411
412 return DILocation::get(C, 0, 0, LocA->getScope(), nullptr, false,
413 0, 0);
414}
415
416std::optional
418 std::array<unsigned, 3> Components = {BD, DF, CI};
420
421
422
423
424
425 RemainingWork =
426 std::accumulate(Components.begin(), Components.end(), RemainingWork);
427
428 int I = 0;
429 unsigned Ret = 0;
430 unsigned NextBitInsertionIndex = 0;
431 while (RemainingWork > 0) {
432 unsigned C = Components[I++];
433 RemainingWork -= C;
435 Ret |= (EC << NextBitInsertionIndex);
437 }
438
439
440
441
442
443 unsigned TBD, TDF, TCI = 0;
445 if (TBD == BD && TDF == DF && TCI == CI)
446 return Ret;
447 return std::nullopt;
448}
449
458
461#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
462#include "llvm/IR/DebugInfoFlags.def"
463 .Default(DINode::FlagZero);
464}
465
467 switch (Flag) {
468#define HANDLE_DI_FLAG(ID, NAME) \
469 case Flag##NAME: \
470 return "DIFlag" #NAME;
471#include "llvm/IR/DebugInfoFlags.def"
472 }
473 return "";
474}
475
478
479
480
482 if (A == FlagPrivate)
483 SplitFlags.push_back(FlagPrivate);
484 else if (A == FlagProtected)
485 SplitFlags.push_back(FlagProtected);
486 else
487 SplitFlags.push_back(FlagPublic);
488 Flags &= ~A;
489 }
491 if (R == FlagSingleInheritance)
492 SplitFlags.push_back(FlagSingleInheritance);
493 else if (R == FlagMultipleInheritance)
494 SplitFlags.push_back(FlagMultipleInheritance);
495 else
496 SplitFlags.push_back(FlagVirtualInheritance);
497 Flags &= ~R;
498 }
499 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
500 Flags &= ~FlagIndirectVirtualBase;
501 SplitFlags.push_back(FlagIndirectVirtualBase);
502 }
503
504#define HANDLE_DI_FLAG(ID, NAME) \
505 if (DIFlags Bit = Flags & Flag##NAME) { \
506 SplitFlags.push_back(Bit); \
507 Flags &= ~Bit; \
508 }
509#include "llvm/IR/DebugInfoFlags.def"
510 return Flags;
511}
512
515 return T->getScope();
516
518 return SP->getScope();
519
521 return LB->getScope();
522
524 return NS->getScope();
525
527 return CB->getScope();
528
530 return M->getScope();
531
533 "Unhandled type of scope.");
534 return nullptr;
535}
536
539 return T->getName();
541 return SP->getName();
543 return NS->getName();
545 return CB->getName();
547 return M->getName();
550 "Unhandled type of scope.");
551 return "";
552}
553
554#ifndef NDEBUG
558#endif
559
564 StorageType Storage, bool ShouldCreate) {
565 unsigned Hash = 0;
568 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
569 return N;
570 if (!ShouldCreate)
571 return nullptr;
572 Hash = Key.getHash();
573 } else {
574 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
575 }
576
577
582 Storage, Context.pImpl->GenericDINodes);
583}
584
585void GenericDINode::recalculateHash() {
586 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
587}
588
589#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
590#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
591#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
592 do { \
593 if (Storage == Uniqued) { \
594 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
595 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
596 return N; \
597 if (!ShouldCreate) \
598 return nullptr; \
599 } else { \
600 assert(ShouldCreate && \
601 "Expected non-uniqued nodes to always be created"); \
602 } \
603 } while (false)
604#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
605 return storeImpl(new (std::size(OPS), Storage) \
606 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
607 Storage, Context.pImpl->CLASS##s)
608#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
609 return storeImpl(new (0u, Storage) \
610 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
611 Storage, Context.pImpl->CLASS##s)
612#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
613 return storeImpl(new (std::size(OPS), Storage) CLASS(Context, Storage, OPS), \
614 Storage, Context.pImpl->CLASS##s)
615#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) \
616 return storeImpl(new (NUM_OPS, Storage) \
617 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
618 Storage, Context.pImpl->CLASS##s)
619
620DISubrange::DISubrange(LLVMContext &C, StorageType Storage,
622 : DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops) {}
624 StorageType Storage, bool ShouldCreate) {
629 return getImpl(Context, CountNode, LB, nullptr, nullptr, Storage,
630 ShouldCreate);
631}
632
634 int64_t Lo, StorageType Storage,
635 bool ShouldCreate) {
638 return getImpl(Context, CountNode, LB, nullptr, nullptr, Storage,
639 ShouldCreate);
640}
641
644 StorageType Storage, bool ShouldCreate) {
648}
649
651 Metadata *CB = getRawCountNode();
652 if (!CB)
653 return BoundType();
654
657 "Count must be signed constant or DIVariable or DIExpression");
658
661
663 return BoundType(MD);
664
666 return BoundType(MD);
667
668 return BoundType();
669}
670
672 Metadata *LB = getRawLowerBound();
673 if (!LB)
674 return BoundType();
675
678 "LowerBound must be signed constant or DIVariable or DIExpression");
679
682
684 return BoundType(MD);
685
687 return BoundType(MD);
688
689 return BoundType();
690}
691
693 Metadata *UB = getRawUpperBound();
694 if (!UB)
695 return BoundType();
696
699 "UpperBound must be signed constant or DIVariable or DIExpression");
700
703
705 return BoundType(MD);
706
708 return BoundType(MD);
709
710 return BoundType();
711}
712
714 Metadata *ST = getRawStride();
715 if (!ST)
716 return BoundType();
717
720 "Stride must be signed constant or DIVariable or DIExpression");
721
724
726 return BoundType(MD);
727
729 return BoundType(MD);
730
731 return BoundType();
732}
733DIGenericSubrange::DIGenericSubrange(LLVMContext &C, StorageType Storage,
735 : DINode(C, DIGenericSubrangeKind, Storage, dwarf::DW_TAG_generic_subrange,
737
741 StorageType Storage,
742 bool ShouldCreate) {
744 Metadata *Ops[] = {CountNode, LB, UB, Stride};
746}
747
750 if (!CB)
752
754 "Count must be signed constant or DIVariable or DIExpression");
755
758
761
763}
764
767 if (!LB)
769
771 "LowerBound must be signed constant or DIVariable or DIExpression");
772
775
778
780}
781
784 if (!UB)
786
788 "UpperBound must be signed constant or DIVariable or DIExpression");
789
792
795
797}
798
801 if (!ST)
803
805 "Stride must be signed constant or DIVariable or DIExpression");
806
809
812
814}
815
816DISubrangeType::DISubrangeType(LLVMContext &C, StorageType Storage,
817 unsigned Line, uint32_t AlignInBits,
819 : DIType(C, DISubrangeTypeKind, Storage, dwarf::DW_TAG_subrange_type, Line,
820 AlignInBits, 0, Flags, Ops) {}
821
826 Metadata *Stride, Metadata *Bias, StorageType Storage, bool ShouldCreate) {
834}
835
837DISubrangeType::convertRawToBound(Metadata *IN) const {
838 if (!IN)
840
843
846
849
852
855
857}
858
859DIEnumerator::DIEnumerator(LLVMContext &C, StorageType Storage,
862 : DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
865}
867 bool IsUnsigned, MDString *Name,
868 StorageType Storage, bool ShouldCreate) {
873}
874
891
894 case dwarf::DW_ATE_signed:
895 case dwarf::DW_ATE_signed_char:
896 case dwarf::DW_ATE_signed_fixed:
898 case dwarf::DW_ATE_unsigned:
899 case dwarf::DW_ATE_unsigned_char:
900 case dwarf::DW_ATE_unsigned_fixed:
902 default:
903 return std::nullopt;
904 }
905}
906
910 unsigned Encoding, DIFlags Flags, unsigned Kind,
911 int Factor, APInt Numerator, APInt Denominator,
912 StorageType Storage, bool ShouldCreate) {
921}
922
924 return getEncoding() == dwarf::DW_ATE_signed_fixed;
925}
926
927std::optionalDIFixedPointType::FixedPointKind
935
937 switch (V) {
939 return "Binary";
941 return "Decimal";
943 return "Rational";
944 }
945 return nullptr;
946}
947
953 unsigned Encoding, StorageType Storage,
954 bool ShouldCreate) {
963}
965 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
967}
968
969
970
974 if (Tuple->getNumOperands() != 1)
975 return nullptr;
976 ED = Tuple->getOperand(0);
977 }
979}
980
982 assert(getTag() == dwarf::DW_TAG_inheritance);
985 return static_cast<uint32_t>(CI->getZExtValue());
986 return 0;
987}
991 return C->getValue();
992 return nullptr;
993}
994
997 getTag() == dwarf::DW_TAG_variable) &&
1000 return C->getValue();
1001 return nullptr;
1002}
1006 return C->getValue();
1007 return nullptr;
1008}
1009
1014 std::optional DWARFAddressSpace,
1015 std::optional PtrAuthData, DIFlags Flags, Metadata *ExtraData,
1027}
1028
1029std::optionalDIDerivedType::PtrAuthData
1030DIDerivedType::getPtrAuthData() const {
1031 return getTag() == dwarf::DW_TAG_LLVM_ptrauth_type
1033 : std::nullopt;
1034}
1035
1039 uint32_t AlignInBits, Metadata *OffsetInBits, DIFlags Flags,
1040 Metadata *Elements, unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1044 Metadata *Specification, uint32_t NumExtraInhabitants, Metadata *BitStride,
1045 StorageType Storage, bool ShouldCreate) {
1047
1048
1050 DICompositeType,
1064}
1065
1071 Metadata *Elements, unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1075 assert(.getString().empty() && "Expected valid identifier");
1076 if (!Context.isODRUniquingDebugTypes())
1077 return nullptr;
1078 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
1079 if (!CT)
1086 if (CT->getTag() != Tag)
1087 return nullptr;
1088
1089
1090 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?");
1091 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
1092 return CT;
1093
1094
1102 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
1103 "Mismatched number of operands");
1104 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
1105 if (Ops[I] != CT->getOperand(I))
1106 CT->setOperand(I, Ops[I]);
1107 return CT;
1108}
1109
1114 Metadata *Specification, uint32_t NumExtraInhabitants, DIFlags Flags,
1115 Metadata *Elements, unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1119 assert(!Identifier.getString().empty() && "Expected valid identifier");
1120 if (!Context.isODRUniquingDebugTypes())
1121 return nullptr;
1122 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
1123 if (!CT) {
1130 } else {
1131 if (CT->getTag() != Tag)
1132 return nullptr;
1133 }
1134 return CT;
1135}
1136
1139 assert(.getString().empty() && "Expected valid identifier");
1140 if (!Context.isODRUniquingDebugTypes())
1141 return nullptr;
1142 return Context.pImpl->DITypeMap->lookup(&Identifier);
1143}
1144DISubroutineType::DISubroutineType(LLVMContext &C, StorageType Storage,
1145 DIFlags Flags, uint8_t CC,
1147 : DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type, 0,
1148 0, 0, Flags, Ops),
1149 CC(CC) {}
1150
1153 StorageType Storage,
1154 bool ShouldCreate) {
1158}
1159
1160DIFile::DIFile(LLVMContext &C, StorageType Storage,
1161 std::optional<ChecksumInfo<MDString *>> CS, MDString *Src,
1163 : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
1164 Checksum(CS), Source(Src) {}
1165
1166
1167
1169 "CSK_MD5",
1170 "CSK_SHA1",
1171 "CSK_SHA256",
1172};
1173
1174StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
1176
1177
1178
1180}
1181
1182std::optionalDIFile::ChecksumKind
1190
1194 MDString *Source, StorageType Storage,
1195 bool ShouldCreate) {
1199
1200
1204}
1205DICompileUnit::DICompileUnit(LLVMContext &C, StorageType Storage,
1207 bool IsOptimized, unsigned RuntimeVersion,
1208 unsigned EmissionKind, uint64_t DWOId,
1209 bool SplitDebugInlining,
1210 bool DebugInfoForProfiling, unsigned NameTableKind,
1212 : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
1215 IsOptimized(IsOptimized), SplitDebugInlining(SplitDebugInlining),
1216 DebugInfoForProfiling(DebugInfoForProfiling),
1217 RangesBaseAddress(RangesBaseAddress) {
1219}
1220
1224 unsigned RuntimeVersion, MDString *SplitDebugFilename,
1225 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
1227 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1228 unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
1229 MDString *SDK, StorageType Storage, bool ShouldCreate) {
1234
1247 Context, Storage, SourceLanguage, IsOptimized,
1248 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
1249 DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
1252}
1253
1254std::optionalDICompileUnit::DebugEmissionKind
1257 .Case("NoDebug", NoDebug)
1262}
1263
1264std::optionalDICompileUnit::DebugNameTableKind
1273
1275 switch (EK) {
1277 return "NoDebug";
1279 return "FullDebug";
1281 return "LineTablesOnly";
1283 return "DebugDirectivesOnly";
1284 }
1285 return nullptr;
1286}
1287
1289 switch (NTK) {
1291 return nullptr;
1293 return "GNU";
1295 return "Apple";
1297 return "None";
1298 }
1299 return nullptr;
1300}
1301DISubprogram::DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
1302 unsigned ScopeLine, unsigned VirtualIndex,
1303 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
1306 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1307 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
1310}
1313 unsigned Virtuality, bool IsMainSubprogram) {
1314
1315 static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
1316 int(SPFlagPureVirtual) ==
1317 int(dwarf::DW_VIRTUALITY_pure_virtual),
1318 "Virtuality constant mismatch");
1321 (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) |
1322 (IsDefinition ? SPFlagDefinition : SPFlagZero) |
1323 (IsOptimized ? SPFlagOptimized : SPFlagZero) |
1324 (IsMainSubprogram ? SPFlagMainSubprogram : SPFlagZero));
1325}
1326
1329 return Block->getScope()->getSubprogram();
1331}
1332
1335 return File->getScope()->getNonLexicalBlockFileScope();
1337}
1338
1343 DIScope *CachedResult = nullptr;
1344
1346 Scope = Scope->getScope()) {
1347 if (auto It = Cache.find(Scope); It != Cache.end()) {
1349 break;
1350 }
1352 }
1353
1354
1355
1356 DIScope *UpdatedScope = CachedResult ? CachedResult : &NewSP;
1357 for (DIScope *ScopeToUpdate : reverse(ScopeChain)) {
1360 Cache[ScopeToUpdate] = UpdatedScope;
1361 }
1362
1364}
1365
1368#define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
1369#include "llvm/IR/DebugInfoFlags.def"
1371}
1372
1374 switch (Flag) {
1375
1377 return "";
1378#define HANDLE_DISP_FLAG(ID, NAME) \
1379 case SPFlag##NAME: \
1380 return "DISPFlag" #NAME;
1381#include "llvm/IR/DebugInfoFlags.def"
1382 }
1383 return "";
1384}
1385
1389
1390
1391
1392#define HANDLE_DISP_FLAG(ID, NAME) \
1393 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
1394 SplitFlags.push_back(Bit); \
1395 Flags &= ~Bit; \
1396 }
1397#include "llvm/IR/DebugInfoFlags.def"
1398 return Flags;
1399}
1400
1404 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
1405 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1408 bool UsesKeyInstructions, StorageType Storage, bool ShouldCreate) {
1424 Ops.pop_back();
1426 Ops.pop_back();
1428 Ops.pop_back();
1430 Ops.pop_back();
1432 Ops.pop_back();
1433 }
1434 }
1435 }
1436 }
1438 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags,
1441}
1442
1444 assert(F && "Invalid function");
1445 return F->getSubprogram() == this;
1446}
1447
1449 return visitRetainedNode<DIScope *>(
1451 [](const DILabel *L) { return L->getScope(); },
1453 [](const Metadata *N) { return nullptr; });
1454}
1455
1456const DILocalScope *DISubprogram::getRetainedNodeScope(const MDNode *N) {
1458}
1459
1464
1466 Metadata *File, unsigned Line,
1467 unsigned Column, StorageType Storage,
1468 bool ShouldCreate) {
1469
1471
1472 assert(Scope && "Expected scope");
1476}
1477
1480 unsigned Discriminator,
1481 StorageType Storage,
1482 bool ShouldCreate) {
1487}
1488
1493}
1495 MDString *Name, bool ExportSymbols,
1496 StorageType Storage, bool ShouldCreate) {
1499
1502}
1503
1504DICommonBlock::DICommonBlock(LLVMContext &Context, StorageType Storage,
1506 : DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block,
1509}
1512 Metadata *File, unsigned LineNo,
1513 StorageType Storage, bool ShouldCreate) {
1516
1519}
1520
1521DIModule::DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
1526}
1529 MDString *ConfigurationMacros,
1531 unsigned LineNo, bool IsDecl, StorageType Storage,
1532 bool ShouldCreate) {
1539}
1540DITemplateTypeParameter::DITemplateTypeParameter(LLVMContext &Context,
1541 StorageType Storage,
1542 bool IsDefault,
1545 dwarf::DW_TAG_template_type_parameter, IsDefault,
1547
1551 StorageType Storage, bool ShouldCreate) {
1556}
1557
1560 bool isDefault, Metadata *Value, StorageType Storage, bool ShouldCreate) {
1566}
1567
1571 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1572 Metadata *StaticDataMemberDeclaration,
1573 Metadata *TemplateParams, uint32_t AlignInBits,
1575 bool ShouldCreate) {
1579 DIGlobalVariable,
1593}
1594
1598 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
1600 bool ShouldCreate) {
1601
1602 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
1603
1610}
1611
1619
1621 while (RawType) {
1622
1625 return Size;
1626
1628
1629 RawType = DT->getRawBaseType();
1630 continue;
1631 }
1632
1633
1634 break;
1635 }
1636
1637
1638 return std::nullopt;
1639}
1640
1641DILabel::DILabel(LLVMContext &C, StorageType Storage, unsigned Line,
1642 unsigned Column, bool IsArtificial,
1643 std::optional CoroSuspendIdx,
1645 : DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops) {
1647 this->Column = Column;
1648 this->IsArtificial = IsArtificial;
1649 this->CoroSuspendIdx = CoroSuspendIdx;
1650}
1652 Metadata *File, unsigned Line, unsigned Column,
1653 bool IsArtificial,
1654 std::optional CoroSuspendIdx,
1655 StorageType Storage, bool ShouldCreate) {
1656 assert(Scope && "Expected scope");
1663}
1664
1667 StorageType Storage, bool ShouldCreate) {
1670}
1673 return singleLocElts->size() > 0 &&
1675 }
1676 return false;
1677}
1680 return singleLocElts->size() > 0 &&
1681 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1682 return false;
1683}
1686 return singleLocElts->size() == 1 &&
1687 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1688 return false;
1689}
1690
1692 bool ShouldCreate) {
1693
1696}
1697
1700
1701 if (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31)
1702 return 2;
1703
1704 switch (Op) {
1709 case dwarf::DW_OP_bregx:
1710 return 3;
1711 case dwarf::DW_OP_constu:
1712 case dwarf::DW_OP_consts:
1713 case dwarf::DW_OP_deref_size:
1714 case dwarf::DW_OP_plus_uconst:
1718 case dwarf::DW_OP_regx:
1719 return 2;
1720 default:
1721 return 1;
1722 }
1723}
1724
1727
1728 if (I->get() + I->getSize() > E->get())
1729 return false;
1730
1732 if ((Op >= dwarf::DW_OP_reg0 && Op <= dwarf::DW_OP_reg31) ||
1733 (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31))
1734 return true;
1735
1736
1737 switch (Op) {
1738 default:
1739 return false;
1741
1742 return I->get() + I->getSize() == E->get();
1743 case dwarf::DW_OP_stack_value: {
1744
1745 if (I->get() + I->getSize() == E->get())
1746 break;
1747 auto J = I;
1749 return false;
1750 break;
1751 }
1752 case dwarf::DW_OP_swap: {
1753
1754
1755
1756
1757
1758
1759
1761 return false;
1762 break;
1763 }
1765
1766
1767
1768
1769
1772 ++FirstOp;
1773 return I->get() == FirstOp->get() && I->getArg(0) == 1;
1774 }
1781 case dwarf::DW_OP_constu:
1782 case dwarf::DW_OP_plus_uconst:
1783 case dwarf::DW_OP_plus:
1784 case dwarf::DW_OP_minus:
1785 case dwarf::DW_OP_mul:
1786 case dwarf::DW_OP_div:
1787 case dwarf::DW_OP_mod:
1788 case dwarf::DW_OP_or:
1789 case dwarf::DW_OP_and:
1790 case dwarf::DW_OP_xor:
1791 case dwarf::DW_OP_shl:
1792 case dwarf::DW_OP_shr:
1793 case dwarf::DW_OP_shra:
1794 case dwarf::DW_OP_deref:
1795 case dwarf::DW_OP_deref_size:
1796 case dwarf::DW_OP_xderef:
1797 case dwarf::DW_OP_lit0:
1798 case dwarf::DW_OP_not:
1799 case dwarf::DW_OP_dup:
1800 case dwarf::DW_OP_regx:
1801 case dwarf::DW_OP_bregx:
1802 case dwarf::DW_OP_push_object_address:
1803 case dwarf::DW_OP_over:
1804 case dwarf::DW_OP_rot:
1805 case dwarf::DW_OP_consts:
1806 case dwarf::DW_OP_eq:
1807 case dwarf::DW_OP_ne:
1808 case dwarf::DW_OP_gt:
1809 case dwarf::DW_OP_ge:
1810 case dwarf::DW_OP_lt:
1811 case dwarf::DW_OP_le:
1812 case dwarf::DW_OP_neg:
1813 case dwarf::DW_OP_abs:
1814 break;
1815 }
1816 }
1817 return true;
1818}
1819
1822 return false;
1823
1825 return false;
1826
1827 for (const auto &It : expr_ops()) {
1828 switch (It.getOp()) {
1829 default:
1830 break;
1831 case dwarf::DW_OP_stack_value:
1832 return true;
1833 }
1834 }
1835
1836 return false;
1837}
1838
1841 return false;
1842
1844 return false;
1845
1846
1847
1848 for (const auto &It : expr_ops()) {
1849 switch (It.getOp()) {
1853 continue;
1854 default:
1855 return true;
1856 }
1857 }
1858
1859 return false;
1860}
1861
1864 return false;
1865
1867 return true;
1868
1869 auto ExprOpBegin = expr_ops().begin();
1870 auto ExprOpEnd = expr_ops().end();
1872 if (ExprOpBegin->getArg(0) != 0)
1873 return false;
1874 ++ExprOpBegin;
1875 }
1876
1877 return !std::any_of(ExprOpBegin, ExprOpEnd, [](auto Op) {
1879 });
1880}
1881
1882std::optional<ArrayRef<uint64_t>>
1884
1886 return std::nullopt;
1887
1888
1891
1892
1893
1897}
1898
1908
1912 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1913 }))
1914 return Expr;
1920}
1921
1922std::optional<const DIExpression *>
1924 if (!Expr)
1925 return std::nullopt;
1926
1929
1930 return std::nullopt;
1931}
1932
1934 const DIExpression *Expr,
1935 bool IsIndirect) {
1936
1937
1939 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1940 }))
1942
1943
1944 if (!IsIndirect) {
1946 return;
1947 }
1948
1949
1950
1952 if (Op.getOp() == dwarf::DW_OP_stack_value ||
1954 Ops.push_back(dwarf::DW_OP_deref);
1955 IsIndirect = false;
1956 }
1958 }
1959 if (IsIndirect)
1960 Ops.push_back(dwarf::DW_OP_deref);
1961}
1962
1964 bool FirstIndirect,
1965 const DIExpression *SecondExpr,
1966 bool SecondIndirect) {
1971 SecondIndirect);
1972 return FirstOps == SecondOps;
1973}
1974
1975std::optionalDIExpression::FragmentInfo
1977 for (auto I = Start; I != End; ++I)
1980 return Info;
1981 }
1982 return std::nullopt;
1983}
1984
1986 std::optional<uint64_t> InitialActiveBits = Var->getSizeInBits();
1987 std::optional<uint64_t> ActiveBits = InitialActiveBits;
1989 switch (Op.getOp()) {
1990 default:
1991
1992
1993 ActiveBits = InitialActiveBits;
1994 break;
1997
1998
1999 std::optionalDIBasicType::Signedness VarSign = Var->getSignedness();
2002 if (!VarSign || VarSigned != OpSigned) {
2003 ActiveBits = InitialActiveBits;
2004 break;
2005 }
2006 [[fallthrough]];
2007 }
2009
2010 if (ActiveBits)
2011 ActiveBits = std::min(*ActiveBits, Op.getArg(1));
2012 else
2013 ActiveBits = Op.getArg(1);
2014 break;
2015 }
2016 }
2017 return ActiveBits;
2018}
2019
2023 Ops.push_back(dwarf::DW_OP_plus_uconst);
2025 } else if (Offset < 0) {
2026 Ops.push_back(dwarf::DW_OP_constu);
2027
2028
2030 Ops.push_back(AbsMinusOne + 1);
2031 Ops.push_back(dwarf::DW_OP_minus);
2032 }
2033}
2034
2037 if (!SingleLocEltsOpt)
2038 return false;
2039 auto SingleLocElts = *SingleLocEltsOpt;
2040
2041 if (SingleLocElts.size() == 0) {
2043 return true;
2044 }
2045
2046 if (SingleLocElts.size() == 2 &&
2047 SingleLocElts[0] == dwarf::DW_OP_plus_uconst) {
2048 Offset = SingleLocElts[1];
2049 return true;
2050 }
2051
2052 if (SingleLocElts.size() == 3 && SingleLocElts[0] == dwarf::DW_OP_constu) {
2053 if (SingleLocElts[2] == dwarf::DW_OP_plus) {
2054 Offset = SingleLocElts[1];
2055 return true;
2056 }
2057 if (SingleLocElts[2] == dwarf::DW_OP_minus) {
2058 Offset = -SingleLocElts[1];
2059 return true;
2060 }
2061 }
2062
2063 return false;
2064}
2065
2068 OffsetInBytes = 0;
2069 RemainingOps.clear();
2070
2072 if (!SingleLocEltsOpt)
2073 return false;
2074
2076 auto ExprOpIt = expr_op_iterator(SingleLocEltsOpt->begin());
2077 while (ExprOpIt != ExprOpEnd) {
2079 if (Op == dwarf::DW_OP_deref || Op == dwarf::DW_OP_deref_size ||
2083 break;
2084 } else if (Op == dwarf::DW_OP_plus_uconst) {
2085 OffsetInBytes += ExprOpIt->getArg(0);
2086 } else if (Op == dwarf::DW_OP_constu) {
2088 ++ExprOpIt;
2089 if (ExprOpIt->getOp() == dwarf::DW_OP_plus)
2090 OffsetInBytes += Value;
2091 else if (ExprOpIt->getOp() == dwarf::DW_OP_minus)
2092 OffsetInBytes -= Value;
2093 else
2094 return false;
2095 } else {
2096
2097 return false;
2098 }
2099 ++ExprOpIt;
2100 }
2101 RemainingOps.append(ExprOpIt.getBase(), ExprOpEnd.getBase());
2102 return true;
2103}
2104
2107 for (auto ExprOp : expr_ops())
2109 SeenOps.insert(ExprOp.getArg(0));
2110 for (uint64_t Idx = 0; Idx < N; ++Idx)
2112 return false;
2113 return true;
2114}
2115
2117 unsigned &AddrClass) {
2118
2119
2121 if (!SingleLocEltsOpt)
2122 return nullptr;
2123 auto SingleLocElts = *SingleLocEltsOpt;
2124
2125 const unsigned PatternSize = 4;
2126 if (SingleLocElts.size() >= PatternSize &&
2127 SingleLocElts[PatternSize - 4] == dwarf::DW_OP_constu &&
2128 SingleLocElts[PatternSize - 2] == dwarf::DW_OP_swap &&
2129 SingleLocElts[PatternSize - 1] == dwarf::DW_OP_xderef) {
2130 AddrClass = SingleLocElts[PatternSize - 3];
2131
2132 if (SingleLocElts.size() == PatternSize)
2133 return nullptr;
2136 ArrayRef(&*SingleLocElts.begin(), SingleLocElts.size() - PatternSize));
2137 }
2138 return Expr;
2139}
2140
2145 Ops.push_back(dwarf::DW_OP_deref);
2146
2149 Ops.push_back(dwarf::DW_OP_deref);
2150
2153
2155}
2156
2160 assert(Expr && "Can't add ops to this expression");
2161
2162
2164 [](auto Op) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) {
2165 assert(ArgNo == 0 &&
2166 "Location Index must be 0 for a non-variadic expression.");
2169 }
2170
2173
2175 if (Op.getOp() == dwarf::DW_OP_stack_value)
2178 NewOps.push_back(dwarf::DW_OP_stack_value);
2180 }
2181 }
2182 Op.appendToVector(NewOps);
2185 }
2187 NewOps.push_back(dwarf::DW_OP_stack_value);
2188
2190}
2191
2194 assert(Expr && "Can't replace args in this expression");
2195
2197
2200 Op.appendToVector(NewOps);
2201 continue;
2202 }
2204 uint64_t Arg = Op.getArg(0) == OldArg ? NewArg : Op.getArg(0);
2205
2206
2207 if (Arg > OldArg)
2208 --Arg;
2210 }
2212}
2213
2217 assert(Expr && "Can't prepend ops to this expression");
2218
2221
2222
2223
2224 Ops.push_back(1);
2225 }
2226
2227
2228 if (Ops.empty())
2231
2233 if (Op.getOp() == dwarf::DW_OP_stack_value)
2236 Ops.push_back(dwarf::DW_OP_stack_value);
2238 }
2239 }
2241 }
2243 Ops.push_back(dwarf::DW_OP_stack_value);
2245}
2246
2249 assert(Expr && .empty() && "Can't append ops to this expression");
2250
2251
2254
2255 if (Op.getOp() == dwarf::DW_OP_stack_value ||
2258
2259
2260 Ops = {};
2261 }
2262 Op.appendToVector(NewOps);
2263 }
2265 auto *result =
2267 assert(result->isValid() && "concatenated expression is not valid");
2268 return result;
2269}
2270
2273 assert(Expr && .empty() && "Can't append ops to this expression");
2276 [](auto Op) {
2277 return Op.getOp() == dwarf::DW_OP_stack_value ||
2278 Op.getOp() == dwarf::DW_OP_LLVM_fragment;
2279 }) &&
2280 "Can't append this op");
2281
2282
2283
2284
2285
2286 std::optional FI = Expr->getFragmentInfo();
2287 unsigned DropUntilStackValue = FI ? 3 : 0;
2290 bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
2291 (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
2292 bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
2293
2294
2295
2297 if (NeedsDeref)
2298 NewOps.push_back(dwarf::DW_OP_deref);
2300 if (NeedsStackValue)
2301 NewOps.push_back(dwarf::DW_OP_stack_value);
2303}
2304
2306 const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
2308
2309
2310 bool CanSplitValue = true;
2311
2312 bool EmitFragment = true;
2313
2314 if (Expr) {
2316 switch (Op.getOp()) {
2317 default:
2318 break;
2319 case dwarf::DW_OP_shr:
2320 case dwarf::DW_OP_shra:
2321 case dwarf::DW_OP_shl:
2322 case dwarf::DW_OP_plus:
2323 case dwarf::DW_OP_plus_uconst:
2324 case dwarf::DW_OP_minus:
2325
2326
2327
2328
2329
2330 CanSplitValue = false;
2331 break;
2332 case dwarf::DW_OP_deref:
2333 case dwarf::DW_OP_deref_size:
2334 case dwarf::DW_OP_deref_type:
2335 case dwarf::DW_OP_xderef:
2336 case dwarf::DW_OP_xderef_size:
2337 case dwarf::DW_OP_xderef_type:
2338
2339
2340 CanSplitValue = true;
2341 break;
2342 case dwarf::DW_OP_stack_value:
2343
2344 if (!CanSplitValue)
2345 return std::nullopt;
2346 break;
2348
2349
2350
2351 if (!EmitFragment)
2352 return std::nullopt;
2353
2354 uint64_t FragmentOffsetInBits = Op.getArg(0);
2355 uint64_t FragmentSizeInBits = Op.getArg(1);
2356 (void)FragmentSizeInBits;
2357 assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
2358 "new fragment outside of original fragment");
2359 OffsetInBits += FragmentOffsetInBits;
2360 continue;
2361 }
2364
2365
2366
2367 uint64_t ExtractOffsetInBits = Op.getArg(0);
2368 uint64_t ExtractSizeInBits = Op.getArg(1);
2369 if (ExtractOffsetInBits >= OffsetInBits &&
2370 ExtractOffsetInBits + ExtractSizeInBits <=
2371 OffsetInBits + SizeInBits) {
2372 Ops.push_back(Op.getOp());
2373 Ops.push_back(ExtractOffsetInBits - OffsetInBits);
2374 Ops.push_back(ExtractSizeInBits);
2375 EmitFragment = false;
2376 continue;
2377 }
2378
2379
2380
2381 return std::nullopt;
2382 }
2383 }
2385 }
2386 }
2387 assert((!Expr->isImplicit() || CanSplitValue) && "Expr can't be split");
2388 assert(Expr && "Unknown DIExpression");
2389 if (EmitFragment) {
2391 Ops.push_back(OffsetInBits);
2392 Ops.push_back(SizeInBits);
2393 }
2395}
2396
2397
2400 uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
2402 std::optionalDIExpression::FragmentInfo &Result,
2403 int64_t &OffsetFromLocationInBits) {
2404
2406 return false;
2407
2408
2409
2410
2411
2412
2413
2414
2415 int64_t MemStartRelToDbgStartInBits;
2416 {
2418 if (!MemOffsetFromDbgInBytes)
2419 return false;
2420
2421 MemStartRelToDbgStartInBits = *MemOffsetFromDbgInBytes * 8;
2422
2423 MemStartRelToDbgStartInBits +=
2424 SliceOffsetInBits - (DbgPtrOffsetInBits + DbgExtractOffsetInBits);
2425 }
2426
2427
2428 OffsetFromLocationInBits = -MemStartRelToDbgStartInBits;
2429
2430
2431 int64_t MemEndRelToDbgStart = MemStartRelToDbgStartInBits + SliceSizeInBits;
2432 if (MemEndRelToDbgStart < 0) {
2433 Result = {0, 0};
2434 return true;
2435 }
2436
2437
2438
2439
2440
2441
2442
2443
2444 int64_t MemStartRelToVarInBits =
2445 MemStartRelToDbgStartInBits + VarFrag.OffsetInBits;
2446 int64_t MemEndRelToVarInBits = MemStartRelToVarInBits + SliceSizeInBits;
2447
2448
2449
2450
2451 int64_t MemFragStart = std::max<int64_t>(0, MemStartRelToVarInBits);
2452 int64_t MemFragSize =
2453 std::max<int64_t>(0, MemEndRelToVarInBits - MemFragStart);
2455
2456
2459 if (TrimmedSliceOfVariable == VarFrag)
2460 Result = std::nullopt;
2461 else
2462 Result = TrimmedSliceOfVariable;
2463 return true;
2464}
2465
2466std::pair<DIExpression *, const ConstantInt *>
2468
2471
2472
2473 bool First = true;
2476 switch (Op.getOp()) {
2477 default:
2478
2479
2480
2482 return {this, CI};
2484 break;
2487 break;
2489 if (Op.getArg(1) == dwarf::DW_ATE_signed)
2491 else {
2492 assert(Op.getArg(1) == dwarf::DW_ATE_unsigned && "Unexpected operand");
2494 }
2495 continue;
2496 }
2498 }
2500 return {this, CI};
2502 ConstantInt::get(getContext(), NewInt)};
2503}
2504
2507 for (auto ExprOp : expr_ops())
2509 Result = std::max(Result, ExprOp.getArg(0) + 1);
2511 "Expression is missing one or more location operands.");
2512 return Result;
2513}
2514
2515std::optionalDIExpression::SignedOrUnsignedConstant
2517
2518
2519
2520
2521
2522
2523
2526 (getElement(0) != dwarf::DW_OP_consts &&
2527 getElement(0) != dwarf::DW_OP_constu))
2528 return std::nullopt;
2529
2532
2536 return std::nullopt;
2537 return getElement(0) == dwarf::DW_OP_constu
2540}
2541
2549
2551 unsigned FromSize, unsigned ToSize,
2554}
2555
2557DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
2559 bool ShouldCreate) {
2563}
2567 : DINode(C, DIObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property, Ops),
2569
2573 Metadata *Type, StorageType Storage, bool ShouldCreate) {
2581}
2582
2585 Metadata *File, unsigned Line,
2587 StorageType Storage,
2588 bool ShouldCreate) {
2594}
2595
2598 bool ShouldCreate) {
2603}
2604
2606 unsigned Line, Metadata *File,
2607 Metadata *Elements, StorageType Storage,
2608 bool ShouldCreate) {
2612}
2613
2616 auto ExistingIt = Context.pImpl->DIArgLists.find_as(DIArgListKeyInfo(Args));
2617 if (ExistingIt != Context.pImpl->DIArgLists.end())
2618 return *ExistingIt;
2619 DIArgList *NewArgList = new DIArgList(Context, Args);
2620 Context.pImpl->DIArgLists.insert(NewArgList);
2621 return NewArgList;
2622}
2623
2627 "DIArgList must be passed a ValueAsMetadata");
2628 untrack();
2629
2630
2634 if (&VM == OldVMPtr) {
2635 if (NewVM)
2636 VM = NewVM;
2637 else
2639 }
2640 }
2641
2642
2643
2644
2645 DIArgList *ExistingArgList = getUniqued(getContext().pImpl->DIArgLists, this);
2646 if (ExistingArgList) {
2648
2649 Args.clear();
2650 delete this;
2651 return;
2652 }
2654 track();
2655}
2656void DIArgList::track() {
2658 if (VAM)
2660}
2661void DIArgList::untrack() {
2663 if (VAM)
2665}
2666void DIArgList::dropAllReferences(bool Untrack) {
2667 if (Untrack)
2668 untrack();
2669 Args.clear();
2671}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
static unsigned encodingBits(unsigned C)
static unsigned encodeComponent(unsigned C)
static unsigned getNextComponentInDiscriminator(unsigned D)
Returns the next component stored in discriminator.
static unsigned getUnsignedFromPrefixEncoding(unsigned U)
Reverse transformation as getPrefixEncodingFromUnsigned.
This file contains constants used for implementing Dwarf debug support.
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.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file implements a set that has insertion order iteration characteristics.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Class for arbitrary precision integers.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Annotations lets you mark points and ranges inside source code, for tests:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & back() const
back - Get the last element.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
bool empty() const
empty - Check if the array is empty.
This is the shared class of boolean and integer constants.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New)
Definition DebugInfoMetadata.cpp:2624
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
Definition DebugInfoMetadata.cpp:2614
static DIBasicType * getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, StorageType Storage, bool ShouldCreate=true)
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, ArrayRef< Metadata * > Ops)
unsigned StringRef uint64_t SizeInBits
LLVM_ABI std::optional< Signedness > getSignedness() const
Return the signedness of this type, or std::nullopt if this type is neither signed nor unsigned.
Definition DebugInfoMetadata.cpp:892
unsigned getEncoding() const
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags unsigned StringRef uint64_t uint32_t unsigned uint32_t NumExtraInhabitants
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t AlignInBits
Metadata Metadata MDString Metadata unsigned LineNo
Metadata Metadata MDString * Name
Metadata Metadata MDString Metadata * File
static LLVM_ABI const char * nameTableKindString(DebugNameTableKind PK)
Definition DebugInfoMetadata.cpp:1288
static LLVM_ABI const char * emissionKindString(DebugEmissionKind EK)
Definition DebugInfoMetadata.cpp:1274
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString * SysRoot
DISourceLanguageName Metadata MDString bool MDString * Flags
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString MDString * SDK
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata * GlobalVariables
DebugEmissionKind getEmissionKind() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata * EnumTypes
DISourceLanguageName Metadata MDString * Producer
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata * RetainedTypes
DISourceLanguageName Metadata MDString bool MDString unsigned MDString * SplitDebugFilename
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata * ImportedEntities
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata * Macros
DebugNameTableKind getNameTableKind() const
DISourceLanguageName Metadata * File
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t AlignInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > EnumKind
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata * DataLocation
static LLVM_ABI DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits, Metadata *Specification, uint32_t NumExtraInhabitants, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, std::optional< uint32_t > EnumKind, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations, Metadata *BitStride)
Build a DICompositeType with the given ODR identifier.
Definition DebugInfoMetadata.cpp:1066
unsigned MDString Metadata unsigned Line
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata * Elements
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned RuntimeLang
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata * Annotations
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString * Identifier
static LLVM_ABI DICompositeType * getODRTypeIfExists(LLVMContext &Context, MDString &Identifier)
Definition DebugInfoMetadata.cpp:1137
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata * Discriminator
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata * TemplateParams
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t OffsetInBits
unsigned MDString Metadata unsigned Metadata * Scope
unsigned MDString Metadata * File
unsigned MDString Metadata unsigned Metadata Metadata * BaseType
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Flags
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata * Allocated
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata * Specification
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata * VTableHolder
unsigned MDString Metadata unsigned Metadata Metadata uint64_t SizeInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata * Associated
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata uint32_t NumExtraInhabitants
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata * Rank
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata uint32_t Metadata * BitStride
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata * OffsetInBits
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t AlignInBits
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > std::optional< PtrAuthData > PtrAuthData
Metadata * getExtraData() const
Get extra data associated with this derived type.
unsigned StringRef DIFile * File
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > DWARFAddressSpace
LLVM_ABI DIType * getClassType() const
Get casted version of extra data.
Definition DebugInfoMetadata.cpp:964
LLVM_ABI Constant * getConstant() const
Definition DebugInfoMetadata.cpp:995
unsigned StringRef DIFile unsigned DIScope DIType Metadata * SizeInBits
LLVM_ABI Constant * getStorageOffsetInBits() const
Definition DebugInfoMetadata.cpp:988
LLVM_ABI Constant * getDiscriminantValue() const
Definition DebugInfoMetadata.cpp:1003
LLVM_ABI uint32_t getVBPtrOffset() const
Definition DebugInfoMetadata.cpp:981
int64_t bool MDString * Name
LLVM_ABI unsigned getSize() const
Return the size of the operand.
Definition DebugInfoMetadata.cpp:1698
uint64_t getOp() const
Get the operand code.
An iterator for expression operands.
element_iterator elements_end() const
LLVM_ABI bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
Definition DebugInfoMetadata.cpp:1671
iterator_range< expr_op_iterator > expr_ops() const
static LLVM_ABI DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
Definition DebugInfoMetadata.cpp:2247
std::array< uint64_t, 6 > ExtOps
unsigned getNumElements() const
static LLVM_ABI ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
Definition DebugInfoMetadata.cpp:2542
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
LLVM_ABI bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
Definition DebugInfoMetadata.cpp:2035
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
Definition DebugInfoMetadata.cpp:2020
DbgVariableFragmentInfo FragmentInfo
LLVM_ABI bool startsWithDeref() const
Return whether the first element a DW_OP_deref.
Definition DebugInfoMetadata.cpp:1678
static LLVM_ABI bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...
Definition DebugInfoMetadata.cpp:1963
expr_op_iterator expr_op_end() const
LLVM_ABI bool isImplicit() const
Return whether this is an implicit location description.
Definition DebugInfoMetadata.cpp:1820
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...
Definition DebugInfoMetadata.cpp:2398
element_iterator elements_begin() const
LLVM_ABI bool hasAllLocationOps(unsigned N) const
Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg,...
Definition DebugInfoMetadata.cpp:2105
std::optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
Definition DebugInfoMetadata.cpp:2157
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
Definition DebugInfoMetadata.cpp:1839
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
Definition DebugInfoMetadata.cpp:1976
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
Definition DebugInfoMetadata.cpp:1923
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
Definition DebugInfoMetadata.cpp:2467
LLVM_ABI bool isDeref() const
Return whether there is exactly one operator and it is a DW_OP_deref;.
Definition DebugInfoMetadata.cpp:1684
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
Definition DebugInfoMetadata.cpp:1910
LLVM_ABI uint64_t getNumLocationOperands() const
Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; th...
Definition DebugInfoMetadata.cpp:2505
ArrayRef< uint64_t > getElements() const
static LLVM_ABI DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
Definition DebugInfoMetadata.cpp:2192
LLVM_ABI std::optional< uint64_t > getActiveBits(DIVariable *Var)
Return the number of bits that have an active value, i.e.
Definition DebugInfoMetadata.cpp:1985
static LLVM_ABI void canonicalizeExpressionOps(SmallVectorImpl< uint64_t > &Ops, const DIExpression *Expr, bool IsIndirect)
Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i....
Definition DebugInfoMetadata.cpp:1933
uint64_t getElement(unsigned I) const
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...
Definition DebugInfoMetadata.cpp:2305
static LLVM_ABI const DIExpression * convertToUndefExpression(const DIExpression *Expr)
Removes all elements from Expr that do not apply to an undef debug value, which includes every operat...
Definition DebugInfoMetadata.cpp:1900
static LLVM_ABI DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
Definition DebugInfoMetadata.cpp:2141
static LLVM_ABI DIExpression * appendToStack(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Convert DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed,...
Definition DebugInfoMetadata.cpp:2271
static LLVM_ABI DIExpression * appendExt(const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
Append a zero- or sign-extension to Expr.
Definition DebugInfoMetadata.cpp:2550
LLVM_ABI std::optional< ArrayRef< uint64_t > > getSingleLocationExpressionElements() const
Returns a reference to the elements contained in this expression, skipping past the leading DW_OP_LLV...
Definition DebugInfoMetadata.cpp:1883
LLVM_ABI bool isSingleLocationExpression() const
Return whether the evaluated expression makes use of a single location at the start of the expression...
Definition DebugInfoMetadata.cpp:1862
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...
Definition DebugInfoMetadata.cpp:2066
LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
Definition DebugInfoMetadata.cpp:2516
LLVM_ABI bool isValid() const
Definition DebugInfoMetadata.cpp:1725
static LLVM_ABI const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu DW_OP_swap DW_O...
Definition DebugInfoMetadata.cpp:2116
static LLVM_ABI DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
Definition DebugInfoMetadata.cpp:2214
MDString MDString * Directory
MDString MDString std::optional< ChecksumInfo< MDString * > > MDString * Source
static LLVM_ABI std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
Definition DebugInfoMetadata.cpp:1183
MDString MDString std::optional< ChecksumInfo< MDString * > > CS
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int Factor
static LLVM_ABI std::optional< FixedPointKind > getFixedPointKind(StringRef Str)
Definition DebugInfoMetadata.cpp:928
static LLVM_ABI const char * fixedPointKindString(FixedPointKind)
Definition DebugInfoMetadata.cpp:936
unsigned StringRef uint64_t uint32_t unsigned Encoding
unsigned StringRef uint64_t uint32_t AlignInBits
LLVM_ABI bool isSigned() const
Definition DebugInfoMetadata.cpp:923
@ FixedPointBinary
Scale factor 2^Factor.
@ FixedPointDecimal
Scale factor 10^Factor.
@ FixedPointRational
Arbitrary rational scale factor.
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int APInt Numerator
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int APInt APInt Denominator
unsigned StringRef uint64_t SizeInBits
Metadata * getRawLowerBound() const
Metadata * getRawCountNode() const
Metadata * getRawStride() const
LLVM_ABI BoundType getLowerBound() const
Definition DebugInfoMetadata.cpp:765
Metadata * getRawUpperBound() const
LLVM_ABI BoundType getCount() const
Definition DebugInfoMetadata.cpp:748
LLVM_ABI BoundType getUpperBound() const
Definition DebugInfoMetadata.cpp:782
PointerUnion< DIVariable *, DIExpression * > BoundType
LLVM_ABI BoundType getStride() const
Definition DebugInfoMetadata.cpp:799
A pair of DIGlobalVariable and DIExpression.
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata * TemplateParams
Metadata MDString MDString Metadata unsigned Line
Metadata MDString MDString Metadata unsigned Metadata * Type
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t Metadata * Annotations
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata * StaticDataMemberDeclaration
Metadata MDString MDString * LinkageName
Metadata MDString MDString Metadata * File
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t AlignInBits
An imported module (C++ using directive or similar).
unsigned Metadata Metadata * Entity
unsigned Metadata Metadata Metadata unsigned Line
unsigned Metadata Metadata Metadata unsigned MDString * Name
unsigned Metadata Metadata Metadata * File
unsigned Metadata * Scope
Metadata MDString Metadata unsigned unsigned bool std::optional< unsigned > CoroSuspendIdx
Metadata MDString Metadata unsigned unsigned Column
Metadata MDString Metadata unsigned unsigned bool IsArtificial
Metadata MDString Metadata unsigned Line
Metadata MDString Metadata * File
LLVM_ABI DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops)
Definition DebugInfoMetadata.cpp:1460
Metadata Metadata unsigned Discriminator
Metadata Metadata unsigned unsigned Column
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition DebugInfoMetadata.cpp:1327
LLVM_ABI DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
Definition DebugInfoMetadata.cpp:1333
DILocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops)
static LLVM_ABI DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Traverses the scope chain rooted at RootScope until it hits a Subprogram, recreating the chain with "...
Definition DebugInfoMetadata.cpp:1339
Metadata MDString Metadata unsigned Metadata * Type
Metadata MDString Metadata * File
DILocalScope * getScope() const
Get the local scope for this variable.
Metadata MDString Metadata unsigned Line
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t Metadata * Annotations
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t AlignInBits
unsigned unsigned DILocalScope * Scope
static LLVM_ABI DILocation * getMergedLocations(ArrayRef< DILocation * > Locs)
Try to combine the vector of locations passed as input in a single one.
Definition DebugInfoMetadata.cpp:117
static LLVM_ABI std::optional< unsigned > encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI)
Raw encoding of the discriminator.
Definition DebugInfoMetadata.cpp:417
unsigned unsigned DILocalScope DILocation bool ImplicitCode
static LLVM_ABI void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, unsigned &CI)
Raw decoder for values in an encoded discriminator D.
Definition DebugInfoMetadata.cpp:450
static LLVM_ABI DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
Attempts to merge LocA and LocB into a single location; see DebugLoc::getMergedLocation for more deta...
Definition DebugInfoMetadata.cpp:223
unsigned unsigned DILocalScope DILocation * InlinedAt
unsigned unsigned Metadata * File
unsigned unsigned Metadata Metadata * Elements
unsigned unsigned MDString MDString * Value
unsigned unsigned MDString * Name
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Metadata Metadata * Scope
Metadata Metadata MDString * Name
Metadata Metadata MDString MDString MDString MDString * APINotesFile
Metadata Metadata MDString MDString MDString * IncludePath
Metadata Metadata MDString MDString * ConfigurationMacros
Metadata Metadata MDString MDString MDString MDString unsigned LineNo
Metadata MDString bool ExportSymbols
Tagged DWARF-like metadata node.
LLVM_ABI dwarf::Tag getTag() const
Definition DebugInfoMetadata.cpp:457
static LLVM_ABI DIFlags getFlag(StringRef Flag)
Definition DebugInfoMetadata.cpp:459
static LLVM_ABI DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
Definition DebugInfoMetadata.cpp:476
DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
static LLVM_ABI StringRef getFlagString(DIFlags Flag)
Definition DebugInfoMetadata.cpp:466
MDString Metadata unsigned MDString MDString unsigned Metadata * Type
MDString Metadata unsigned MDString * GetterName
MDString Metadata unsigned MDString MDString * SetterName
Base class for scope-like contexts.
LLVM_ABI StringRef getName() const
Definition DebugInfoMetadata.cpp:537
LLVM_ABI DIScope * getScope() const
Definition DebugInfoMetadata.cpp:513
DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops)
Wrapper structure that holds a language name and its version.
String type, Fortran CHARACTER(n)
unsigned MDString Metadata Metadata Metadata uint64_t SizeInBits
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t AlignInBits
unsigned MDString Metadata Metadata Metadata * StringLocationExp
unsigned MDString Metadata Metadata * StringLengthExp
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t unsigned Encoding
unsigned MDString Metadata * StringLength
Subprogram description. Uses SubclassData1.
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString bool UsesKeyInstructions
Metadata MDString MDString Metadata unsigned Metadata unsigned ScopeLine
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags SPFlags
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata * ContainingType
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata * TemplateParams
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata * Declaration
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString * TargetFuncName
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
Definition DebugInfoMetadata.cpp:1312
static const DIScope * getRawRetainedNodeScope(const MDNode *N)
Definition DebugInfoMetadata.cpp:1448
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata * ThrownTypes
static LLVM_ABI DISPFlags getFlag(StringRef Flag)
Definition DebugInfoMetadata.cpp:1366
Metadata MDString MDString Metadata * File
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned VirtualIndex
static LLVM_ABI DISPFlags splitFlags(DISPFlags Flags, SmallVectorImpl< DISPFlags > &SplitFlags)
Split up a flags bitfield for easier printing.
Definition DebugInfoMetadata.cpp:1387
static LLVM_ABI StringRef getFlagString(DISPFlags Flag)
Definition DebugInfoMetadata.cpp:1373
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata * RetainedNodes
DISPFlags
Debug info subprogram flags.
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int ThisAdjustment
LLVM_ABI bool describes(const Function *F) const
Check if this subprogram describes the given function.
Definition DebugInfoMetadata.cpp:1443
StringRef DIFile unsigned Line
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata * UpperBound
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata Metadata Metadata * Bias
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata Metadata * Stride
StringRef DIFile unsigned DIScope uint64_t SizeInBits
PointerUnion< ConstantInt *, DIVariable *, DIExpression *, DIDerivedType * > BoundType
StringRef DIFile unsigned DIScope uint64_t uint32_t AlignInBits
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata * LowerBound
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags Flags
LLVM_ABI BoundType getUpperBound() const
Definition DebugInfoMetadata.cpp:692
LLVM_ABI BoundType getStride() const
Definition DebugInfoMetadata.cpp:713
LLVM_ABI BoundType getLowerBound() const
Definition DebugInfoMetadata.cpp:671
LLVM_ABI BoundType getCount() const
Definition DebugInfoMetadata.cpp:650
Type array for a subprogram.
DIFlags uint8_t Metadata * TypeArray
Base class for template parameters.
unsigned MDString Metadata * Type
unsigned MDString Metadata bool Metadata * Value
bool isStaticMember() const
DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants, DIFlags Flags, ArrayRef< Metadata * > Ops)
LLVM_ABI uint32_t getAlignInBits() const
Definition DebugInfoMetadata.cpp:45
Base class for variables.
std::optional< DIBasicType::Signedness > getSignedness() const
Return the signedness of this variable's type, or std::nullopt if this type is neither signed nor uns...
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
Definition DebugInfoMetadata.cpp:1618
Metadata * getRawType() const
LLVM_ABI DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, signed Line, ArrayRef< Metadata * > Ops, uint32_t AlignInBits=0)
Definition DebugInfoMetadata.cpp:1612
A parsed version of the target data layout string in and methods for querying it.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI DebugVariableAggregate(const DbgVariableRecord *DVR)
Definition DebugInfoMetadata.cpp:57
const DILocation * getInlinedAt() const
const DILocalVariable * getVariable() const
LLVM_ABI DebugVariable(const DbgVariableRecord *DVR)
Definition DebugInfoMetadata.cpp:52
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Class representing an expression and its matching format.
Generic tagged DWARF-like metadata node.
LLVM_ABI dwarf::Tag getTag() const
Definition DebugInfoMetadata.cpp:560
unsigned MDString * Header
unsigned MDString ArrayRef< Metadata * > DwarfOps
DenseSet< DIArgList *, DIArgListInfo > DIArgLists
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
LLVM_ABI TempMDNode clone() const
Create a (temporary) clone of this.
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
LLVMContext & getContext() const
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
LLVM_ABI StringRef getString() const
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Implements a dense probed hash-table based set with some number of buckets stored inline.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
LLVM Value Representation.
LLVM_ABI std::optional< int64_t > getPointerOffsetFrom(const Value *Other, const DataLayout &DL) const
If this ptr is provably equal to Other plus a constant offset, return that offset in bytes.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
#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.
initializer< Ty > init(const Ty &Val)
Calculates the starting offsets for various sections within the .debug_names section.
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
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.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
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.
auto reverse(ContainerTy &&C)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
FunctionAddr VTableAddr Count
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_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Ref
The access may reference the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
LLVM_ABI cl::opt< bool > PickMergedSourceLocations("pick-merged-source-locations", cl::init(false), cl::Hidden, cl::desc("Preserve line and column number when merging locations."))
Implement std::hash so that hash_code can be used in STL containers.
SmallPtrSet< DIScope *, 8 > Scopes
Definition DebugInfoMetadata.cpp:187
void insert(DIScope *S, LineColumn Loc)
Definition DebugInfoMetadata.cpp:189
DIScope * match(DIScope *S, LineColumn Loc)
Definition DebugInfoMetadata.cpp:191
void insert(DIScope *S, LineColumn Loc)
Definition DebugInfoMetadata.cpp:202
DIScope * match(DIScope *S, LineColumn Loc)
Definition DebugInfoMetadata.cpp:206
SmallMapVector< std::pair< DIFile *, LineColumn >, SmallSetVector< DIScope *, 8 >, 8 > Scopes
Definition DebugInfoMetadata.cpp:200
A single checksum, represented by a Kind and a Value (a string).
static DbgVariableFragmentInfo intersect(DbgVariableFragmentInfo A, DbgVariableFragmentInfo B)
Returns a zero-sized fragment if A and B don't intersect.
A MapVector that performs no allocations if smaller than a certain size.