36 cl::desc(
"Enable adding flow sensitive discriminators"));
42 cl::desc(
"Preserve line and column number when merging locations."));
50 std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
54 Fragment(DVR->getExpression()->getFragmentInfo()),
61DILocation::DILocation(
LLVMContext &
C, StorageType Storage,
unsigned Line,
64 :
MDNode(
C, DILocationKind, Storage, MDs), AtomGroup(AtomGroup),
66 assert(AtomRank <= 7 &&
"AtomRank number should fit in 3 bits");
68 C.updateDILocationAtomGroupWaterline(AtomGroup + 1);
71 "Expected a scope and optional inlined-at");
73 assert(Column < (1u << 16) &&
"Expected 16-bit column");
75 SubclassData32 = Line;
76 SubclassData16 = Column;
78 setImplicitCode(ImplicitCode);
83 if (Column >= (1u << 16))
89 Metadata *InlinedAt,
bool ImplicitCode,
90 uint64_t AtomGroup, uint8_t AtomRank,
91 StorageType Storage,
bool ShouldCreate) {
96 if (
auto *
N =
getUniqued(Context.pImpl->DILocations,
99 AtomGroup, AtomRank)))
104 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
114 Storage, Context.pImpl->DILocations);
120 if (Locs.
size() == 1)
122 auto *Merged = Locs[0];
125 if (Merged ==
nullptr)
133 TempMDNode ClonedScope = LBB->
clone();
148 return {LB->getLine(), LB->getColumn()};
150 return {SP->getLine(), 0u};
156template <
typename MatcherT>
157static std::pair<DIScope *, LineColumn>
164 LineColumn Loc1(L1->getLine(), L1->getColumn());
165 for (;
S1;
S1 =
S1->getScope()) {
167 Matcher.insert(
S1, Loc1);
172 LineColumn Loc2(L2->getLine(), L2->getColumn());
176 if (
DIScope *S = Matcher.match(S2, Loc2))
177 return std::make_pair(S, Loc2);
182 return std::make_pair(
nullptr,
LineColumn(L2->getLine(), L2->getColumn()));
192 return Scopes.contains(S) ? S :
nullptr;
209 if (ScopesAtLoc ==
Scopes.end())
213 if (ScopesAtLoc->second.contains(S))
216 if (!ScopesAtLoc->second.empty())
217 return *ScopesAtLoc->second.begin();
234 return LocA ? LocA : LocB;
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;
260 for (
auto [L,
I] = std::make_pair(LocA, 0U); L; L = L->getInlinedAt(),
I++) {
263 {L->getScope()->getSubprogram(), L->getInlinedAt()},
I);
264 assert(Res.second &&
"Multiple <SP, InlinedAt> pairs in a location chain?");
268 LocVec::reverse_iterator ARIt = ALocs.rend();
269 LocVec::reverse_iterator BRIt = BLocs.rend();
275 for (
auto [L,
I] = std::make_pair(LocB, 0U); L; L = L->getInlinedAt(),
I++) {
278 if (ARIt != ALocs.rend())
282 auto IT = ALookup.
find({L->getScope()->getSubprogram(), L->getInlinedAt()});
283 if (
IT == ALookup.
end())
287 ARIt = LocVec::reverse_iterator(ALocs.begin() +
IT->second + 1);
288 BRIt = LocVec::reverse_iterator(BLocs.begin() +
I + 1);
299 auto *LocAIA = LocA->getInlinedAt();
300 auto *LocBIA = LocB->getInlinedAt();
301 auto MergeLocPair = [&
C, LocAIA,
302 LocBIA](
const DILocation *L1,
const DILocation *L2,
307 L1->getAtomGroup(), L1->getAtomRank());
311 if (L1->getScope()->getSubprogram() != L2->getScope()->getSubprogram())
316 assert(
Scope &&
"No common scope in the same subprogram?");
319 if (
Scope->getFile() != L1->getFile() || L1->getFile() != L2->getFile()) {
320 auto [CommonLocScope, CommonLoc] =
330 Scope = CommonLocScope;
334 if (
Scope->getFile() != L1->getFile() || L1->getFile() != L2->getFile())
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();
347 if (!SameLine || !(L1->getAtomGroup() || L2->getAtomGroup()))
355 if (LocBIA == LocAIA &&
InlinedAt == LocBIA) {
360 bool UseL1Atom = [L1, L2]() {
361 if (L1->getAtomRank() == L2->getAtomRank()) {
363 if (!L1->getAtomGroup() || !L2->getAtomGroup())
364 return !L2->getAtomGroup();
365 return L1->getAtomGroup() < L2->getAtomGroup();
368 if (!L1->getAtomRank() || !L2->getAtomRank())
369 return !L2->getAtomRank();
370 return L1->getAtomRank() < L2->getAtomRank();
372 Group = UseL1Atom ? L1->getAtomGroup() : L2->getAtomGroup();
373 Rank = UseL1Atom ? L1->getAtomRank() : L2->getAtomRank();
379 Group =
C.incNextDILocationAtomGroup();
386 DILocation *Result = ARIt != ALocs.rend() ? (*ARIt)->getInlinedAt() :
nullptr;
390 for (; ARIt != ALocs.rend() && BRIt != BLocs.rend(); ++ARIt, ++BRIt) {
391 DILocation *Tmp = MergeLocPair(*ARIt, *BRIt, Result);
416std::optional<unsigned>
418 std::array<unsigned, 3> Components = {BD,
DF, CI};
426 std::accumulate(Components.begin(), Components.end(), RemainingWork);
430 unsigned NextBitInsertionIndex = 0;
431 while (RemainingWork > 0) {
432 unsigned C = Components[
I++];
435 Ret |= (EC << NextBitInsertionIndex);
443 unsigned TBD, TDF, TCI = 0;
445 if (TBD == BD && TDF ==
DF && TCI == CI)
461#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
462#include "llvm/IR/DebugInfoFlags.def"
468#define HANDLE_DI_FLAG(ID, NAME) \
470 return "DIFlag" #NAME;
471#include "llvm/IR/DebugInfoFlags.def"
482 if (
A == FlagPrivate)
484 else if (
A == FlagProtected)
491 if (R == FlagSingleInheritance)
492 SplitFlags.
push_back(FlagSingleInheritance);
493 else if (R == FlagMultipleInheritance)
494 SplitFlags.
push_back(FlagMultipleInheritance);
496 SplitFlags.
push_back(FlagVirtualInheritance);
499 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
500 Flags &= ~FlagIndirectVirtualBase;
501 SplitFlags.
push_back(FlagIndirectVirtualBase);
504#define HANDLE_DI_FLAG(ID, NAME) \
505 if (DIFlags Bit = Flags & Flag##NAME) { \
506 SplitFlags.push_back(Bit); \
509#include "llvm/IR/DebugInfoFlags.def"
515 return T->getScope();
518 return SP->getScope();
521 return LB->getScope();
524 return NS->getScope();
527 return CB->getScope();
530 return M->getScope();
533 "Unhandled type of scope.");
541 return SP->getName();
543 return NS->getName();
545 return CB->getName();
550 "Unhandled type of scope.");
564 StorageType Storage,
bool ShouldCreate) {
572 Hash =
Key.getHash();
574 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
582 Storage, Context.pImpl->GenericDINodes);
585void GenericDINode::recalculateHash() {
586 setHash(GenericDINodeInfo::KeyTy::calculateHash(
this));
589#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
590#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
591#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
593 if (Storage == Uniqued) { \
594 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
595 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
600 assert(ShouldCreate && \
601 "Expected non-uniqued nodes to always be created"); \
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)
620DISubrange::DISubrange(
LLVMContext &
C, StorageType Storage,
622 :
DINode(
C, DISubrangeKind, Storage,
dwarf::DW_TAG_subrange_type,
Ops) {}
624 StorageType Storage,
bool ShouldCreate) {
634 int64_t
Lo, StorageType Storage,
644 StorageType Storage,
bool ShouldCreate) {
657 "Count must be signed constant or DIVariable or DIExpression");
663 return BoundType(MD);
666 return BoundType(MD);
678 "LowerBound must be signed constant or DIVariable or DIExpression");
684 return BoundType(MD);
687 return BoundType(MD);
699 "UpperBound must be signed constant or DIVariable or DIExpression");
705 return BoundType(MD);
708 return BoundType(MD);
720 "Stride must be signed constant or DIVariable or DIExpression");
726 return BoundType(MD);
729 return BoundType(MD);
733DIGenericSubrange::DIGenericSubrange(
LLVMContext &
C, StorageType Storage,
735 :
DINode(
C, DIGenericSubrangeKind, Storage,
dwarf::DW_TAG_generic_subrange,
754 "Count must be signed constant or DIVariable or DIExpression");
771 "LowerBound must be signed constant or DIVariable or DIExpression");
788 "UpperBound must be signed constant or DIVariable or DIExpression");
805 "Stride must be signed constant or DIVariable or DIExpression");
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) {}
837DISubrangeType::convertRawToBound(
Metadata *IN)
const {
856DIEnumerator::DIEnumerator(
LLVMContext &
C, StorageType Storage,
865 StorageType Storage,
bool ShouldCreate) {
891 case dwarf::DW_ATE_signed:
892 case dwarf::DW_ATE_signed_char:
893 case dwarf::DW_ATE_signed_fixed:
895 case dwarf::DW_ATE_unsigned:
896 case dwarf::DW_ATE_unsigned_char:
897 case dwarf::DW_ATE_unsigned_fixed:
907 unsigned Encoding, DIFlags Flags,
unsigned Kind,
908 int Factor,
APInt Numerator,
APInt Denominator,
909 StorageType Storage,
bool ShouldCreate) {
921 return getEncoding() == dwarf::DW_ATE_signed_fixed;
924std::optional<DIFixedPointType::FixedPointKind>
950 unsigned Encoding, StorageType Storage,
969 return static_cast<uint32_t>(CI->getZExtValue());
975 return C->getValue();
981 getTag() == dwarf::DW_TAG_variable) &&
984 return C->getValue();
990 return C->getValue();
998 std::optional<unsigned> DWARFAddressSpace,
999 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
Metadata *ExtraData,
1013std::optional<DIDerivedType::PtrAuthData>
1014DIDerivedType::getPtrAuthData()
const {
1015 return getTag() == dwarf::DW_TAG_LLVM_ptrauth_type
1023 uint32_t AlignInBits,
Metadata *OffsetInBits, DIFlags Flags,
1024 Metadata *Elements,
unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1028 Metadata *Specification, uint32_t NumExtraInhabitants,
Metadata *BitStride,
1029 StorageType Storage,
bool ShouldCreate) {
1055 Metadata *
Elements,
unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1060 if (!Context.isODRUniquingDebugTypes())
1062 auto *&CT = (*Context.pImpl->DITypeMap)[&
Identifier];
1070 if (CT->getTag() !=
Tag)
1075 if (!CT->isForwardDecl() || (
Flags & DINode::FlagFwdDecl))
1086 assert((std::end(
Ops) - std::begin(
Ops)) == (
int)CT->getNumOperands() &&
1087 "Mismatched number of operands");
1088 for (
unsigned I = 0, E = CT->getNumOperands();
I != E; ++
I)
1089 if (
Ops[
I] != CT->getOperand(
I))
1090 CT->setOperand(
I,
Ops[
I]);
1099 Metadata *Elements,
unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1103 assert(!Identifier.getString().empty() &&
"Expected valid identifier");
1104 if (!Context.isODRUniquingDebugTypes())
1106 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
1115 if (CT->getTag() != Tag)
1124 if (!Context.isODRUniquingDebugTypes())
1126 return Context.pImpl->DITypeMap->lookup(&
Identifier);
1128DISubroutineType::DISubroutineType(
LLVMContext &
C, StorageType Storage,
1131 :
DIType(
C, DISubroutineTypeKind, Storage,
dwarf::DW_TAG_subroutine_type, 0,
1137 StorageType Storage,
1138 bool ShouldCreate) {
1145 std::optional<ChecksumInfo<MDString *>> CS,
MDString *Src,
1148 Checksum(CS),
Source(Src) {}
1158StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
1166std::optional<DIFile::ChecksumKind>
1178 MDString *Source, StorageType Storage,
1179 bool ShouldCreate) {
1189DICompileUnit::DICompileUnit(
LLVMContext &
C, StorageType Storage,
1191 bool IsOptimized,
unsigned RuntimeVersion,
1192 unsigned EmissionKind, uint64_t DWOId,
1193 bool SplitDebugInlining,
1194 bool DebugInfoForProfiling,
unsigned NameTableKind,
1199 IsOptimized(IsOptimized), SplitDebugInlining(SplitDebugInlining),
1200 DebugInfoForProfiling(DebugInfoForProfiling),
1201 RangesBaseAddress(RangesBaseAddress) {
1208 unsigned RuntimeVersion,
MDString *SplitDebugFilename,
1211 uint64_t DWOId,
bool SplitDebugInlining,
bool DebugInfoForProfiling,
1212 unsigned NameTableKind,
bool RangesBaseAddress,
MDString *SysRoot,
1213 MDString *SDK, StorageType Storage,
bool ShouldCreate) {
1231 Context,
Storage, SourceLanguage, IsOptimized,
1232 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
1233 DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
1238std::optional<DICompileUnit::DebugEmissionKind>
1248std::optional<DICompileUnit::DebugNameTableKind>
1265 return "LineTablesOnly";
1267 return "DebugDirectivesOnly";
1285DISubprogram::DISubprogram(
LLVMContext &
C, StorageType Storage,
unsigned Line,
1286 unsigned ScopeLine,
unsigned VirtualIndex,
1287 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
1290 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1291 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
1297 unsigned Virtuality,
bool IsMainSubprogram) {
1299 static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
1300 int(SPFlagPureVirtual) ==
1301 int(dwarf::DW_VIRTUALITY_pure_virtual),
1302 "Virtuality constant mismatch");
1305 (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) |
1306 (IsDefinition ? SPFlagDefinition : SPFlagZero) |
1307 (IsOptimized ? SPFlagOptimized : SPFlagZero) |
1308 (IsMainSubprogram ? SPFlagMainSubprogram : SPFlagZero));
1313 return Block->getScope()->getSubprogram();
1319 return File->getScope()->getNonLexicalBlockFileScope();
1327 DIScope *CachedResult =
nullptr;
1330 Scope = Scope->getScope()) {
1331 if (
auto It = Cache.find(Scope); It != Cache.end()) {
1340 DIScope *UpdatedScope = CachedResult ? CachedResult : &NewSP;
1344 Cache[ScopeToUpdate] = UpdatedScope;
1352#define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
1353#include "llvm/IR/DebugInfoFlags.def"
1362#define HANDLE_DISP_FLAG(ID, NAME) \
1363 case SPFlag##NAME: \
1364 return "DISPFlag" #NAME;
1365#include "llvm/IR/DebugInfoFlags.def"
1376#define HANDLE_DISP_FLAG(ID, NAME) \
1377 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
1378 SplitFlags.push_back(Bit); \
1381#include "llvm/IR/DebugInfoFlags.def"
1388 unsigned ScopeLine,
Metadata *ContainingType,
unsigned VirtualIndex,
1389 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
Metadata *Unit,
1392 bool UsesKeyInstructions, StorageType Storage,
bool ShouldCreate) {
1422 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags,
1427bool DISubprogram::describes(
const Function *
F)
const {
1428 assert(
F &&
"Invalid function");
1429 return F->getSubprogram() ==
this;
1438 unsigned Column, StorageType Storage,
1439 bool ShouldCreate) {
1443 assert(Scope &&
"Expected scope");
1451 unsigned Discriminator,
1452 StorageType Storage,
1453 bool ShouldCreate) {
1466 MDString *Name,
bool ExportSymbols,
1467 StorageType Storage,
bool ShouldCreate) {
1484 StorageType Storage,
bool ShouldCreate) {
1502 unsigned LineNo,
bool IsDecl, StorageType Storage,
1503 bool ShouldCreate) {
1512 StorageType Storage,
1516 dwarf::DW_TAG_template_type_parameter, IsDefault,
1522 StorageType Storage,
bool ShouldCreate) {
1531 bool isDefault,
Metadata *
Value, StorageType Storage,
bool ShouldCreate) {
1543 Metadata *StaticDataMemberDeclaration,
1544 Metadata *TemplateParams, uint32_t AlignInBits,
1546 bool ShouldCreate) {
1569 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
1571 bool ShouldCreate) {
1573 assert(Arg <= UINT16_MAX &&
"Expected argument number to fit in 16-bits");
1600 RawType = DT->getRawBaseType();
1609 return std::nullopt;
1612DILabel::DILabel(
LLVMContext &
C, StorageType Storage,
unsigned Line,
1613 unsigned Column,
bool IsArtificial,
1614 std::optional<unsigned> CoroSuspendIdx,
1618 this->Column = Column;
1619 this->IsArtificial = IsArtificial;
1620 this->CoroSuspendIdx = CoroSuspendIdx;
1623 Metadata *File,
unsigned Line,
unsigned Column,
1625 std::optional<unsigned> CoroSuspendIdx,
1626 StorageType Storage,
bool ShouldCreate) {
1627 assert(Scope &&
"Expected scope");
1638 StorageType Storage,
bool ShouldCreate) {
1644 return singleLocElts->size() > 0 &&
1651 return singleLocElts->size() > 0 &&
1652 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1657 return singleLocElts->size() == 1 &&
1658 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1663 bool ShouldCreate) {
1672 if (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31)
1680 case dwarf::DW_OP_bregx:
1682 case dwarf::DW_OP_constu:
1683 case dwarf::DW_OP_consts:
1684 case dwarf::DW_OP_deref_size:
1685 case dwarf::DW_OP_plus_uconst:
1689 case dwarf::DW_OP_regx:
1699 if (
I->get() +
I->getSize() > E->get())
1703 if ((
Op >= dwarf::DW_OP_reg0 &&
Op <= dwarf::DW_OP_reg31) ||
1704 (
Op >= dwarf::DW_OP_breg0 &&
Op <= dwarf::DW_OP_breg31))
1713 return I->get() +
I->getSize() == E->get();
1714 case dwarf::DW_OP_stack_value: {
1716 if (
I->get() +
I->getSize() == E->get())
1723 case dwarf::DW_OP_swap: {
1744 return I->get() == FirstOp->get() &&
I->getArg(0) == 1;
1752 case dwarf::DW_OP_constu:
1753 case dwarf::DW_OP_plus_uconst:
1754 case dwarf::DW_OP_plus:
1755 case dwarf::DW_OP_minus:
1756 case dwarf::DW_OP_mul:
1757 case dwarf::DW_OP_div:
1758 case dwarf::DW_OP_mod:
1759 case dwarf::DW_OP_or:
1760 case dwarf::DW_OP_and:
1761 case dwarf::DW_OP_xor:
1762 case dwarf::DW_OP_shl:
1763 case dwarf::DW_OP_shr:
1764 case dwarf::DW_OP_shra:
1765 case dwarf::DW_OP_deref:
1766 case dwarf::DW_OP_deref_size:
1767 case dwarf::DW_OP_xderef:
1768 case dwarf::DW_OP_lit0:
1769 case dwarf::DW_OP_not:
1770 case dwarf::DW_OP_dup:
1771 case dwarf::DW_OP_regx:
1772 case dwarf::DW_OP_bregx:
1773 case dwarf::DW_OP_push_object_address:
1774 case dwarf::DW_OP_over:
1775 case dwarf::DW_OP_rot:
1776 case dwarf::DW_OP_consts:
1777 case dwarf::DW_OP_eq:
1778 case dwarf::DW_OP_ne:
1779 case dwarf::DW_OP_gt:
1780 case dwarf::DW_OP_ge:
1781 case dwarf::DW_OP_lt:
1782 case dwarf::DW_OP_le:
1783 case dwarf::DW_OP_neg:
1784 case dwarf::DW_OP_abs:
1798 for (
const auto &It :
expr_ops()) {
1799 switch (It.getOp()) {
1802 case dwarf::DW_OP_stack_value:
1819 for (
const auto &It :
expr_ops()) {
1820 switch (It.getOp()) {
1840 auto ExprOpBegin =
expr_ops().begin();
1843 if (ExprOpBegin->getArg(0) != 0)
1848 return !std::any_of(ExprOpBegin, ExprOpEnd, [](
auto Op) {
1853std::optional<ArrayRef<uint64_t>>
1857 return std::nullopt;
1883 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1893std::optional<const DIExpression *>
1896 return std::nullopt;
1901 return std::nullopt;
1905 const DIExpression *Expr,
1910 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1923 if (
Op.getOp() == dwarf::DW_OP_stack_value ||
1925 Ops.push_back(dwarf::DW_OP_deref);
1928 Op.appendToVector(
Ops);
1931 Ops.push_back(dwarf::DW_OP_deref);
1936 const DIExpression *SecondExpr,
1937 bool SecondIndirect) {
1943 return FirstOps == SecondOps;
1946std::optional<DIExpression::FragmentInfo>
1948 for (
auto I = Start;
I != End; ++
I)
1953 return std::nullopt;
1957 std::optional<uint64_t> InitialActiveBits = Var->
getSizeInBits();
1958 std::optional<uint64_t> ActiveBits = InitialActiveBits;
1960 switch (
Op.getOp()) {
1964 ActiveBits = InitialActiveBits;
1970 std::optional<DIBasicType::Signedness> VarSign = Var->
getSignedness();
1973 if (!VarSign || VarSigned != OpSigned) {
1974 ActiveBits = InitialActiveBits;
1982 ActiveBits = std::min(*ActiveBits,
Op.getArg(1));
1984 ActiveBits =
Op.getArg(1);
1994 Ops.push_back(dwarf::DW_OP_plus_uconst);
1997 Ops.push_back(dwarf::DW_OP_constu);
2001 Ops.push_back(AbsMinusOne + 1);
2002 Ops.push_back(dwarf::DW_OP_minus);
2008 if (!SingleLocEltsOpt)
2010 auto SingleLocElts = *SingleLocEltsOpt;
2012 if (SingleLocElts.size() == 0) {
2017 if (SingleLocElts.size() == 2 &&
2018 SingleLocElts[0] == dwarf::DW_OP_plus_uconst) {
2019 Offset = SingleLocElts[1];
2023 if (SingleLocElts.size() == 3 && SingleLocElts[0] == dwarf::DW_OP_constu) {
2024 if (SingleLocElts[2] == dwarf::DW_OP_plus) {
2025 Offset = SingleLocElts[1];
2028 if (SingleLocElts[2] == dwarf::DW_OP_minus) {
2029 Offset = -SingleLocElts[1];
2040 RemainingOps.
clear();
2043 if (!SingleLocEltsOpt)
2048 while (ExprOpIt != ExprOpEnd) {
2050 if (
Op == dwarf::DW_OP_deref ||
Op == dwarf::DW_OP_deref_size ||
2055 }
else if (
Op == dwarf::DW_OP_plus_uconst) {
2056 OffsetInBytes += ExprOpIt->getArg(0);
2057 }
else if (
Op == dwarf::DW_OP_constu) {
2060 if (ExprOpIt->getOp() == dwarf::DW_OP_plus)
2061 OffsetInBytes +=
Value;
2062 else if (ExprOpIt->getOp() == dwarf::DW_OP_minus)
2063 OffsetInBytes -=
Value;
2072 RemainingOps.
append(ExprOpIt.getBase(), ExprOpEnd.getBase());
2080 SeenOps.
insert(ExprOp.getArg(0));
2088 unsigned &AddrClass) {
2092 if (!SingleLocEltsOpt)
2094 auto SingleLocElts = *SingleLocEltsOpt;
2096 const unsigned PatternSize = 4;
2097 if (SingleLocElts.size() >= PatternSize &&
2098 SingleLocElts[PatternSize - 4] == dwarf::DW_OP_constu &&
2099 SingleLocElts[PatternSize - 2] == dwarf::DW_OP_swap &&
2100 SingleLocElts[PatternSize - 1] == dwarf::DW_OP_xderef) {
2101 AddrClass = SingleLocElts[PatternSize - 3];
2103 if (SingleLocElts.size() == PatternSize)
2107 ArrayRef(&*SingleLocElts.begin(), SingleLocElts.size() - PatternSize));
2116 Ops.push_back(dwarf::DW_OP_deref);
2120 Ops.push_back(dwarf::DW_OP_deref);
2131 assert(Expr &&
"Can't add ops to this expression");
2135 [](
auto Op) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) {
2137 "Location Index must be 0 for a non-variadic expression.");
2146 if (
Op.getOp() == dwarf::DW_OP_stack_value)
2149 NewOps.
push_back(dwarf::DW_OP_stack_value);
2153 Op.appendToVector(NewOps);
2158 NewOps.
push_back(dwarf::DW_OP_stack_value);
2165 assert(Expr &&
"Can't replace args in this expression");
2171 Op.appendToVector(NewOps);
2175 uint64_t Arg =
Op.getArg(0) == OldArg ? NewArg :
Op.getArg(0);
2188 assert(Expr &&
"Can't prepend ops to this expression");
2204 if (
Op.getOp() == dwarf::DW_OP_stack_value)
2207 Ops.push_back(dwarf::DW_OP_stack_value);
2211 Op.appendToVector(
Ops);
2214 Ops.push_back(dwarf::DW_OP_stack_value);
2220 assert(Expr && !
Ops.empty() &&
"Can't append ops to this expression");
2226 if (
Op.getOp() == dwarf::DW_OP_stack_value ||
2233 Op.appendToVector(NewOps);
2238 assert(result->isValid() &&
"concatenated expression is not valid");
2244 assert(Expr && !
Ops.empty() &&
"Can't append ops to this expression");
2248 return Op.getOp() == dwarf::DW_OP_stack_value ||
2249 Op.getOp() == dwarf::DW_OP_LLVM_fragment;
2251 "Can't append this op");
2258 unsigned DropUntilStackValue = FI ? 3 : 0;
2261 bool NeedsDeref = (Expr->
getNumElements() > DropUntilStackValue) &&
2262 (ExprOpsBeforeFragment.
back() != dwarf::DW_OP_stack_value);
2263 bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.
empty();
2271 if (NeedsStackValue)
2272 NewOps.
push_back(dwarf::DW_OP_stack_value);
2277 const DIExpression *Expr,
unsigned OffsetInBits,
unsigned SizeInBits) {
2281 bool CanSplitValue =
true;
2283 bool EmitFragment =
true;
2287 switch (
Op.getOp()) {
2290 case dwarf::DW_OP_shr:
2291 case dwarf::DW_OP_shra:
2292 case dwarf::DW_OP_shl:
2293 case dwarf::DW_OP_plus:
2294 case dwarf::DW_OP_plus_uconst:
2295 case dwarf::DW_OP_minus:
2301 CanSplitValue =
false;
2303 case dwarf::DW_OP_deref:
2304 case dwarf::DW_OP_deref_size:
2305 case dwarf::DW_OP_deref_type:
2306 case dwarf::DW_OP_xderef:
2307 case dwarf::DW_OP_xderef_size:
2308 case dwarf::DW_OP_xderef_type:
2311 CanSplitValue =
true;
2313 case dwarf::DW_OP_stack_value:
2316 return std::nullopt;
2323 return std::nullopt;
2325 uint64_t FragmentOffsetInBits =
Op.getArg(0);
2327 (void)FragmentSizeInBits;
2328 assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
2329 "new fragment outside of original fragment");
2330 OffsetInBits += FragmentOffsetInBits;
2340 if (ExtractOffsetInBits >= OffsetInBits &&
2341 ExtractOffsetInBits + ExtractSizeInBits <=
2342 OffsetInBits + SizeInBits) {
2343 Ops.push_back(
Op.getOp());
2344 Ops.push_back(ExtractOffsetInBits - OffsetInBits);
2345 Ops.push_back(ExtractSizeInBits);
2346 EmitFragment =
false;
2352 return std::nullopt;
2355 Op.appendToVector(
Ops);
2359 assert(Expr &&
"Unknown DIExpression");
2362 Ops.push_back(OffsetInBits);
2363 Ops.push_back(SizeInBits);
2371 uint64_t SliceSizeInBits,
const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
2373 std::optional<DIExpression::FragmentInfo> &Result,
2374 int64_t &OffsetFromLocationInBits) {
2386 int64_t MemStartRelToDbgStartInBits;
2389 if (!MemOffsetFromDbgInBytes)
2392 MemStartRelToDbgStartInBits = *MemOffsetFromDbgInBytes * 8;
2394 MemStartRelToDbgStartInBits +=
2395 SliceOffsetInBits - (DbgPtrOffsetInBits + DbgExtractOffsetInBits);
2399 OffsetFromLocationInBits = -MemStartRelToDbgStartInBits;
2402 int64_t MemEndRelToDbgStart = MemStartRelToDbgStartInBits + SliceSizeInBits;
2403 if (MemEndRelToDbgStart < 0) {
2415 int64_t MemStartRelToVarInBits =
2417 int64_t MemEndRelToVarInBits = MemStartRelToVarInBits + SliceSizeInBits;
2422 int64_t MemFragStart = std::max<int64_t>(0, MemStartRelToVarInBits);
2423 int64_t MemFragSize =
2424 std::max<int64_t>(0, MemEndRelToVarInBits - MemFragStart);
2430 if (TrimmedSliceOfVariable == VarFrag)
2431 Result = std::nullopt;
2433 Result = TrimmedSliceOfVariable;
2437std::pair<DIExpression *, const ConstantInt *>
2447 switch (
Op.getOp()) {
2460 if (
Op.getArg(1) == dwarf::DW_ATE_signed)
2463 assert(
Op.getArg(1) == dwarf::DW_ATE_unsigned &&
"Unexpected operand");
2468 Op.appendToVector(
Ops);
2480 Result = std::max(Result, ExprOp.getArg(0) + 1);
2482 "Expression is missing one or more location operands.");
2486std::optional<DIExpression::SignedOrUnsignedConstant>
2499 return std::nullopt;
2507 return std::nullopt;
2522 unsigned FromSize,
unsigned ToSize,
2530 bool ShouldCreate) {
2538 : DINode(
C, DIObjCPropertyKind,
Storage, dwarf::DW_TAG_APPLE_property,
Ops),
2544 Metadata *
Type, StorageType Storage,
bool ShouldCreate) {
2558 StorageType Storage,
2559 bool ShouldCreate) {
2569 bool ShouldCreate) {
2578 Metadata *Elements, StorageType Storage,
2579 bool ShouldCreate) {
2587 auto ExistingIt = Context.pImpl->DIArgLists.find_as(
DIArgListKeyInfo(Args));
2588 if (ExistingIt != Context.pImpl->DIArgLists.end())
2590 DIArgList *NewArgList =
new DIArgList(Context, Args);
2591 Context.pImpl->DIArgLists.insert(NewArgList);
2598 "DIArgList must be passed a ValueAsMetadata");
2605 if (&VM == OldVMPtr) {
2617 if (ExistingArgList) {
2627void DIArgList::track() {
2632void DIArgList::untrack() {
2637void DIArgList::dropAllReferences(
bool Untrack) {
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 found DebugLoc that has a DILocation, 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)
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
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.
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)
static LLVM_ABI const char * emissionKindString(DebugEmissionKind EK)
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.
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)
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.
LLVM_ABI Constant * getConstant() const
unsigned StringRef DIFile unsigned DIScope DIType Metadata * SizeInBits
LLVM_ABI Constant * getStorageOffsetInBits() const
LLVM_ABI Constant * getDiscriminantValue() const
LLVM_ABI uint32_t getVBPtrOffset() const
int64_t bool MDString * Name
LLVM_ABI unsigned getSize() const
Return the size of the operand.
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.
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.
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.
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.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
DbgVariableFragmentInfo FragmentInfo
LLVM_ABI bool startsWithDeref() const
Return whether the first element a DW_OP_deref.
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...
expr_op_iterator expr_op_end() const
LLVM_ABI bool isImplicit() const
Return whether this is an implicit location description.
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...
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,...
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...
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
LLVM_ABI bool isDeref() const
Return whether there is exactly one operator and it is a DW_OP_deref;.
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
LLVM_ABI uint64_t getNumLocationOperands() const
Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; th...
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,...
LLVM_ABI std::optional< uint64_t > getActiveBits(DIVariable *Var)
Return the number of bits that have an active value, i.e.
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....
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...
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...
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 ...
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,...
static LLVM_ABI DIExpression * appendExt(const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
Append a zero- or sign-extension to Expr.
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...
LLVM_ABI bool isSingleLocationExpression() const
Return whether the evaluated expression makes use of a single location at the start of the expression...
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...
LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
LLVM_ABI bool isValid() const
static LLVM_ABI const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu <DWARFAddress Space> DW_OP_swap DW_O...
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.
MDString MDString * Directory
MDString MDString std::optional< ChecksumInfo< MDString * > > MDString * Source
static LLVM_ABI std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
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)
static LLVM_ABI const char * fixedPointKindString(FixedPointKind)
unsigned StringRef uint64_t uint32_t unsigned Encoding
unsigned StringRef uint64_t uint32_t AlignInBits
LLVM_ABI bool isSigned() const
@ 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
Metadata * getRawUpperBound() const
LLVM_ABI BoundType getCount() const
LLVM_ABI BoundType getUpperBound() const
PointerUnion< DIVariable *, DIExpression * > BoundType
LLVM_ABI BoundType getStride() const
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)
Metadata Metadata unsigned Discriminator
Metadata Metadata unsigned unsigned Column
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
LLVM_ABI DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
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 "...
Metadata MDString Metadata unsigned Metadata * Type
Metadata MDString Metadata * File
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.
static LLVM_ABI std::optional< unsigned > encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI)
Raw encoding of the discriminator.
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.
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...
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
static LLVM_ABI DIFlags getFlag(StringRef Flag)
static LLVM_ABI DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
static LLVM_ABI StringRef getFlagString(DIFlags Flag)
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
LLVM_ABI DIScope * getScope() const
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)
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)
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.
static LLVM_ABI StringRef getFlagString(DISPFlags Flag)
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
StringRef DIFile unsigned Line
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata * UpperBound
PointerUnion< ConstantInt *, DIVariable *, DIExpression * > BoundType
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
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
LLVM_ABI BoundType getStride() const
LLVM_ABI BoundType getLowerBound() const
LLVM_ABI BoundType getCount() const
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
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.
Metadata * getRawType() const
LLVM_ABI DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, signed Line, ArrayRef< Metadata * > Ops, uint32_t AlignInBits=0)
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)
const DILocation * getInlinedAt() const
const DILocalVariable * getVariable() const
LLVM_ABI DebugVariable(const DbgVariableRecord *DVR)
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
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<X> - Return the argument parameter cast to the specified type.
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)
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
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<X> - 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<X> - 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
void insert(DIScope *S, LineColumn Loc)
DIScope * match(DIScope *S, LineColumn Loc)
void insert(DIScope *S, LineColumn Loc)
DIScope * match(DIScope *S, LineColumn Loc)
SmallMapVector< std::pair< DIFile *, LineColumn >, SmallSetVector< DIScope *, 8 >, 8 > Scopes
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.