46 "add-linkage-names-to-declaration-call-origins",
cl::Hidden,
47 cl::desc(
"Add DW_AT_linkage_name to function declaration DIEs "
48 "referenced by DW_AT_call_origin attributes. Enabled by default "
49 "for -gsce debugger tuning."));
52 "emit-func-debug-line-table-offsets",
cl::Hidden,
53 cl::desc(
"Include line table offset in function's debug info and emit end "
54 "sequence after each function's line data."),
72 return dwarf::DW_TAG_skeleton_unit;
74 return dwarf::DW_TAG_compile_unit;
82 MacroLabelBegin =
Asm->createTempSymbol(
"cu_macro_begin");
84 for (
auto *GVE :
CUNode->getGlobalVariables())
85 if (
auto *GV = GVE->getVariable())
86 GlobalVarScopes.insert(GV->getScope());
93 if ((Skeleton || !
DD->useSplitDwarf()) && Label)
97 if ((!
DD->useSplitDwarf() || !Skeleton) &&
DD->getDwarfVersion() < 5)
100 bool UseAddrOffsetFormOrExpressions =
101 DD->useAddrOffsetForm() ||
DD->useAddrOffsetExpressions();
104 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
105 Base =
DD->getSectionLabel(&Label->getSection());
108 unsigned idx =
DD->getAddressPool().getIndex(Label);
110 DD->getDwarfVersion() >= 5 ? dwarf::DW_FORM_addrx
111 : dwarf::DW_FORM_GNU_addr_index,
118 assert(
DD->getDwarfVersion() >= 5 &&
119 "Addr+offset expressions are only valuable when using debug_addr (to "
120 "reduce relocations) available in DWARFv5 or higher");
121 if (
DD->useAddrOffsetExpressions()) {
128 DD->getAddressPool().getIndex(
Base), Label,
Base));
146 unsigned CUID =
Asm->OutStreamer->hasRawTextSupport() ? 0 :
getUniqueID();
148 return Asm->OutStreamer->emitDwarfFileDirective(0,
"",
"", std::nullopt,
151 if (LastFile != File) {
153 LastFileID =
Asm->OutStreamer->emitDwarfFileDirective(
154 0, File->getDirectory(), File->getFilename(),
DD->getMD5AsBytes(File),
155 File->getSource(), CUID);
180 assert(SDMDecl->isStaticMember() &&
"Expected static member decl");
184 addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
187 if (GTy != SDMDecl->getBaseType())
193 if (!DisplayName.
empty())
200 addFlag(*VariableDIE, dwarf::DW_AT_external);
207 addFlag(*VariableDIE, dwarf::DW_AT_declaration);
214 addUInt(*VariableDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
228 bool addToAccelTable =
false;
230 std::optional<unsigned> TargetAddrSpace;
231 std::unique_ptr<DIEDwarfExpression> DwarfExpr;
233 for (
const auto &GE : GlobalExprs) {
242 addToAccelTable =
true;
261 !
Asm->getObjFileLowering().supportDebugThreadLocalLocation())
265 addToAccelTable =
true;
267 DwarfExpr = std::make_unique<DIEDwarfExpression>(*
Asm, *
this, *
Loc);
271 Expr =
DD->adjustExpressionForTarget(Expr, TargetAddrSpace);
272 DwarfExpr->addFragmentOffset(Expr);
279 auto GetPointerSizedFormAndOp = [
this]() {
280 unsigned PointerSize =
Asm->MAI.getCodePointerSize();
281 assert((PointerSize == 4 || PointerSize == 8) &&
282 "Add support for other sizes if necessary");
287 return PointerSize == 4
288 ? FormAndOp{dwarf::DW_FORM_data4, dwarf::DW_OP_const4u}
289 : FormAndOp{dwarf::DW_FORM_data8, dwarf::DW_OP_const8u};
291 if (
Global->isThreadLocal()) {
292 if (
Asm->TM.getTargetTriple().isWasm()) {
298 addWasmRelocBaseGlobal(
Loc,
"__tls_base", 1);
300 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
301 }
else if (
Asm->TM.useEmulatedTLS()) {
306 if (!
DD->useSplitDwarf()) {
307 auto FormAndOp = GetPointerSizedFormAndOp();
309 addUInt(*
Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
313 Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym));
315 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
317 DD->getAddressPool().getIndex(Sym,
true));
321 DD->useGNUTLSOpcode() ? dwarf::DW_OP_GNU_push_tls_address
322 : dwarf::DW_OP_form_tls_address);
324 }
else if (
Asm->TM.getTargetTriple().isWasm() &&
329 addWasmRelocBaseGlobal(
Loc,
"__memory_base", 1);
331 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
334 !
Asm->getObjFileLowering()
337 auto FormAndOp = GetPointerSizedFormAndOp();
339 addUInt(*
Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
342 Asm->getObjFileLowering().getIndirectSymViaRWPI(Sym));
344 Register BaseReg =
Asm->getObjFileLowering().getStaticBase();
345 unsigned DwarfBaseReg =
346 Asm->TM.getMCRegisterInfo().getDwarfRegNum(BaseReg,
false);
347 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + DwarfBaseReg);
351 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
362 if (DwarfExpr->isUnknownLocation())
363 DwarfExpr->setMemoryLocationKind();
364 DwarfExpr->addExpression(Expr);
366 DD->addTargetVariableAttributes(*
this, *VariableDIE, TargetAddrSpace,
370 addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());
372 if (
DD->useAllLinkageNames())
375 if (addToAccelTable) {
382 DD->useAllLinkageNames())
396 addString(NDie, dwarf::DW_AT_name, Name);
406 DD->insertSectionLabel(
Range.Begin);
408 auto *PrevCU =
DD->getPrevCU();
409 bool SameAsPrevCU =
this == PrevCU;
415 if (CURanges.empty() || !SameAsPrevCU ||
416 (&CURanges.back().End->getSection() !=
417 &
Range.End->getSection())) {
420 DD->terminateLineTable(PrevCU);
421 CURanges.push_back(
Range);
425 CURanges.back().End =
Range.End;
429 if (
CUNode->isDebugDirectivesOnly())
433 if (
DD->useSectionsAsReferences()) {
457 assert(Begin &&
"Begin label should not be null!");
458 assert(End &&
"End label should not be null!");
463 if (
DD->getDwarfVersion() >= 4 &&
475 uint64_t GlobalIndex) {
478 const unsigned TI_GLOBAL_RELOC = 3;
490 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
491 addSInt(*
Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);
501 addUInt(*Loc, dwarf::DW_FORM_data4, GlobalIndex);
515 for (
const auto &R :
Asm->MBBSectionRanges)
516 BB_List.
push_back({R.second.BeginLabel, R.second.EndLabel});
520 if (
DD->useAppleExtensionAttributes() &&
521 !
DD->getCurrentFunction()->disableFramePointerElim())
522 addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
526 Asm->getObjFileLowering().getDwarfLineSection()->getBeginSymbol();
536 switch (FrameBase.
Kind) {
540 addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
546 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
548 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_consts);
550 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
557 const unsigned TI_GLOBAL_RELOC = 3;
563 addWasmRelocBaseGlobal(
Loc,
"__stack_pointer",
565 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
583 DD->addSubprogramNames(*
this,
CUNode->getNameTableKind(), SP, *SPDie);
590 DIE &ParentScopeDIE) {
591 if (!Scope || !Scope->getScopeNode())
594 auto *DS = Scope->getScopeNode();
597 "Only handle inlined subprograms here, use "
598 "constructSubprogramScopeDIE for non-inlined "
604 assert(ScopeDIE &&
"Scope DIE should not be null.");
610 if (
DD->isLexicalScopeDIENull(Scope))
615 assert(ScopeDIE &&
"Scope DIE should not be null.");
623 HasRangeLists =
true;
627 (
DD->getDwarfVersion() < 5 && Skeleton ? Skeleton->DU :
DU)
628 ->addRange(*(Skeleton ? Skeleton :
this), std::move(
Range));
630 uint32_t Index = IndexAndList.first;
631 auto &
List = *IndexAndList.second;
638 if (
DD->getDwarfVersion() >= 5)
639 addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_rnglistx, Index);
651 if (!
DD->useRangesSection() ||
652 (Ranges.size() == 1 &&
653 (!
DD->alwaysUseRanges(*
this) ||
654 DD->getSectionLabel(&Ranges.front().Begin->getSection()) ==
655 Ranges.front().Begin))) {
666 List.reserve(Ranges.size());
668 auto *BeginLabel =
DD->getLabelBeforeInsn(R.first);
669 auto *
EndLabel =
DD->getLabelAfterInsn(R.second);
671 const auto *BeginMBB = R.first->getParent();
672 const auto *EndMBB = R.second->getParent();
674 const auto *
MBB = BeginMBB;
682 if (
MBB->sameSection(EndMBB) ||
MBB->isEndSection()) {
683 auto MBBSectionRange =
Asm->MBBSectionRanges[
MBB->getSectionID()];
685 {
MBB->sameSection(BeginMBB) ? BeginLabel
686 : MBBSectionRange.BeginLabel,
687 MBB->sameSection(EndMBB) ?
EndLabel : MBBSectionRange.EndLabel});
689 if (
MBB->sameSection(EndMBB))
698 DIE &ParentScopeDIE) {
699 assert(Scope->getScopeNode());
700 auto *DS = Scope->getScopeNode();
704 DIE *OriginDIE = getAbstractScopeDIEs()[InlinedSP];
705 assert(OriginDIE &&
"Unable to find original DIE for an inlined subprogram.");
709 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
715 addUInt(*ScopeDIE, dwarf::DW_AT_call_file, std::nullopt,
717 addUInt(*ScopeDIE, dwarf::DW_AT_call_line, std::nullopt, IA->getLine());
719 addUInt(*ScopeDIE, dwarf::DW_AT_call_column, std::nullopt, IA->getColumn());
720 if (IA->getDiscriminator() &&
DD->getDwarfVersion() >= 4)
721 addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, std::nullopt,
722 IA->getDiscriminator());
726 DD->addSubprogramNames(*
this,
CUNode->getNameTableKind(), InlinedSP,
733 DIE &ParentScopeDIE) {
734 if (
DD->isLexicalScopeDIENull(Scope))
736 const auto *DS = Scope->getScopeNode();
741 if (Scope->isAbstractScope()) {
743 "Abstract DIE for this scope exists!");
744 getAbstractScopeDIEs()[DS] = ScopeDIE;
747 if (!Scope->getInlinedAt()) {
748 assert(!LexicalBlockDIEs.count(DS) &&
749 "Concrete out-of-line DIE for this scope exists!");
750 LexicalBlockDIEs[DS] = ScopeDIE;
752 InlinedLocalScopeDIEs[DS].push_back(ScopeDIE);
770 applyConcreteDbgVariableAttributes(V, DV, *VariableDie);
779 switch (DT->getTag()) {
780 case dwarf::DW_TAG_typedef:
781 case dwarf::DW_TAG_const_type:
782 case dwarf::DW_TAG_volatile_type:
783 case dwarf::DW_TAG_restrict_type:
784 case dwarf::DW_TAG_atomic_type:
785 Ty = DT->getBaseType();
797 const DIExpression *Expr =
Single.getExpr();
811 auto FirstOp = ExprOps.begin();
812 if (FirstOp == ExprOps.end() ||
816 if (
DD->getDwarfVersion() < 4)
819 const DbgValueLoc &DVal =
Single.getValueLoc();
824 "Non-variadic value must have one entry");
830 const DIDerivedType *PtrTy =
835 if (PtrTy->
getTag() != dwarf::DW_TAG_pointer_type &&
836 PtrTy->
getTag() != dwarf::DW_TAG_reference_type &&
837 PtrTy->
getTag() != dwarf::DW_TAG_rvalue_reference_type)
840 const DIType *PointeeTy = PtrTy->getBaseType();
846 DIE *ArtificialDIEPtr =
nullptr;
847 if (
Entry.isInt() && PointeeTy) {
848 auto It = ImplicitPointerDIEs.find({PointeeTy,
Entry.getInt()});
849 if (It != ImplicitPointerDIEs.end())
850 ArtificialDIEPtr = It->second;
853 if (!ArtificialDIEPtr) {
856 if (
Entry.isLocation()) {
858 }
else if (
Entry.isInt()) {
861 }
else if (
Entry.isConstantFP()) {
867 ArtificialDIEPtr = &ProcDIE;
870 if (
Entry.isInt() && PointeeTy)
871 ImplicitPointerDIEs.insert(
872 {{PointeeTy,
Entry.getInt()}, ArtificialDIEPtr});
877 const unsigned ImplicitPtrOp =
DD->getDwarfVersion() >= 5
878 ? dwarf::DW_OP_implicit_pointer
879 : dwarf::DW_OP_GNU_implicit_pointer;
880 addUInt(*Loc, dwarf::DW_FORM_data1, ImplicitPtrOp);
883 dwarf::DW_FORM_ref_addr, DIEEntry(*ArtificialDIEPtr));
885 addSInt(*Loc, dwarf::DW_FORM_sdata, 0);
887 addBlock(VariableDie, dwarf::DW_AT_location, Loc);
891void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
894 if (emitImplicitPointerLocation(
Single, DV, VariableDie))
897 const DbgValueLoc *DVal = &
Single.getValueLoc();
899 DD->addTargetVariableAttributes(*
this, VariableDie, std::nullopt,
903 if (
Entry->isLocation()) {
905 }
else if (
Entry->isInt()) {
906 auto *Expr =
Single.getExpr();
909 DIEDwarfExpression DwarfExpr(*
Asm, *
this, *Loc);
911 DwarfExpr.addFragmentOffset(Expr);
912 DwarfExpr.addUnsignedConstant(
Entry->getInt());
913 DwarfExpr.addExpression(Expr);
914 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
915 if (DwarfExpr.TagOffset)
916 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset,
917 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);
920 }
else if (
Entry->isConstantFP()) {
922 }
else if (
Entry->isConstantInt()) {
924 }
else if (
Entry->isTargetIndexLocation()) {
926 DIEDwarfExpression DwarfExpr(*
Asm, *
this, *Loc);
930 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
937 return Entry.isLocation() && !Entry.getLoc().getReg();
940 const DIExpression *Expr =
Single.getExpr();
941 assert(Expr &&
"Variadic Debug Value must have an Expression.");
943 DIEDwarfExpression DwarfExpr(*
Asm, *
this, *Loc);
944 DwarfExpr.addFragmentOffset(Expr);
945 DIExpressionCursor Cursor(Expr);
946 const TargetRegisterInfo &
TRI = *
Asm->MF->getSubtarget().getRegisterInfo();
948 auto AddEntry = [&](
const DbgValueLocEntry &
Entry,
949 DIExpressionCursor &Cursor) {
950 if (
Entry.isLocation()) {
951 if (!DwarfExpr.addMachineRegExpression(
TRI, Cursor,
952 Entry.getLoc().getReg()))
954 }
else if (
Entry.isInt()) {
956 DwarfExpr.addUnsignedConstant(
Entry.getInt());
957 }
else if (
Entry.isConstantFP()) {
962 APInt RawBytes =
Entry.getConstantFP()->getValueAPF().bitcastToAPInt();
966 }
else if (
Entry.isConstantInt()) {
967 APInt RawBytes =
Entry.getConstantInt()->getValue();
971 }
else if (
Entry.isTargetIndexLocation()) {
972 TargetIndexLocation Loc =
Entry.getTargetIndexLocation();
975 assert(
Asm->TM.getTargetTriple().isWasm());
983 if (!DwarfExpr.addExpression(
985 [&](
unsigned Idx, DIExpressionCursor &Cursor) ->
bool {
986 return AddEntry(DVal->getLocEntries()[Idx], Cursor);
991 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
992 if (DwarfExpr.TagOffset)
993 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
994 *DwarfExpr.TagOffset);
997void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
1003 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1007void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const Loc::MMI &MMI,
1010 std::optional<unsigned> TargetAddrSpace;
1012 DIEDwarfExpression DwarfExpr(*
Asm, *
this, *Loc);
1015 const DIExpression *Expr = Fragment.Expr;
1016 const TargetFrameLowering *TFI =
Asm->MF->getSubtarget().getFrameLowering();
1017 StackOffset Offset =
1019 DwarfExpr.addFragmentOffset(Expr);
1021 auto *
TRI =
Asm->MF->getSubtarget().getRegisterInfo();
1022 SmallVector<uint64_t, 8>
Ops;
1023 TRI->getOffsetOpcodes(Offset,
Ops);
1025 Expr =
DD->adjustExpressionForTarget(Expr, TargetAddrSpace);
1028 DIExpressionCursor Cursor(
Ops);
1029 DwarfExpr.setMemoryLocationKind();
1030 if (
const MCSymbol *FrameSymbol =
Asm->getFunctionFrameSymbol())
1033 DwarfExpr.addMachineRegExpression(
1034 *
Asm->MF->getSubtarget().getRegisterInfo(), Cursor, FrameReg);
1035 DwarfExpr.addExpression(std::move(Cursor));
1037 DD->addTargetVariableAttributes(*
this, VariableDie, TargetAddrSpace,
1039 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
1040 if (DwarfExpr.TagOffset)
1041 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1042 *DwarfExpr.TagOffset);
1045void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
1049 DIEDwarfExpression DwarfExpr(*
Asm, *
this, *Loc);
1052 DwarfExpr.addFragmentOffset(&Expr);
1054 DwarfExpr.beginEntryValueExpression(Cursor);
1055 DwarfExpr.addMachineRegExpression(
1056 *
Asm->MF->getSubtarget().getRegisterInfo(), Cursor,
Register);
1057 DwarfExpr.addExpression(std::move(Cursor));
1059 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
1062void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
1063 const std::monostate &,
const DbgVariable &DV,
DIE &VariableDie) {}
1067 DIE *&ObjectPointer) {
1070 ObjectPointer = Var;
1078 DL.setDIE(*LabelDie);
1080 if (Scope.isAbstractScope())
1090 if (!Array || Array->getTag() != dwarf::DW_TAG_array_type)
1092 if (
auto *DLVar = Array->getDataLocation())
1093 Result.push_back(DLVar);
1094 if (
auto *AsVar = Array->getAssociated())
1095 Result.push_back(AsVar);
1096 if (
auto *AlVar = Array->getAllocated())
1097 Result.push_back(AlVar);
1098 for (
auto *El : Array->getElements()) {
1100 if (
auto Count = Subrange->getCount())
1102 Result.push_back(Dependency);
1103 if (
auto LB = Subrange->getLowerBound())
1105 Result.push_back(Dependency);
1106 if (
auto UB = Subrange->getUpperBound())
1108 Result.push_back(Dependency);
1109 if (
auto ST = Subrange->getStride())
1111 Result.push_back(Dependency);
1113 if (
auto Count = GenericSubrange->getCount())
1115 Result.push_back(Dependency);
1116 if (
auto LB = GenericSubrange->getLowerBound())
1118 Result.push_back(Dependency);
1119 if (
auto UB = GenericSubrange->getUpperBound())
1121 Result.push_back(Dependency);
1122 if (
auto ST = GenericSubrange->getStride())
1124 Result.push_back(Dependency);
1145 DbgVar.
insert({Var->getVariable(), Var});
1150 while (!WorkList.
empty()) {
1151 auto Item = WorkList.
back();
1153 bool visitedAllDependencies = Item.getInt();
1159 if (Visited.
count(Var))
1163 if (visitedAllDependencies) {
1165 Result.push_back(Var);
1170 auto Res = Visiting.
insert(Var);
1172 assert(
false &&
"dependency cycle in local variables");
1196 assert(!Scope->getInlinedAt());
1197 assert(!Scope->isAbstractScope());
1202 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
1206 auto *SPTy =
Sub->getType();
1210 DITypeArray FnArgs = SPTy->getTypeArray();
1215 if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
1223bool DwarfCompileUnit::hasGlobalVariableInScope(
const DILocalScope *ScopeNode) {
1224 return GlobalVarScopes.contains(ScopeNode);
1229 DIE *ObjectPointer =
nullptr;
1232 auto Vars =
DU->getScopeVariables().lookup(Scope);
1233 for (
auto &DV : Vars.Args)
1242 for (
DbgLabel *
DL :
DU->getScopeLabels().lookup(Scope))
1249 auto &LocalDecls =
DD->getLocalDeclsForScope(Scope->getScopeNode());
1250 DeferredLocalDecls.insert_range(LocalDecls);
1254 auto skipLexicalScope = [
this](
LexicalScope *S) ->
bool {
1262 if (S->isAbstractScope() && hasGlobalVariableInScope(DS))
1267 if (getAbstractScopeDIEs().
lookup(DS))
1269 auto Vars =
DU->getScopeVariables().lookup(S);
1270 if (!Vars.Args.empty() || !Vars.Locals.empty())
1273 DD->getLocalDeclsForScope(DS).empty();
1279 if (skipLexicalScope(LS))
1285 return ObjectPointer;
1290 if (
auto *AbsDef = getAbstractScopeDIEs().
lookup(SP))
1293 auto [ContextDIE, ContextCU] = getOrCreateAbstractSubprogramContextDIE(SP);
1294 return createAbstractSubprogramDIE(SP, ContextDIE, ContextCU);
1297DIE &DwarfCompileUnit::createAbstractSubprogramDIE(
1302 *ContextDIE,
nullptr);
1305 ContextCU->getAbstractScopeDIEs()[SP] = &AbsDef;
1308 ContextCU->
addSInt(AbsDef, dwarf::DW_AT_inline,
1310 : dwarf::DW_FORM_implicit_const,
1316std::pair<DIE *, DwarfCompileUnit *>
1317DwarfCompileUnit::getOrCreateAbstractSubprogramContextDIE(
1323 if (
auto *SPDecl = SP->getDeclaration())
1332 return std::make_pair(ContextDIE, ContextCU);
1340 if (!getFinalizedAbstractSubprograms().insert(SP).second)
1343 auto [ContextDIE, ContextCU] = getOrCreateAbstractSubprogramContextDIE(SP);
1344 DIE *AbsDef = getAbstractScopeDIEs().lookup(SP);
1346 AbsDef = &createAbstractSubprogramDIE(SP, ContextDIE, ContextCU);
1349 ContextCU->
addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer,
1354 return DD->getDwarfVersion() <= 4 && !
DD->tuneForLLDB();
1361 case dwarf::DW_TAG_call_site:
1362 return dwarf::DW_TAG_GNU_call_site;
1363 case dwarf::DW_TAG_call_site_parameter:
1364 return dwarf::DW_TAG_GNU_call_site_parameter;
1375 case dwarf::DW_AT_call_all_calls:
1376 return dwarf::DW_AT_GNU_all_call_sites;
1377 case dwarf::DW_AT_call_target:
1378 return dwarf::DW_AT_GNU_call_site_target;
1379 case dwarf::DW_AT_call_target_clobbered:
1380 return dwarf::DW_AT_GNU_call_site_target_clobbered;
1381 case dwarf::DW_AT_call_origin:
1382 return dwarf::DW_AT_abstract_origin;
1383 case dwarf::DW_AT_call_return_pc:
1384 return dwarf::DW_AT_low_pc;
1385 case dwarf::DW_AT_call_value:
1386 return dwarf::DW_AT_GNU_call_site_value;
1387 case dwarf::DW_AT_call_tail_call:
1388 return dwarf::DW_AT_GNU_tail_call;
1399 case dwarf::DW_OP_entry_value:
1400 return dwarf::DW_OP_GNU_entry_value;
1415 if (CallTarget.
getReg()) {
1422 TRI.isCalleeSavedPhysReg(CallTarget.
getReg(), *
Asm->MF)
1423 ? dwarf::DW_AT_call_target
1424 : dwarf::DW_AT_call_target_clobbered);
1432 }
else if (CalleeSP) {
1434 assert(CalleeDIE &&
"Could not create DIE for call site entry origin");
1468 assert(PCAddr &&
"Missing return PC information for a call");
1474 addType(CallSiteDIE, AllocSiteTy, dwarf::DW_AT_LLVM_alloc_type);
1481 for (
const auto &Param : Params) {
1482 unsigned Register = Param.getRegister();
1483 auto CallSiteDieParam =
1487 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,
1499 CallSiteDIE.
addChild(CallSiteDieParam);
1508 auto *Entity =
Module->getEntity();
1517 if (
auto *AbsSPDie = getAbstractScopeDIEs().
lookup(SP))
1518 EntityDie = AbsSPDie;
1528 EntityDie =
getDIE(Entity);
1531 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
1533 if (!Name.empty()) {
1534 addString(*IMDie, dwarf::DW_AT_name, Name);
1541 DD->addAccelNamespace(*
this,
CUNode->getNameTableKind(), Name, *IMDie);
1546 DINodeArray Elements =
Module->getElements();
1547 for (
const auto *Element : Elements) {
1565 assert(ContextDIE &&
"Empty scope for the imported entity!");
1574 if (
DIE *AbsSPDIE = getAbstractScopeDIEs().
lookup(SP)) {
1577 addDIEEntry(*
D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
1589 auto *Die = Entity->
getDIE();
1593 if (AbsEntity && AbsEntity->
getDIE()) {
1608 const auto *Sym = Label->getSymbol();
1615 if (
StringRef Name = Label->getName(); !Name.empty())
1621 if (
auto *AbsLSDie = getAbstractScopeDIEs().
lookup(LS))
1622 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *AbsLSDie);
1625 for (
auto [LScope, ScopeDIE] : LexicalBlockDIEs)
1626 AttachAO(LScope, ScopeDIE);
1627 for (
auto &[LScope, ScopeDIEs] : InlinedLocalScopeDIEs)
1628 for (
auto *ScopeDIE : ScopeDIEs)
1629 AttachAO(LScope, ScopeDIE);
1633 auto &AbstractEntities = getAbstractEntities();
1634 auto I = AbstractEntities.find(
Node);
1635 if (
I != AbstractEntities.end())
1636 return I->second.get();
1642 assert(Scope && Scope->isAbstractScope());
1643 auto &Entity = getAbstractEntities()[
Node];
1649 Entity = std::make_unique<DbgLabel>(
1657 if (!Skeleton && !
DD->useSectionsAsReferences()) {
1663 :
DD->useSplitDwarf() ? dwarf::DW_UT_skeleton
1664 : dwarf::DW_UT_compile;
1666 if (
DD->getDwarfVersion() >= 5 && UT != dwarf::DW_UT_compile)
1671 if (!
DD->shouldEmitDwarfPubSections())
1674 switch (
CUNode->getNameTableKind()) {
1685 !
CUNode->isDebugDirectivesOnly() &&
1687 DD->getDwarfVersion() < 5;
1698 GlobalNames[FullName] = &Die;
1710 GlobalNames.insert(std::make_pair(std::move(FullName), &
getUnitDie()));
1719 GlobalTypes[FullName] = &Die;
1731 GlobalTypes.insert(std::make_pair(std::move(FullName), &
getUnitDie()));
1736 auto *
Single = std::get_if<Loc::Single>(&DV);
1740 addAddress(Die, dwarf::DW_AT_location, Location);
1748 if (Location.isIndirect())
1749 DwarfExpr.setMemoryLocationKind();
1753 if (!DwarfExpr.addMachineRegExpression(
TRI, Cursor, Location.getReg()))
1755 DwarfExpr.addExpression(std::move(Cursor));
1760 if (DwarfExpr.TagOffset)
1761 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1762 *DwarfExpr.TagOffset);
1768 addLocationWithExpr(Die,
Attribute, Location, {});
1776 assert(Location.isIndirect() &&
"Memory loc should be indirect");
1808 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1816 ? dwarf::DW_FORM_loclistx
1817 :
DD->getDwarfSectionOffsetForm();
1825 addString(VariableDie, dwarf::DW_AT_name, Name);
1828 if (
uint32_t AlignInBytes = DIVar->getAlignInBytes())
1829 addUInt(VariableDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1837 addFlag(VariableDie, dwarf::DW_AT_artificial);
1844 addString(LabelDie, dwarf::DW_AT_name, Name);
1845 const auto *
DILabel = Label.getLabel();
1848 addFlag(LabelDie, dwarf::DW_AT_artificial);
1850 addUInt(LabelDie, dwarf::DW_AT_LLVM_coro_suspend_idx, std::nullopt,
1862 auto *SPDecl = SP->getDeclaration();
1863 auto *Context = SPDecl ? SPDecl->getScope() : SP->getScope();
1868bool DwarfCompileUnit::isDwoUnit()
const {
1878 (
DD->useSplitDwarf() && !Skeleton);
1887 MCSymbol *Label =
DD->getAddressPool().getLabel();
1889 DD->getDwarfVersion() >= 5 ? dwarf::DW_AT_addr_base
1890 : dwarf::DW_AT_GNU_addr_base,
1911 addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);
1918 addUInt(Die, dwarf::DW_AT_byte_size, std::nullopt,
1926 bool isAbstract = getAbstractScopeDIEs().count(LB->
getSubprogram());
1928 auto &DIEs = getAbstractScopeDIEs();
1929 if (
auto It = DIEs.find(LB); It != DIEs.end())
1932 assert(!isAbstract &&
"Missed lexical block DIE in abstract tree!");
1935 if (
auto It = LexicalBlockDIEs.find(LB); It != LexicalBlockDIEs.end())
1947 Context = LFScope->getNonLexicalBlockFileScope();
1953 const auto &DIEs = getAbstractScopeDIEs();
1954 if (
auto It = DIEs.find(SPScope); It != DIEs.end())
1963 if (!
F && SP->isDefinition()) {
1964 F =
DD->getLexicalScopes().getFunction(SP);
1969 return &
DD->getOrCreateAbstractSubprogramCU(SP, *
this)
1970 .getOrCreateAbstractSubprogramDIE(SP);
1980 !CalleeSP.isDefinition() &&
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static SmallVector< DbgVariable *, 8 > sortLocalVars(SmallVectorImpl< DbgVariable * > &Input)
Sort local variables so that variables appearing inside of helper expressions come first.
static const DIType * resolveTypeQualifiers(const DIType *Ty)
static SmallVector< const DIVariable *, 2 > dependencies(DbgVariable *Var)
Return all DIVariables that appear in count: expressions.
static cl::opt< bool > EmitFuncLineTableOffsetsOption("emit-func-debug-line-table-offsets", cl::Hidden, cl::desc("Include line table offset in function's debug info and emit end " "sequence after each function's line data."), cl::init(false))
static bool AddLinkageNamesToDeclCallOriginsForTuning(const DwarfDebug *DD)
static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW)
static cl::opt< cl::boolOrDefault > AddLinkageNamesToDeclCallOrigins("add-linkage-names-to-declaration-call-origins", cl::Hidden, cl::desc("Add DW_AT_linkage_name to function declaration DIEs " "referenced by DW_AT_call_origin attributes. Enabled by default " "for -gsce debugger tuning."))
Query value using AddLinkageNamesToDeclCallOriginsForTuning.
This file contains constants used for implementing Dwarf debug support.
static bool lookup(const GsymReader &GR, GsymDataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SmallString class.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
This class is intended to be used as a driving class for all asm writers.
MachineFunction * MF
The current machine function.
const DataLayout & getDataLayout() const
Return information about data layout.
MCSymbol * GetExternalSymbolSymbol(const Twine &Sym) const
Return the MCSymbol for the specified ExternalSymbol.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
unsigned getLineNo() const
StringRef getName() const
DIScope * getScope() const
DIGlobalVariable * getDecl() const
static LLVM_ABI std::optional< DebugEmissionKind > getEmissionKind(StringRef Str)
DIEBlock - Represents a block of values.
DwarfExpression implementation for singular DW_AT_location.
Represents a pointer to a location list in the debug_loc section.
DIELoc - Represents an expression location.
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
A structured debug information entry.
LLVM_ABI DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
DIE & addChild(DIE *Child)
Add a child to the DIE.
DIE & addChildFront(DIE *Child)
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
LLVM_ABI const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
Holds a DIExpression and keeps track of how many operands have been consumed so far.
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
unsigned getNumElements() const
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
element_iterator elements_begin() const
ArrayRef< uint64_t > getElements() const
uint64_t getElement(unsigned I) const
LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
DIDerivedType * getStaticDataMemberDeclaration() const
MDTuple * getTemplateParams() const
bool isLocalToUnit() const
StringRef getLinkageName() const
StringRef getDisplayName() const
bool isDefinition() const
DINodeArray getAnnotations() const
An imported module (C++ using directive or similar).
bool isArtificial() const
std::optional< unsigned > getCoroSuspendIdx() const
DILocalScope * getScope() const
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.
Tagged DWARF-like metadata node.
LLVM_ABI dwarf::Tag getTag() const
Base class for scope-like contexts.
Subprogram description. Uses SubclassData1.
uint32_t getAlignInBytes() const
DIScope * getScope() const
StringRef getName() const
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
const DINode * getEntity() const
Accessors.
This class is used to track label information.
ArrayRef< DbgValueLocEntry > getLocEntries() const
This class is used to track local variable information.
bool isArtificial() const
Return true if DbgVariable is artificial.
dwarf::Tag getTag() const
bool isObjectPointer() const
const DILocalVariable * getVariable() const
StringRef getName() const
const DIType * getType() const
Loc::Variant & asVariant()
To workaround P2162R0 https://github.com/cplusplus/papers/issues/873 the base class subobject needs t...
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool useGNUAnalogForDwarf5Feature() const
Whether to use the GNU analog for a DWARF5 tag, attribute, or location atom.
void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, SmallVector< DbgCallSiteParam, 4 > &Params)
Construct call site parameter DIEs for the CallSiteDIE.
void addLinkageNamesToDeclarations(const DwarfDebug &DD, const DISubprogram &CalleeSP, DIE &CalleeDIE)
void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End)
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const
This takes a DWARF 5 tag and returns it or a GNU analog.
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
bool includeMinimalInlineScopes() const
DIE * getOrCreateImportedEntityDIE(const DIImportedEntity *IE)
Get or create a DIE for an imported entity.
void addBaseTypeRef(DIEValueList &Die, int64_t Idx)
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
void finishEntityDefinition(const DbgEntity *Entity)
void addMemoryLocation(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location, int64_t Offset)
Add a memory location exprloc to DIE with attribute Attribute at Location + Offset.
void addRange(RangeSpan Range)
addRange - Add an address range to the list of ranges for this unit.
void addAddrTableBase()
Add the DW_AT_addr_base attribute to the unit DIE.
std::vector< BaseTypeRef > ExprRefedBaseTypes
DIE * constructInlinedScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)
This scope represents an inlined body of a function.
void createBaseTypeDIEs()
void addScopeRangeList(DIE &ScopeDIE, SmallVector< RangeSpan, 2 > Range)
A helper function to construct a RangeSpanList for a given lexical scope.
uint64_t getDWOId() const
DIE * getOrCreateCommonBlock(const DICommonBlock *CB, ArrayRef< GlobalExpr > GlobalExprs)
void addVariableAddress(const DbgVariable &DV, DIE &Die, MachineLocation Location)
Add DW_AT_location attribute for a DbgVariable based on provided MachineLocation.
DIE & constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, const Function *CalleeF, bool IsTail, const MCSymbol *PCAddr, const MCSymbol *CallAddr, MachineLocation CallTarget, int64_t Offset, DIType *AllocSiteTy)
Construct a call site entry DIE describing a call within Scope to a callee described by CalleeSP and ...
DIE & getOrCreateAbstractSubprogramDIE(const DISubprogram *SP)
Create an abstract subprogram DIE, that should later be populated by constructAbstractSubprogramScope...
DIE & constructSubprogramScopeDIE(const DISubprogram *Sub, const Function &F, LexicalScope *Scope, MCSymbol *LineTableSym)
Construct a DIE for this subprogram scope.
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
DIE & updateSubprogramScopeDIE(const DISubprogram *SP, const Function &F, MCSymbol *LineTableSym)
Find DIE for the given subprogram and attach appropriate DW_AT_low_pc, DW_AT_high_pc and DW_AT_LLVM_s...
void createAbstractEntity(const DINode *Node, LexicalScope *Scope)
void applyStmtList(DIE &D)
Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *F, bool Minimal=false) override
DIE * getOrCreateContextDIE(const DIScope *Ty) override
Construct a DIE for a given scope.
void applyCommonDbgVariableAttributes(const DbgVariable &Var, DIE &VariableDie)
Add attributes to Var which reflect the common attributes of VariableDie, namely those which are not ...
DIE * constructVariableDIE(DbgVariable &DV, bool Abstract=false)
Construct a DIE for the given DbgVariable.
dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const
This takes a DWARF 5 location atom and either returns it or a GNU analog.
DIE * getLocalContextDIE(const DILexicalBlock *LB)
Get DW_TAG_lexical_block for the given DILexicalBlock if available, or the most close parent DIE,...
DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
Get or create global variable DIE.
void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie)
DIE * createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE)
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr)
Add a Dwarf expression attribute data and value.
DIE * getOrCreateLexicalBlockDIE(LexicalScope *Scope, DIE &ParentDIE)
Get if available or create a new DW_TAG_lexical_block for the given LexicalScope and attach DW_AT_low...
dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const
This takes a DWARF 5 attribute and returns it or a GNU analog.
void addAddress(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Add an address attribute to a die based on the location provided.
void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie)
void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLocalLabelAddress - Add a dwarf label attribute data and value using DW_FORM_addr only.
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)
void attachLexicalScopesAbstractOrigins()
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, UnitKind Kind=UnitKind::Full)
DIE * constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope)
Construct a DIE for the given DbgLabel.
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
DbgEntity * getExistingAbstractEntity(const DINode *Node)
bool hasDwarfPubSections() const
void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLabelAddress - Add a dwarf label attribute data and value using either DW_FORM_addr or DW_FORM_GNU...
void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index)
Add a Dwarf loclistptr attribute data and value.
bool emitFuncLineTableOffsets() const
void addComplexAddress(const DIExpression *DIExpr, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Start with the address based on the location provided, and generate the DWARF information necessary t...
DIE * constructImportedEntityDIE(const DIImportedEntity *IE)
DwarfCompileUnit & getCU() override
void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)
void finishSubprogramDefinition(const DISubprogram *SP)
Collects and handles dwarf debug information.
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for split DWARF.
void addAccelName(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)
Set the location (Loc) and DIExpression (DIExpr) to describe.
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
std::optional< uint8_t > TagOffset
void setCallSiteParamValueFlag()
Lock this down to become a call site parameter location.
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
void addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
void addWasmLocation(unsigned Index, uint64_t Offset)
Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...
void beginEntryValueExpression(DIExpressionCursor &ExprCursor)
Begin emission of an entry value dwarf operation.
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
DwarfDebug & getDwarfDebug() const
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
void addOpAddress(DIELoc &Die, const MCSymbol *Sym)
Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
DIE * getOrCreateNameSpace(const DINamespace *NS)
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal)
const DICompileUnit * CUNode
MDNode for the compile unit.
virtual DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *FnHint, bool Minimal=false)
DIE * getOrCreateSubprogramContextDIE(const DISubprogram *SP, bool IgnoreScope)
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
MCSymbol * LabelBegin
The start of the unit within its section.
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
void addSourceLine(DIE &Die, unsigned Line, unsigned Column, const DIFile *File)
Add location information to specified debug information entry.
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
BumpPtrAllocator DIEValueAllocator
DIE * getOrCreateModule(const DIModule *M)
const DICompileUnit * getCUNode() const
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
AsmPrinter * Asm
Target of Dwarf emission.
unsigned getUniqueID() const
Gets Unique ID for this unit.
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
This class is used to track scope information.
Multi-value location description.
unsigned getDebugLocListIndex() const
std::optional< uint8_t > getDebugLocListTagOffset() const
Single value location description.
Base class for the full range of assembler expressions which are needed for parsing.
MCSection * getDwarfRangesSection() const
MCSection * getDwarfAddrSection() const
MCSection * getDwarfLineSection() const
MCSymbol * getBeginSymbol()
void setType(wasm::WasmSymbolType type)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
A Module instance is used to store all the information related to an LLVM module.
StringRef getName() const
Get a short "name" for the module.
Wrapper class representing virtual and physical registers.
static constexpr bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Implements a dense probed hash-table based set with some number of buckets stored inline.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
Information about stack frame layout on the target.
virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const
Return the frame base information to be encoded in the DWARF subprogram debug info.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
A DeclContext is a named program scope that is used for ODR uniquing of types.
LLVM_ABI StringRef AttributeEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
UnitType
Constants for unit types in DWARF v5.
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
@ WASM_SYMBOL_TYPE_GLOBAL
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
LLVM_ABI bool isRangeRelaxable(const MCSymbol *Begin, const MCSymbol *End)
bool isa_and_nonnull(const Y &Val)
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
This is used to track range of instructions with identical lexical scope.
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)
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
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...
@ Global
Append to llvm.global_dtors.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
@ Sub
Subtraction of integers.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Single location defined by (potentially multiple) EntryValueInfo.
std::set< EntryValueInfo > EntryValues
Single location defined by (potentially multiple) MMI entries.
const std::set< FrameIndexExpr > & getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
Helper used to pair up a symbol and its DWARF compile unit.
union llvm::TargetFrameLowering::DwarfFrameBase::@004076321055032247336074224075335064105264310375 Location
enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind
struct WasmFrameBase WasmLoc