82 #define DEBUG_TYPE "dwarfdebug" 86 cl::desc(
"Disable debug info printing"));
89 "use-dwarf-ranges-base-address-specifier",
cl::Hidden,
99 cl::desc(
"Generate DWARF4 type units."),
103 "split-dwarf-cross-cu-references",
cl::Hidden,
110 cl::desc(
"Make an absence of debug location information explicit."),
118 "Default for platform"),
126 cl::desc(
"Use inlined strings rather than string section."),
134 cl::desc(
"Disable emission of DWARF pub sections."),
139 cl::desc(
"Disable emission .debug_ranges section."),
144 cl::desc(
"Use sections+offset as references rather than labels."),
157 cl::desc(
"Which DWARF linkage-name attributes to emit."),
159 "Default for platform"),
162 "Abstract subprograms")),
170 void DebugLocDwarfExpression::emitOp(uint8_t
Op,
const char *Comment) {
176 void DebugLocDwarfExpression::emitSigned(int64_t
Value) {
180 void DebugLocDwarfExpression::emitUnsigned(uint64_t Value) {
185 unsigned MachineReg) {
191 assert(Var &&
"Invalid complex DbgVariable!");
192 return Var->getType().resolve()->isBlockByrefStruct();
225 uint16_t tag = Ty->
getTag();
227 if (tag == dwarf::DW_TAG_pointer_type)
228 subType = resolve(cast<DIDerivedType>(Ty)->
getBaseType());
230 auto Elements = cast<DICompositeType>(subType)->getElements();
231 for (
unsigned i = 0,
N = Elements.size(); i <
N; ++i) {
232 auto *DT = cast<DIDerivedType>(Elements[i]);
233 if (
getName() == DT->getName())
234 return resolve(DT->getBaseType());
241 if (FrameIndexExprs.size() == 1)
242 return FrameIndexExprs;
245 [](
const FrameIndexExpr &A) {
246 return A.Expr->isFragment();
248 "multiple FI expressions without DW_OP_LLVM_fragment");
249 llvm::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(),
250 [](
const FrameIndexExpr &A,
const FrameIndexExpr &
B) ->
bool {
251 return A.Expr->getFragmentInfo()->OffsetInBits <
252 B.Expr->getFragmentInfo()->OffsetInBits;
255 return FrameIndexExprs;
259 assert(DebugLocListIndex == ~0U && !MInsn &&
"not an MMI entry");
260 assert(V.DebugLocListIndex == ~0U && !V.MInsn &&
"not an MMI entry");
261 assert(V.Var == Var &&
"conflicting variable");
262 assert(V.IA == IA &&
"conflicting inlined-at location");
264 assert(!FrameIndexExprs.empty() &&
"Expected an MMI entry");
265 assert(!V.FrameIndexExprs.
empty() &&
"Expected an MMI entry");
271 if (FrameIndexExprs.size()) {
272 auto *Expr = FrameIndexExprs.back().Expr;
273 if (!Expr || !Expr->isFragment())
277 for (
const auto &FIE : V.FrameIndexExprs)
280 return FIE.FI == Other.FI && FIE.Expr == Other.Expr;
282 FrameIndexExprs.push_back(FIE);
284 assert((FrameIndexExprs.size() == 1 ||
286 [](FrameIndexExpr &FIE) {
287 return FIE.Expr && FIE.Expr->isFragment();
289 "conflicting locations for variable");
293 bool GenerateTypeUnits,
301 if (GenerateTypeUnits)
307 if (DwarfVersion >= 5)
317 InfoHolder(A,
"info_string", DIEValueAllocator),
318 SkeletonHolder(A,
"skel_string", DIEValueAllocator),
319 IsDarwin(A->
TM.getTargetTriple().isOSDarwin()) {
333 if (DwarfInlinedStrings ==
Default)
334 UseInlineStrings = TT.
isNVPTX();
336 UseInlineStrings = DwarfInlinedStrings ==
Enable;
352 unsigned DwarfVersion = DwarfVersionNumber ? DwarfVersionNumber
358 UsePubSections = !NoDwarfPubSections && !TT.
isNVPTX();
359 UseRangesSection = !NoDwarfRangesSection && !TT.
isNVPTX();
362 if (DwarfSectionsAsReferences ==
Default)
363 UseSectionsAsReferences = TT.
isNVPTX();
365 UseSectionsAsReferences = DwarfSectionsAsReferences ==
Enable;
379 UseGNUTLSOpcode =
tuneForGDB() || DwarfVersion < 3;
382 UseDWARF2Bitfields = (DwarfVersion < 4) ||
tuneForGDB();
388 UseSegmentedStringOffsetsTable = DwarfVersion >= 5;
425 if (!SP->isDefinition())
434 if (SP->getLinkageName() !=
"" && SP->
getName() != SP->getLinkageName() &&
462 if (Ranges.
size() > 1)
481 void DwarfDebug::constructAbstractSubprogramScopeDIE(
DwarfCompileUnit &SrcCU,
495 auto &
CU = getOrCreateDwarfCompileUnit(SP->getUnit());
496 if (
auto *SkelCU =
CU.getSkeleton()) {
498 .constructAbstractSubprogramScopeDIE(Scope);
499 if (
CU.getCUNode()->getSplitDebugInlining())
500 SkelCU->constructAbstractSubprogramScopeDIE(Scope);
502 CU.constructAbstractSubprogramScopeDIE(Scope);
510 U.
addFlag(D, dwarf::DW_AT_GNU_pubnames);
516 DwarfDebug::getOrCreateDwarfCompileUnit(
const DICompileUnit *DIUnit) {
517 if (
auto *
CU = CUMap.lookup(DIUnit))
522 auto OwnedUnit = llvm::make_unique<DwarfCompileUnit>(
523 InfoHolder.
getUnits().size(), DIUnit,
Asm,
this, &InfoHolder);
526 InfoHolder.
addUnit(std::move(OwnedUnit));
528 NewCU.setSkeleton(constructSkeletonCU(NewCU));
529 NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name,
530 Asm->TM.Options.MCOptions.SplitDwarfFile);
534 NewCU.addImportedEntity(
IE);
540 if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU)
541 Asm->OutStreamer->emitDwarfFile0Directive(
542 CompilationDir, FN, NewCU.getMD5AsBytes(DIUnit->
getFile()),
543 DIUnit->
getSource(), NewCU.getUniqueID());
547 if (!Flags.
empty()) {
548 std::string ProducerWithFlags = Producer.
str() +
" " + Flags.
str();
549 NewCU.addString(Die, dwarf::DW_AT_producer, ProducerWithFlags);
551 NewCU.addString(Die, dwarf::DW_AT_producer, Producer);
553 NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
555 NewCU.addString(Die, dwarf::DW_AT_name, FN);
559 NewCU.addStringOffsetsStart();
562 NewCU.initStmtList();
566 if (!CompilationDir.
empty())
567 NewCU.addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
569 addGnuPubAttributes(NewCU, Die);
574 NewCU.addFlag(Die, dwarf::DW_AT_APPLE_optimized);
578 NewCU.addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
581 NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
582 dwarf::DW_FORM_data1, RVer);
586 NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoDWOSection());
588 NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
592 NewCU.addUInt(Die, dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8,
596 NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name,
600 CUMap.insert({DIUnit, &NewCU});
601 CUDieMap.insert({&Die, &NewCU});
607 if (isa<DILocalScope>(N->
getScope()))
624 if (!A.
Expr || !
B.Expr)
627 auto FragmentB =
B.Expr->getFragmentInfo();
628 if (!FragmentA || !FragmentB)
630 return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
635 return A.
Expr ==
B.Expr;
656 SingleCU = NumDebugCUs == 1;
662 for (
auto *GVE : GVs)
663 GVMap[GVE->getVariable()].push_back({&
Global, GVE->getExpression()});
685 return !isa<DILocalScope>(
IE->getScope());
688 if (!HasNonLocalImportedEntities && CUNode->getEnumTypes().empty() &&
689 CUNode->getRetainedTypes().empty() &&
690 CUNode->getGlobalVariables().empty() && CUNode->getMacros().empty())
696 for (
auto *GVE : CUNode->getGlobalVariables()) {
700 auto &GVMapEntry = GVMap[GVE->getVariable()];
701 auto *Expr = GVE->getExpression();
702 if (!GVMapEntry.size() || (Expr && Expr->isConstant()))
703 GVMapEntry.push_back({
nullptr, Expr});
706 for (
auto *GVE : CUNode->getGlobalVariables()) {
708 if (Processed.
insert(GV).second)
712 for (
auto *Ty : CUNode->getEnumTypes()) {
717 for (
auto *Ty : CUNode->getRetainedTypes()) {
720 if (
DIType *RT = dyn_cast<DIType>(Ty))
726 for (
auto *
IE : CUNode->getImportedEntities())
727 constructAndAddImportedEntityDIE(CU,
IE);
731 void DwarfDebug::finishVariableDefinitions() {
732 for (
const auto &Var : ConcreteVariables) {
733 DIE *VariableDie = Var->getDIE();
744 void DwarfDebug::finishSubprogramDefinitions() {
748 getOrCreateDwarfCompileUnit(
SP->getUnit()),
753 void DwarfDebug::finalizeModuleInfo() {
756 finishSubprogramDefinitions();
758 finishVariableDefinitions();
764 if (CUMap.size() > 1)
769 for (
const auto &
P : CUMap) {
770 auto &TheCU = *
P.second;
788 dwarf::DW_FORM_data8,
ID);
789 SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
790 dwarf::DW_FORM_data8,
ID);
796 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_addr_base,
801 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base,
813 if (
unsigned NumRanges = TheCU.
getRanges().size()) {
829 auto *CUNode = cast<DICompileUnit>(
P.first);
831 if (CUNode->getMacros())
839 if (CUNode->getDWOId())
840 getOrCreateDwarfCompileUnit(CUNode);
860 finalizeModuleInfo();
889 emitDebugAbbrevDWO();
899 emitAccelNamespaces();
903 emitAccelDebugNames();
912 emitDebugPubSections();
918 void DwarfDebug::ensureAbstractVariableIsCreated(
DwarfCompileUnit &
CU, InlinedVariable IV,
919 const MDNode *ScopeNode) {
925 cast<DILocalScope>(ScopeNode)));
928 void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(
DwarfCompileUnit &CU,
929 InlinedVariable IV,
const MDNode *ScopeNode) {
940 void DwarfDebug::collectVariableInfoFromMFTable(
946 assert(
VI.Var->isValidLocationForIntrinsic(
VI.Loc) &&
947 "Expected inlined-at fields to agree");
949 InlinedVariable Var(
VI.Var,
VI.Loc->getInlinedAt());
957 ensureAbstractVariableIsCreatedIfScoped(TheCU, Var, Scope->
getScopeNode());
958 auto RegVar = llvm::make_unique<DbgVariable>(Var.first, Var.second);
959 RegVar->initializeMMI(
VI.Expr,
VI.Slot);
961 DbgVar->addMMIEntry(*RegVar);
963 MFVars.
insert({Var, RegVar.get()});
964 ConcreteVariables.push_back(std::move(RegVar));
978 assert((!Op1.isImm() || (Op1.getImm() == 0)) &&
"unexpected offset");
997 if (Begin == Next.Begin) {
998 auto *FirstExpr = cast<DIExpression>(Values[0].Expression);
999 auto *FirstNextExpr = cast<DIExpression>(Next.Values[0].Expression);
1000 if (!FirstExpr->isFragment() || !FirstNextExpr->isFragment())
1006 for (
unsigned i = 0, j = 0; i < Values.size(); ++i) {
1007 for (; j < Next.Values.size(); ++j) {
1008 int res = cast<DIExpression>(Values[i].Expression)->fragmentCmp(
1009 cast<DIExpression>(Next.Values[j].Expression));
1021 addValues(Next.Values);
1056 for (
auto I = Ranges.
begin(),
E = Ranges.
end();
I !=
E; ++
I) {
1073 OpenRanges.
erase(Last, OpenRanges.
end());
1076 assert(StartLabel &&
"Forgot label before DBG_VALUE starting a range!");
1081 else if (std::next(
I) == Ranges.
end())
1085 assert(EndLabel &&
"Forgot label after instruction ending a range!");
1091 bool couldMerge =
false;
1099 if (!DebugLoc.
empty())
1107 if (OpenRanges.
size())
1115 auto CurEntry = DebugLoc.
rbegin();
1117 dbgs() << CurEntry->getValues().size() <<
" Values:\n";
1118 for (
auto &Value : CurEntry->getValues())
1120 dbgs() <<
"-----\n";
1123 auto PrevEntry = std::next(CurEntry);
1124 if (PrevEntry != DebugLoc.
rend() && PrevEntry->MergeRanges(*CurEntry))
1131 InlinedVariable IV) {
1132 ensureAbstractVariableIsCreatedIfScoped(TheCU, IV, Scope.
getScopeNode());
1133 ConcreteVariables.push_back(
1134 llvm::make_unique<DbgVariable>(IV.first, IV.second));
1136 return ConcreteVariables.back().get();
1154 if (LSRange.size() == 0)
1158 const MachineInstr *LScopeBegin = LSRange.front().first;
1163 for (++Pred; Pred != MBB->rend(); ++Pred) {
1166 auto PredDL = Pred->getDebugLoc();
1167 if (!PredDL || Pred->isMetaInstruction())
1171 if (DL->getScope() == PredDL->getScope())
1174 if (!PredScope || LScope->dominates(PredScope))
1202 collectVariableInfoFromMFTable(TheCU, Processed);
1205 InlinedVariable IV =
I.first;
1206 if (Processed.
count(IV))
1210 const auto &Ranges =
I.second;
1224 DbgVariable *RegVar = createConcreteVariable(TheCU, *Scope, IV);
1230 if (Ranges.
size() == 1 &&
1244 buildLocationList(Entries, Ranges);
1250 static_cast<const Metadata *
>(IV.first->getType()));
1253 for (
auto &Entry : Entries)
1254 Entry.finalize(*
Asm, List, BT);
1258 for (
const DINode *DN : SP->getRetainedNodes()) {
1259 if (
auto *DV = dyn_cast<DILocalVariable>(DN)) {
1260 if (Processed.
insert(InlinedVariable(DV,
nullptr)).second)
1262 createConcreteVariable(TheCU, *Scope, InlinedVariable(DV,
nullptr));
1284 unsigned LastAsmLine =
1293 if (LastAsmLine == 0 && DL.
getLine() != 0) {
1304 if (LastAsmLine == 0)
1307 if (UnknownLocations == Disable)
1321 const MDNode *Scope =
nullptr;
1322 unsigned Column = 0;
1327 recordSourceLine(0, Column, Scope, 0);
1359 for (
const auto &MBB : *MF)
1360 for (
const auto &
MI : MBB)
1363 return MI.getDebugLoc();
1393 auto *SP =
PrologEndLoc->getInlinedAtScope()->getSubprogram();
1411 "endFunction should be called with the same function as beginFunction");
1421 collectVariableInfo(TheCU, SP, ProcessedVars);
1429 if (!TheCU.getCUNode()->getDebugInfoForProfiling() &&
1443 auto *SP = cast<DISubprogram>(AScope->getScopeNode());
1444 for (
const DINode *DN : SP->getRetainedNodes()) {
1445 if (
auto *DV = dyn_cast<DILocalVariable>(DN)) {
1447 if (!ProcessedVars.
insert(InlinedVariable(DV,
nullptr)).second)
1449 ensureAbstractVariableIsCreated(TheCU, InlinedVariable(DV,
nullptr),
1452 &&
"ensureAbstractVariableIsCreated inserted abstract scopes");
1455 constructAbstractSubprogramScopeDIE(TheCU, AScope);
1458 ProcessedSPNodes.insert(SP);
1459 TheCU.constructSubprogramScopeDIE(SP, FnScope);
1460 if (
auto *SkelCU = TheCU.getSkeleton())
1462 TheCU.getCUNode()->getSplitDebugInlining())
1463 SkelCU->constructSubprogramScopeDIE(SP, FnScope);
1476 void DwarfDebug::recordSourceLine(
unsigned Line,
unsigned Col,
const MDNode *S,
1479 unsigned FileNo = 1;
1480 unsigned Discriminator = 0;
1481 if (
auto *Scope = cast_or_null<DIScope>(S)) {
1482 Fn = Scope->getFilename();
1484 if (
auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
1485 Discriminator = LBF->getDiscriminator();
1487 unsigned CUID =
Asm->
OutStreamer->getContext().getDwarfCompileUnitID();
1489 .getOrCreateSourceID(Scope->getFile());
1491 Asm->
OutStreamer->EmitDwarfLocDirective(FileNo, Line, Col, Flags, 0,
1500 void DwarfDebug::emitDebugInfo() {
1506 void DwarfDebug::emitAbbreviations() {
1512 void DwarfDebug::emitStringOffsetsTableHeader() {
1519 template <
typename AccelTableT>
1528 void DwarfDebug::emitAccelDebugNames() {
1530 if (getUnits().empty())
1539 void DwarfDebug::emitAccelNames() {
1546 void DwarfDebug::emitAccelObjC() {
1552 void DwarfDebug::emitAccelNamespaces() {
1553 emitAccel(AccelNamespace,
1559 void DwarfDebug::emitAccelTypes() {
1590 if (Die->
getTag() == dwarf::DW_TAG_compile_unit)
1598 DIE &SpecDIE = SpecVal.getDIEEntry().getEntry();
1605 case dwarf::DW_TAG_class_type:
1606 case dwarf::DW_TAG_structure_type:
1607 case dwarf::DW_TAG_union_type:
1608 case dwarf::DW_TAG_enumeration_type:
1613 case dwarf::DW_TAG_typedef:
1614 case dwarf::DW_TAG_base_type:
1615 case dwarf::DW_TAG_subrange_type:
1617 case dwarf::DW_TAG_namespace:
1619 case dwarf::DW_TAG_subprogram:
1621 case dwarf::DW_TAG_variable:
1623 case dwarf::DW_TAG_enumerator:
1633 void DwarfDebug::emitDebugPubSections() {
1634 for (
const auto &NU : CUMap) {
1644 emitDebugPubSection(GnuStyle,
"Names", TheU, TheU->
getGlobalNames());
1649 emitDebugPubSection(GnuStyle,
"Types", TheU, TheU->
getGlobalTypes());
1661 void DwarfDebug::emitDebugPubSection(
bool GnuStyle,
StringRef Name,
1668 Asm->
OutStreamer->AddComment(
"Length of Public " + Name +
" Info");
1679 emitSectionReference(*TheU);
1685 for (
const auto &GI : Globals) {
1686 const char *Name = GI.getKeyData();
1687 const DIE *Entity = GI.second;
1710 void DwarfDebug::emitDebugStr() {
1711 MCSection *StringOffsetsSection =
nullptr;
1713 emitStringOffsetsTableHeader();
1718 StringOffsetsSection,
true);
1724 auto Comment = Comments.begin();
1725 auto End = Comments.end();
1726 for (uint8_t Byte : DebugLocs.
getBytes(Entry))
1727 Streamer.
EmitInt8(Byte, Comment != End ? *(Comment++) :
"");
1737 if (Value.
isInt()) {
1738 if (BT && (BT->
getEncoding() == dwarf::DW_ATE_signed ||
1766 if (Value.isFragment()) {
1770 }) &&
"all values are expected to be fragments");
1771 assert(std::is_sorted(Values.begin(), Values.end()) &&
1772 "fragments are expected to be sorted");
1774 for (
auto Fragment : Values)
1778 assert(Values.size() == 1 &&
"only fragments may have >1 value");
1781 DwarfExpr.finalize();
1795 void DwarfDebug::emitDebugLoc() {
1825 void DwarfDebug::emitDebugLocDWO() {
1836 unsigned idx = AddrPool.
getIndex(Entry.BeginSym);
1852 void DwarfDebug::emitDebugARanges() {
1857 for (
const SymbolCU &SCU : ArangeLabels) {
1858 if (SCU.Sym->isInSection()) {
1860 MCSection *Section = &SCU.Sym->getSection();
1862 SectionMap[Section].push_back(SCU);
1867 SectionMap[
nullptr].push_back(SCU);
1873 for (
auto &
I : SectionMap) {
1876 if (List.
size() < 1)
1884 Span.
Start = Cur.Sym;
1887 Spans[Cur.CU].push_back(Span);
1911 const MCSymbol *StartSym = List[0].Sym;
1912 for (
size_t n = 1, e = List.
size(); n < e; n++) {
1913 const SymbolCU &Prev = List[n - 1];
1917 if (Cur.
CU != Prev.
CU) {
1919 Span.
Start = StartSym;
1922 Spans[Prev.
CU].push_back(Span);
1935 std::vector<DwarfCompileUnit *> CUs;
1936 for (
const auto &it : Spans) {
1949 std::vector<ArangeSpan> &
List = Spans[CU];
1956 unsigned ContentSize =
1962 unsigned TupleSize = PtrSize * 2;
1968 ContentSize += Padding;
1969 ContentSize += (List.size() + 1) * TupleSize;
1977 emitSectionReference(*CU);
1994 uint64_t
Size = SymSize[Span.Start];
2022 SectionRanges[&Range.getStart()->getSection()].push_back(&Range);
2025 bool BaseIsSet =
false;
2026 for (
const auto &
P : SectionRanges) {
2033 auto *
Base = CUBase;
2034 if (!
Base &&
P.second.size() > 1 &&
2039 Base =
P.second.front()->getStart();
2040 if (DwarfVersion >= 5) {
2041 Asm->
OutStreamer->AddComment(
"DW_RLE_base_address");
2042 Asm->
OutStreamer->EmitIntValue(dwarf::DW_RLE_base_address, 1);
2047 }
else if (BaseIsSet && DwarfVersion < 5) {
2054 for (
const auto *RS :
P.second) {
2055 const MCSymbol *Begin = RS->getStart();
2056 const MCSymbol *End = RS->getEnd();
2057 assert(Begin &&
"Range without a begin symbol?");
2058 assert(End &&
"Range without an end symbol?");
2060 if (DwarfVersion >= 5) {
2062 Asm->
OutStreamer->AddComment(
"DW_RLE_offset_pair");
2063 Asm->
OutStreamer->EmitIntValue(dwarf::DW_RLE_offset_pair, 1);
2072 }
else if (DwarfVersion >= 5) {
2073 Asm->
OutStreamer->AddComment(
"DW_RLE_start_length");
2074 Asm->
OutStreamer->EmitIntValue(dwarf::DW_RLE_start_length, 1);
2085 if (DwarfVersion >= 5) {
2086 Asm->
OutStreamer->AddComment(
"DW_RLE_end_of_list");
2087 Asm->
OutStreamer->EmitIntValue(dwarf::DW_RLE_end_of_list, 1);
2124 void DwarfDebug::emitDebugRanges() {
2128 auto NoRangesPresent = [
this]() {
2130 CUMap, [](
const decltype(CUMap)::const_iterator::value_type &Pair) {
2131 return Pair.second->getRangeLists().empty();
2136 assert(NoRangesPresent() &&
"No debug ranges expected.");
2140 if (NoRangesPresent())
2155 for (
const auto &
I : CUMap) {
2170 void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes,
DwarfCompileUnit &U) {
2171 for (
auto *MN : Nodes) {
2172 if (
auto *M = dyn_cast<DIMacro>(MN))
2174 else if (
auto *
F = dyn_cast<DIMacroFile>(MN))
2175 emitMacroFile(*
F, U);
2181 void DwarfDebug::emitMacro(
DIMacro &M) {
2187 if (!Value.
empty()) {
2205 void DwarfDebug::emitDebugMacinfo() {
2213 for (
const auto &
P : CUMap) {
2214 auto &TheCU = *
P.second;
2217 auto *CUNode = cast<DICompileUnit>(
P.first);
2218 DIMacroNodeArray Macros = CUNode->getMacros();
2219 if (!Macros.empty()) {
2221 handleMacroNodes(Macros, U);
2230 void DwarfDebug::initSkeletonUnit(
const DwarfUnit &U,
DIE &Die,
2231 std::unique_ptr<DwarfCompileUnit> NewU) {
2232 NewU->addString(Die, dwarf::DW_AT_GNU_dwo_name,
2235 if (!CompilationDir.empty())
2236 NewU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
2238 addGnuPubAttributes(*NewU, Die);
2240 SkeletonHolder.addUnit(std::move(NewU));
2245 auto OwnedUnit = llvm::make_unique<DwarfCompileUnit>(
2250 NewCU.initStmtList();
2253 NewCU.addStringOffsetsStart();
2255 initSkeletonUnit(CU, NewCU.
getUnitDie(), std::move(OwnedUnit));
2262 void DwarfDebug::emitDebugInfoDWO() {
2265 InfoHolder.emitUnits(
true);
2270 void DwarfDebug::emitDebugAbbrevDWO() {
2275 void DwarfDebug::emitDebugLineDWO() {
2277 SplitTypeUnitFileTable.Emit(
2282 void DwarfDebug::emitStringOffsetsTableHeaderDWO() {
2284 InfoHolder.getStringPool().emitStringOffsetsTableHeader(
2286 InfoHolder.getStringOffsetsStartSym());
2292 void DwarfDebug::emitDebugStrDWO() {
2294 emitStringOffsetsTableHeaderDWO();
2302 void DwarfDebug::emitDebugAddr() {
2311 SplitTypeUnitFileTable.maybeSetRootFile(
2314 return &SplitTypeUnitFileTable;
2325 return Result.
high();
2334 if (!TypeUnitsUnderConstruction.empty() && AddrPool.hasBeenUsed())
2337 auto Ins = TypeSignatures.insert(std::make_pair(CTy, 0));
2343 bool TopLevelType = TypeUnitsUnderConstruction.empty();
2344 AddrPool.resetUsedFlag();
2346 auto OwnedUnit = llvm::make_unique<DwarfTypeUnit>(CU,
Asm,
this, &InfoHolder,
2347 getDwoLineTable(CU));
2350 TypeUnitsUnderConstruction.emplace_back(std::move(OwnedUnit), CTy);
2352 NewTU.addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
2356 NewTU.setTypeSignature(Signature);
2357 Ins.first->second = Signature;
2360 NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesDWOSection());
2362 NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesSection(Signature));
2364 CU.applyStmtList(UnitDie);
2370 NewTU.addStringOffsetsStart();
2372 NewTU.setType(NewTU.createTypeDIE(CTy));
2375 auto TypeUnitsToAdd = std::move(TypeUnitsUnderConstruction);
2376 TypeUnitsUnderConstruction.clear();
2380 if (AddrPool.hasBeenUsed()) {
2385 for (
const auto &TU : TypeUnitsToAdd)
2386 TypeSignatures.erase(TU.second);
2392 CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
2398 for (
auto &TU : TypeUnitsToAdd) {
2399 InfoHolder.computeSizeAndOffsetsForUnit(TU.first.get());
2403 CU.addDIETypeSignature(RefDie, Signature);
2410 template <
typename DataT>
2425 AccelDebugNames.addName(Ref, Die);
2435 addAccelNameImpl(AccelNames, Name, Die);
2441 addAccelNameImpl(AccelObjC, Name, Die);
2445 addAccelNameImpl(AccelNamespace, Name, Die);
2449 addAccelNameImpl(AccelTypes, Name, Die);
const StringMap< const DIE * > & getGlobalTypes() const
const DICompileUnit * getCUNode() const
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry)
Emit the location for a debug loc entry, including the size header.
debug_compile_units_iterator debug_compile_units_end() const
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
const SmallVectorImpl< RangeSpanList > & getRangeLists() const
getRangeLists - Get the vector of range lists.
An object containing the capability of hashing and adding hash attributes onto a DIE.
const DILocalScope * getScopeNode() const
Builder for DebugLocStream lists.
MCSection * getDwarfStrOffSection() const
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
SectionKind getKind() const
static cl::opt< bool > SplitDwarfCrossCuReferences("split-dwarf-cross-cu-references", cl::Hidden, cl::desc("Enable cross-cu references in DWO files"), cl::init(false))
void addUnit(std::unique_ptr< DwarfCompileUnit > U)
Add a unit to the list of CUs.
static dwarf::PubIndexEntryDescriptor computeIndexValue(DwarfUnit *CU, const DIE *Die)
computeIndexValue - Compute the gdb index value for the DIE and CU.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)
Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.
void addMMIEntry(const DbgVariable &V)
static cl::opt< bool > DisableDebugInfoPrinting("disable-debug-info-print", cl::Hidden, cl::desc("Disable debug info printing"))
MCSection * getDwarfAccelObjCSection() const
This struct describes location entries emitted in the .debug_loc section.
const MCSymbol * getBaseAddress() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
bool hasDebugInfo() const
Returns true if valid debug info is present.
#define DWARF2_FLAG_PROLOGUE_END
MCSection * getDwarfStrSection() const
MCTargetOptions MCOptions
Machine level options.
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
static SmallVectorImpl< DwarfCompileUnit::GlobalExpr > & sortGlobalExprs(SmallVectorImpl< DwarfCompileUnit::GlobalExpr > &GVEs)
Sort and unique GVEs by comparing their fragment offset.
Compute iterated dominance frontiers using a linear time algorithm.
bool isAbstractScope() const
void addUnsignedConstant(uint64_t Value)
Emit an unsigned constant.
unsigned getRuntimeVersion() const
MCSection * getDwarfLocSection() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
void setMemoryLocationKind()
Lock this down to become a memory location description.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
BufferByteStreamer getStreamer()
Implements a dense probed hash-table based set.
const DIType * getType() const
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
std::string SplitDwarfFile
uint16_t getDwarfVersion() const
unsigned getReg() const
getReg - Returns the register number.
MCSection * getDwarfAccelNamesSection() const
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
static cl::opt< AccelTableKind > AccelTables("accel-tables", cl::Hidden, cl::desc("Output dwarf accelerator tables."), cl::values(clEnumValN(AccelTableKind::Default, "Default", "Default for platform"), clEnumValN(AccelTableKind::None, "Disable", "Disabled."), clEnumValN(AccelTableKind::Apple, "Apple", "Apple"), clEnumValN(AccelTableKind::Dwarf, "Dwarf", "DWARF")), cl::init(AccelTableKind::Default))
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
MD5::MD5Result * getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
SmallVectorImpl< InsnRange > & getRanges()
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null, or not exclusively derived from constant.
unsigned getDebugSectionOffset() const
static cl::opt< bool > NoDwarfRangesSection("no-dwarf-ranges-section", cl::Hidden, cl::desc("Disable emission .debug_ranges section."), cl::init(false))
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
This class implements a map that also provides access to all stored values in a deterministic order...
uint64_t getDWOId() const
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
void addName(DwarfStringPoolEntryRef Name, Types &&... Args)
static const char *const DbgTimerName
unsigned const TargetRegisterInfo * TRI
MachineFunction * MF
The current machine function.
MCSection * getDwarfARangesSection() const
StringRef getProducer() const
bool isMetaInstruction() const
Return true if this instruction doesn't produce any output in the form of executable instructions...
LexicalScope - This class is used to track scope information.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
DIE::value_iterator addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
const MachineInstr * CurMI
If nonnull, stores the current machine instruction we're processing.
VariableDbgInfoMapTy & getVariableDbgInfo()
Tagged DWARF-like metadata node.
DebuggerKind
Identify a debugger for "tuning" the debug info.
void addAccelNamespace(StringRef Name, const DIE &Die)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
void initializeDbgValue(const MachineInstr *DbgValue)
Initialize from a DBG_VALUE instruction.
static const char *const DbgTimerDescription
static cl::opt< bool > GenerateARangeSection("generate-arange-section", cl::Hidden, cl::desc("Generate dwarf aranges"), cl::init(false))
MCSection * getDwarfRnglistsSection() const
MCSection * getDwarfPubNamesSection() const
virtual void EmitULEB128(uint64_t DWord, const Twine &Comment="")=0
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)
DIScope * getScope() const
static MCSymbol * emitRnglistsTableHeader(AsmPrinter *Asm, DwarfFile &Holder)
MCSymbol * getRnglistsTableBaseSym() const
DebugLoc PrevInstLoc
Previous instruction's location information.
StringRef getSplitDebugFilename() const
#define DWARF2_FLAG_IS_STMT
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DebugLocEntry::Value &Value, DwarfExpression &DwarfExpr)
StringRef getFlags() const
MCSection * getDwarfMacinfoSection() const
LexicalScope * getOrCreateAbstractScope(const DILocalScope *Scope)
getOrCreateAbstractScope - Find or create an abstract lexical scope.
MCSection * getDwarfLocDWOSection() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
DbgValueHistoryMap DbgValues
History of DBG_VALUE and clobber instructions for each user variable.
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
This class is basically a combination of TimeRegion and Timer.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to...
String pool entry reference.
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
The access may reference the value stored in memory.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
static StringRef getName(Value *V)
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null. ...
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
void setDWOId(uint64_t DwoId)
virtual void EmitInt8(uint8_t Byte, const Twine &Comment="")=0
DenseMap< LexicalScope *, ScopeVars > & getScopeVariables()
Holds a DIExpression and keeps track of how many operands have been consumed so far.
uint64_t computeCUSignature(StringRef DWOName, const DIE &Die)
Computes the CU signature.
AccelTableKind
The kind of accelerator tables we should emit.
#define clEnumVal(ENUMVAL, DESC)
StringRef getFilename() const
DwarfExpression implementation for .debug_loc entries.
This file implements a class to represent arbitrary precision integral constant values and operations...
DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
const SmallVectorImpl< RangeSpan > & getRanges() const
Describes an entry of the various gnu_pub* debug sections.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
unsigned getUniqueID() const
bool isConstantFP() const
MCSymbol * getFunctionBegin() const
static bool validThroughout(LexicalScopes &LScopes, const MachineInstr *DbgValue, const MachineInstr *RangeEnd)
Determine whether a singular DBG_VALUE is valid for the entirety of its enclosing lexical scope...
DenseMap< const MDNode *, DIE * > & getAbstractSPDies()
This class is used to track local variable information.
void setBaseAddress(const MCSymbol *Base)
static AccelTableKind computeAccelTableKind(unsigned DwarfVersion, bool GenerateTypeUnits, DebuggerKind Tuning, const Triple &TT)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
DIMacroNodeArray getElements() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
bool MergeValues(const DebugLocEntry &Next)
If this and Next are describing different pieces of the same variable, merge them by appending Next's...
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
debug_compile_units_iterator debug_compile_units_begin() const
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits()
static cl::opt< DefaultOnOff > DwarfInlinedStrings("dwarf-inlined-strings", cl::Hidden, cl::desc("Use inlined strings rather than string section."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
MCSection * getDwarfAccelTypesSection() const
DIE & addChild(DIE *Child)
Add a child to the DIE.
static cl::opt< bool > GenerateDwarfTypeUnits("generate-type-units", cl::Hidden, cl::desc("Generate DWARF4 type units."), cl::init(false))
void EmitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
static cl::opt< bool > UseDwarfRangesBaseAddressSpecifier("use-dwarf-ranges-base-address-specifier", cl::Hidden, cl::desc("Use base address specifiers in debug_ranges"), cl::init(false))
MCSection * getDwarfAbbrevSection() const
const DIExpression * Expr
void resolve()
Resolve a unique, unresolved node.
MCSection * getDwarfAbbrevDWOSection() const
LexicalScope * findAbstractScope(const DILocalScope *N)
findAbstractScope - Find an abstract scope or return null.
static void forBothCUs(DwarfCompileUnit &CU, Func F)
MCSymbol * getStringOffsetsStartSym() const
MCSection * getDwarfGnuPubTypesSection() const
DebuggerKind DebuggerTuning
Which debugger to tune for.
This dwarf writer support class manages information associated with a source file.
DwarfStringPool & getStringPool()
Returns the string pool.
initializer< Ty > init(const Ty &Val)
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
void endModule() override
Emit all Dwarf sections that should come after the content.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MCSymbol * getSym() const
const MachineBasicBlock * PrevInstBB
const MCAsmInfo * MAI
Target Asm Printer information.
static void getObjCClassCategory(StringRef In, StringRef &Class, StringRef &Category)
static cl::opt< LinkageNameOption > DwarfLinkageNames("dwarf-linkage-names", cl::Hidden, cl::desc("Which DWARF linkage-name attributes to emit."), cl::values(clEnumValN(DefaultLinkageNames, "Default", "Default for platform"), clEnumValN(AllLinkageNames, "All", "All"), clEnumValN(AbstractLinkageNames, "Abstract", "Abstract subprograms")), cl::init(DefaultLinkageNames))
MCSection * getDwarfAddrSection() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
DISubprogram * getSubprogram() const
Get the attached subprogram.
const DILocation * getInlinedAt() const
static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
const DIExpression * getExpression() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
A structured debug information entry.
AsmPrinter * Asm
Target of debug info emission.
std::pair< iterator, bool > insert(const ValueT &V)
ArrayRef< char > getBytes(const Entry &E) const
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
DIImportedEntityArray getImportedEntities() const
MCSection * getDwarfLineDWOSection() const
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
void addAccelType(StringRef Name, const DIE &Die, char Flags)
static cl::opt< DefaultOnOff > UnknownLocations("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::values(clEnumVal(Default, "At top of block or after label"), clEnumVal(Enable, "In all cases"), clEnumVal(Disable, "Never")), cl::init(Default))
DwarfDebug(AsmPrinter *A, Module *M)
void EmitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
const Triple & getTargetTriple() const
void computeSizeAndOffsets()
Compute the size and offset of all the DIEs.
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
ArrayRef< Entry > getEntries(const List &L) const
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var)
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
GDBIndexEntryLinkage Linkage
MDNode * getScope() const
A pair of GlobalVariable and DIExpression.
void emitDWARF5AccelTable(AsmPrinter *Asm, AccelTable< DWARF5AccelTableData > &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit >> CUs)
Helper used to pair up a symbol and its DWARF compile unit.
StringRef getDirectory() const
iterator erase(const_iterator CI)
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
bool hasDwarfPubSections() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
StringRef OperationEncodingString(unsigned Encoding)
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
static const char *const DWARFGroupDescription
Triple - Helper class for working with autoconf configuration names.
ArrayRef< FrameIndexExpr > getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
An imported module (C++ using directive or similar).
bool useLocSection() const
Returns whether .debug_loc section should be emitted.
void sort(IteratorTy Start, IteratorTy End)
DIE * constructImportedEntityDIE(const DIImportedEntity *Module)
Construct import_module DIE.
const APFloat & getValueAPF() const
void addExpression(DIExpressionCursor &&Expr, unsigned FragmentOffsetInBits=0)
Emit all remaining operations in the DIExpressionCursor.
uint16_t getLanguage() const
SmallVector< RangeSpan, 2 > takeRanges()
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
static DebugLoc findPrologueEndLoc(const MachineFunction *MF)
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
MCSymbol * getMacroLabelBegin() const
static bool hasObjCCategory(StringRef Name)
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
const StringMap< const DIE * > & getGlobalNames() const
void setDebugInfoAvailability(bool avail)
StringRef getName() const
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
bool isDebugValue() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual void EmitSLEB128(uint64_t DWord, const Twine &Comment="")=0
Module.h This file contains the declarations for the Module class.
void beginModule()
Emit all Dwarf sections that should come prior to the content.
static ManagedStatic< CodeViewErrorCategory > Category
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
bool getGnuPubnames() const
MCSymbol * getBeginSymbol()
void finishSubprogramDefinition(const DISubprogram *SP)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
MCSection * getDwarfInfoSection() const
bool useAppleExtensionAttributes() const
void emitInt32(int Value) const
Emit a long directive and value.
MCSection * getDwarfDebugNamesSection() const
MCSection * getDwarfStrOffDWOSection() const
void addAccelName(StringRef Name, const DIE &Die)
MCSymbol * getFunctionEnd() const
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry)
Emit an entry for the debug loc section.
void addRnglistsBase()
Add the DW_AT_rnglists_base attribute to the unit DIE.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void emitRangeList(AsmPrinter *Asm, DwarfCompileUnit *CU, const RangeSpanList &List)
Emit a single range list. We handle both DWARF v5 and earlier.
unsigned getSourceLanguage() const
static cl::opt< DefaultOnOff > DwarfSectionsAsReferences("dwarf-sections-as-references", cl::Hidden, cl::desc("Use sections+offset as references rather than labels."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
This file contains constants used for implementing Dwarf debug support.
Class for arbitrary precision integers.
ArrayRef< std::string > getComments(const Entry &E) const
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
MCSection * getDwarfPubTypesSection() const
bool isBlockByrefStruct() const
DebugLoc PrologEndLoc
This location indicates end of function prologue and beginning of function body.
const SmallVectorImpl< RangeSpan > & getRanges() const
getRanges - Get the list of ranges for this unit.
dwarf::Tag getTag() const
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
A single location or constant.
const MachineBasicBlock * getParent() const
void finalize(const AsmPrinter &AP, DebugLocStream::ListBuilder &List, const DIBasicType *BT)
Lower this entry into a DWARF expression.
void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, MCSymbol *StartSym)
DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
MCSection * getDwarfStrDWOSection() const
Representation of each machine instruction.
static StringRef getObjCMethodName(StringRef In)
bool getSplitDebugInlining() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
unsigned getEncoding() const
EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
void EmitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const
Emit something like ".long Label + Offset".
DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
Get or create global variable DIE.
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
LLVM_NODISCARD bool empty() const
bool useRangesSection() const
Returns whether ranges section should be emitted.
bool isBlockByrefVariable() const
void endFunctionImpl(const MachineFunction *MF) override
Gather and emit post-function debug information.
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module's llvm.dbg.cu named metadata node and...
bool shareAcrossDWOCUs() const
MCSection * getDwarfGnuPubNamesSection() const
Optional< StringRef > getSource() const
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Base class for debug information backends.
static uint64_t makeTypeSignature(StringRef Identifier)
Perform an MD5 checksum of Identifier and return the lower 64 bits.
unsigned getMacinfoType() const
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
StringRef getValue() const
DwarfCompileUnit * getSkeleton() const
void skippedNonDebugFunction() override
const Module * getModule() const
void emitStrings(MCSection *StrSection, MCSection *OffsetSection=nullptr, bool UseRelativeOffsets=false)
Emit all of the strings to the section given.
static cl::opt< bool > NoDwarfPubSections("no-dwarf-pub-sections", cl::Hidden, cl::desc("Disable emission of DWARF pub sections."), cl::init(false))
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
uint16_t getDwarfVersion() const
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
ArrayRef< LexicalScope * > getAbstractScopesList() const
getAbstractScopesList - Return a reference to list of abstract scopes.
void addSubprogramNames(const DISubprogram *SP, DIE &Die)
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
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...
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection * getDwarfAccelNamespaceSection() const
static const char *const DWARFGroupName
void emitInt8(int Value) const
Emit a byte directive and value.
void finishVariableDefinition(const DbgVariable &Var)
LLVM Value Representation.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr) const
Emit the specified unsigned leb128 value.
uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
DbgVariable * getExistingAbstractVariable(InlinedVariable IV, const DILocalVariable *&Cleansed)
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void emitAbbrevs(MCSection *)
Emit a set of abbreviations to the specific section.
void addSignedConstant(int64_t Value)
Emit a signed constant.
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, Optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
MachineModuleInfo * MMI
Collected machine module information.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
iterator_range< global_iterator > globals()
void addAccelObjC(StringRef Name, const DIE &Die)
MachineLocation getLoc() const
StringRef - Represent a constant reference to a string, i.e.
APInt bitcastToAPInt() const
void emitUnits(bool UseOffsets)
Emit all of the units to the section listed with the given abbreviation section.
MCSection * getDwarfRangesSection() const
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
static bool isObjCClass(StringRef Name)
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
void createAbstractVariable(const DILocalVariable *Var, LexicalScope *Scope)
Builder for DebugLocStream entries.
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
const MachineOperand & getOperand(unsigned i) const
bool isFragment() const
Return whether this is a piece of an aggregate variable.
const ConstantInt * getCImm() const
MCSymbol * getLabelBegin() const
void addValues(ArrayRef< DebugLocEntry::Value > Vals)
MCSymbol * createTempSymbol(const Twine &Name) const
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, unsigned MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
const ConstantFP * getConstantFP() const
ArrayRef< List > getLists() const
bool empty()
empty - Return true if there is any lexical scope information available.
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.
void emitInt16(int Value) const
Emit a short directive and value.
StringRef getName() const
Basic type, like 'int' or 'float'.
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.