llvm.org GIT mirror llvm / 76221cb
IR: Represent -ggnu-pubnames with a flag on the DICompileUnit. This allows the flag to be persisted through to LTO. Differential Revision: https://reviews.llvm.org/D37655 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313078 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 2 years ago
20 changed file(s) with 423 addition(s) and 411 deletion(s). Raw diff Collapse all Expand all
111111 /// \param SplitDebugInlining Whether to emit inline debug info.
112112 /// \param DebugInfoForProfiling Whether to emit extra debug info for
113113 /// profile collection.
114 /// \param GnuPubnames Whether to emit .debug_gnu_pubnames section instead
115 /// of .debug_pubnames.
114116 DICompileUnit *
115117 createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
116118 bool isOptimized, StringRef Flags, unsigned RV,
118120 DICompileUnit::DebugEmissionKind Kind =
119121 DICompileUnit::DebugEmissionKind::FullDebug,
120122 uint64_t DWOId = 0, bool SplitDebugInlining = true,
121 bool DebugInfoForProfiling = false);
123 bool DebugInfoForProfiling = false,
124 bool GnuPubnames = false);
122125
123126 /// Create a file descriptor to hold debugging information for a file.
124127 /// \param Filename File name.
10671067 uint64_t DWOId;
10681068 bool SplitDebugInlining;
10691069 bool DebugInfoForProfiling;
1070 bool GnuPubnames;
10701071
10711072 DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
10721073 bool IsOptimized, unsigned RuntimeVersion,
10731074 unsigned EmissionKind, uint64_t DWOId, bool SplitDebugInlining,
1074 bool DebugInfoForProfiling, ArrayRef Ops)
1075 bool DebugInfoForProfiling, bool GnuPubnames, ArrayRef Ops)
10751076 : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
10761077 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
10771078 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind),
10781079 DWOId(DWOId), SplitDebugInlining(SplitDebugInlining),
1079 DebugInfoForProfiling(DebugInfoForProfiling) {
1080 DebugInfoForProfiling(DebugInfoForProfiling), GnuPubnames(GnuPubnames) {
10801081 assert(Storage != Uniqued);
10811082 }
10821083 ~DICompileUnit() = default;
10901091 DIGlobalVariableExpressionArray GlobalVariables,
10911092 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
10921093 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1093 StorageType Storage, bool ShouldCreate = true) {
1094 return getImpl(Context, SourceLanguage, File,
1095 getCanonicalMDString(Context, Producer), IsOptimized,
1096 getCanonicalMDString(Context, Flags), RuntimeVersion,
1097 getCanonicalMDString(Context, SplitDebugFilename),
1098 EmissionKind, EnumTypes.get(), RetainedTypes.get(),
1099 GlobalVariables.get(), ImportedEntities.get(), Macros.get(),
1100 DWOId, SplitDebugInlining, DebugInfoForProfiling, Storage,
1101 ShouldCreate);
1094 bool GnuPubnames, StorageType Storage, bool ShouldCreate = true) {
1095 return getImpl(
1096 Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
1097 IsOptimized, getCanonicalMDString(Context, Flags), RuntimeVersion,
1098 getCanonicalMDString(Context, SplitDebugFilename), EmissionKind,
1099 EnumTypes.get(), RetainedTypes.get(), GlobalVariables.get(),
1100 ImportedEntities.get(), Macros.get(), DWOId, SplitDebugInlining,
1101 DebugInfoForProfiling, GnuPubnames, Storage, ShouldCreate);
11021102 }
11031103 static DICompileUnit *
11041104 getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
11071107 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
11081108 Metadata *GlobalVariables, Metadata *ImportedEntities,
11091109 Metadata *Macros, uint64_t DWOId, bool SplitDebugInlining,
1110 bool DebugInfoForProfiling, StorageType Storage,
1110 bool DebugInfoForProfiling, bool GnuPubnames, StorageType Storage,
11111111 bool ShouldCreate = true);
11121112
11131113 TempDICompileUnit cloneImpl() const {
11171117 getEmissionKind(), getEnumTypes(), getRetainedTypes(),
11181118 getGlobalVariables(), getImportedEntities(),
11191119 getMacros(), DWOId, getSplitDebugInlining(),
1120 getDebugInfoForProfiling());
1120 getDebugInfoForProfiling(), getGnuPubnames());
11211121 }
11221122
11231123 public:
11321132 DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
11331133 DIGlobalVariableExpressionArray GlobalVariables,
11341134 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
1135 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling),
1135 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1136 bool GnuPubnames),
11361137 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
11371138 SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
11381139 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
1139 DebugInfoForProfiling))
1140 DebugInfoForProfiling, GnuPubnames))
11401141 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
11411142 DICompileUnit,
11421143 (unsigned SourceLanguage, Metadata *File, MDString *Producer,
11441145 MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,
11451146 Metadata *RetainedTypes, Metadata *GlobalVariables,
11461147 Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId,
1147 bool SplitDebugInlining, bool DebugInfoForProfiling),
1148 bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames),
11481149 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
11491150 SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
11501151 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
1151 DebugInfoForProfiling))
1152 DebugInfoForProfiling, GnuPubnames))
11521153
11531154 TempDICompileUnit clone() const { return cloneImpl(); }
11541155
11591160 return (DebugEmissionKind)EmissionKind;
11601161 }
11611162 bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
1163 bool getGnuPubnames() const { return GnuPubnames; }
11621164 StringRef getProducer() const { return getStringOperand(1); }
11631165 StringRef getFlags() const { return getStringOperand(2); }
11641166 StringRef getSplitDebugFilename() const { return getStringOperand(3); }
40984098 OPTIONAL(macros, MDField, ); \
40994099 OPTIONAL(dwoId, MDUnsignedField, ); \
41004100 OPTIONAL(splitDebugInlining, MDBoolField, = true); \
4101 OPTIONAL(debugInfoForProfiling, MDBoolField, = false);
4101 OPTIONAL(debugInfoForProfiling, MDBoolField, = false); \
4102 OPTIONAL(gnuPubnames, MDBoolField, = false);
41024103 PARSE_MD_FIELDS();
41034104 #undef VISIT_MD_FIELDS
41044105
41064107 Context, language.Val, file.Val, producer.Val, isOptimized.Val, flags.Val,
41074108 runtimeVersion.Val, splitDebugFilename.Val, emissionKind.Val, enums.Val,
41084109 retainedTypes.Val, globals.Val, imports.Val, macros.Val, dwoId.Val,
4109 splitDebugInlining.Val, debugInfoForProfiling.Val);
4110 splitDebugInlining.Val, debugInfoForProfiling.Val, gnuPubnames.Val);
41104111 return false;
41114112 }
41124113
13541354 break;
13551355 }
13561356 case bitc::METADATA_COMPILE_UNIT: {
1357 if (Record.size() < 14 || Record.size() > 18)
1357 if (Record.size() < 14 || Record.size() > 19)
13581358 return error("Invalid record");
13591359
13601360 // Ignore Record[0], which indicates whether this compile unit is
13681368 Record.size() <= 15 ? nullptr : getMDOrNull(Record[15]),
13691369 Record.size() <= 14 ? 0 : Record[14],
13701370 Record.size() <= 16 ? true : Record[16],
1371 Record.size() <= 17 ? false : Record[17]);
1371 Record.size() <= 17 ? false : Record[17],
1372 Record.size() <= 18 ? false : Record[18]);
13721373
13731374 MetadataList.assignValue(CU, NextMetadataNo);
13741375 NextMetadataNo++;
15541554 Record.push_back(VE.getMetadataOrNullID(N->getMacros().get()));
15551555 Record.push_back(N->getSplitDebugInlining());
15561556 Record.push_back(N->getDebugInfoForProfiling());
1557 Record.push_back(N->getGnuPubnames());
15571558
15581559 Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev);
15591560 Record.clear();
5050 #include
5151
5252 using namespace llvm;
53
54 enum DefaultOnOff { Default, Enable, Disable };
55
56 static cl::opt
57 DwarfPubSections("generate-dwarf-pub-sections", cl::Hidden,
58 cl::desc("Generate DWARF pubnames and pubtypes sections"),
59 cl::values(clEnumVal(Default, "Default for platform"),
60 clEnumVal(Enable, "Enabled"),
61 clEnumVal(Disable, "Disabled")),
62 cl::init(Default));
5363
5464 DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node,
5565 AsmPrinter *A, DwarfDebug *DW,
754764 DwarfUnit::emitCommonHeader(UseOffsets, UT);
755765 }
756766
767 bool DwarfCompileUnit::hasDwarfPubSections() const {
768 // Opting in to GNU Pubnames/types overrides the default to ensure these are
769 // generated for things like Gold's gdb_index generation.
770 if (CUNode->getGnuPubnames())
771 return true;
772
773 if (DwarfPubSections == Default)
774 return DD->tuneForGDB() && !includeMinimalInlineScopes();
775
776 return DwarfPubSections == Enable;
777 }
778
757779 /// addGlobalName - Add a new global name to the compile unit.
758780 void DwarfCompileUnit::addGlobalName(StringRef Name, const DIE &Die,
759781 const DIScope *Context) {
760 if (!DD->hasDwarfPubSections(includeMinimalInlineScopes()))
782 if (!hasDwarfPubSections())
761783 return;
762784 std::string FullName = getParentContextString(Context) + Name.str();
763785 GlobalNames[FullName] = &Die;
765787
766788 void DwarfCompileUnit::addGlobalNameForTypeUnit(StringRef Name,
767789 const DIScope *Context) {
768 if (!DD->hasDwarfPubSections(includeMinimalInlineScopes()))
790 if (!hasDwarfPubSections())
769791 return;
770792 std::string FullName = getParentContextString(Context) + Name.str();
771793 // Insert, allowing the entry to remain as-is if it's already present
778800 /// Add a new global type to the unit.
779801 void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
780802 const DIScope *Context) {
781 if (!DD->hasDwarfPubSections(includeMinimalInlineScopes()))
803 if (!hasDwarfPubSections())
782804 return;
783805 std::string FullName = getParentContextString(Context) + Ty->getName().str();
784806 GlobalTypes[FullName] = &Die;
786808
787809 void DwarfCompileUnit::addGlobalTypeUnitType(const DIType *Ty,
788810 const DIScope *Context) {
789 if (!DD->hasDwarfPubSections(includeMinimalInlineScopes()))
811 if (!hasDwarfPubSections())
790812 return;
791813 std::string FullName = getParentContextString(Context) + Ty->getName().str();
792814 // Insert, allowing the entry to remain as-is if it's already present
288288
289289 void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
290290 const MCSymbol *getBaseAddress() const { return BaseAddress; }
291
292 bool hasDwarfPubSections() const;
291293 };
292294
293295 } // end namespace llvm
8888 "use-dwarf-ranges-base-address-specifier", cl::Hidden,
8989 cl::desc("Use base address specifiers in debug_ranges"), cl::init(false));
9090
91 static cl::opt
92 GenerateGnuPubSections("generate-gnu-dwarf-pub-sections", cl::Hidden,
93 cl::desc("Generate GNU-style pubnames and pubtypes"),
94 cl::init(false));
95
9691 static cl::opt GenerateARangeSection("generate-arange-section",
9792 cl::Hidden,
9893 cl::desc("Generate dwarf aranges"),
114109 static cl::opt
115110 DwarfAccelTables("dwarf-accel-tables", cl::Hidden,
116111 cl::desc("Output prototype dwarf accelerator tables."),
117 cl::values(clEnumVal(Default, "Default for platform"),
118 clEnumVal(Enable, "Enabled"),
119 clEnumVal(Disable, "Disabled")),
120 cl::init(Default));
121
122 static cl::opt
123 DwarfPubSections("generate-dwarf-pub-sections", cl::Hidden,
124 cl::desc("Generate DWARF pubnames and pubtypes sections"),
125112 cl::values(clEnumVal(Default, "Default for platform"),
126113 clEnumVal(Enable, "Enabled"),
127114 clEnumVal(Disable, "Disabled")),
413400 }
414401 }
415402
416 bool DwarfDebug::hasDwarfPubSections(bool includeMinimalInlineScopes) const {
417 // Opting in to GNU Pubnames/types overrides the default to ensure these are
418 // generated for things like Gold's gdb_index generation.
419 if (GenerateGnuPubSections)
420 return true;
421
422 if (DwarfPubSections == Default)
423 return tuneForGDB() && !includeMinimalInlineScopes;
424
425 return DwarfPubSections == Enable;
426 }
427
428403 void DwarfDebug::addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const {
429 if (!hasDwarfPubSections(U.includeMinimalInlineScopes()))
404 if (!U.hasDwarfPubSections())
430405 return;
431406
432407 U.addFlag(D, dwarf::DW_AT_GNU_pubnames);
791766 }
792767
793768 // Emit the pubnames and pubtypes sections if requested.
794 // The condition is optimistically correct - any CU not using GMLT (&
795 // implicit/default pubnames state) might still have pubnames.
796 if (hasDwarfPubSections(/* gmlt */ false)) {
797 emitDebugPubNames(GenerateGnuPubSections);
798 emitDebugPubTypes(GenerateGnuPubSections);
799 }
769 emitDebugPubSections();
800770
801771 // clean up.
802772 // FIXME: AbstractVariables.clear();
14921462 }
14931463 }
14941464
1495 /// emitDebugPubNames - Emit visible names into a debug pubnames section.
1496 void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
1497 MCSection *PSec = GnuStyle
1498 ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection()
1499 : Asm->getObjFileLowering().getDwarfPubNamesSection();
1500
1501 emitDebugPubSection(GnuStyle, PSec, "Names",
1502 &DwarfCompileUnit::getGlobalNames);
1503 }
1504
1505 void DwarfDebug::emitDebugPubSection(
1506 bool GnuStyle, MCSection *PSec, StringRef Name,
1507 const StringMap &(DwarfCompileUnit::*Accessor)() const) {
1465 /// emitDebugPubSections - Emit visible names and types into debug pubnames and
1466 /// pubtypes sections.
1467 void DwarfDebug::emitDebugPubSections() {
15081468 for (const auto &NU : CUMap) {
15091469 DwarfCompileUnit *TheU = NU.second;
1510
1511 const auto &Globals = (TheU->*Accessor)();
1512
1513 if (!hasDwarfPubSections(TheU->includeMinimalInlineScopes()))
1470 if (!TheU->hasDwarfPubSections())
15141471 continue;
15151472
1516 if (auto *Skeleton = TheU->getSkeleton())
1517 TheU = Skeleton;
1518
1519 // Start the dwarf pubnames section.
1520 Asm->OutStreamer->SwitchSection(PSec);
1521
1522 // Emit the header.
1523 Asm->OutStreamer->AddComment("Length of Public " + Name + " Info");
1524 MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
1525 MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
1526 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
1527
1528 Asm->OutStreamer->EmitLabel(BeginLabel);
1529
1530 Asm->OutStreamer->AddComment("DWARF Version");
1531 Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION);
1532
1533 Asm->OutStreamer->AddComment("Offset of Compilation Unit Info");
1534 Asm->emitDwarfSymbolReference(TheU->getLabelBegin());
1535
1536 Asm->OutStreamer->AddComment("Compilation Unit Length");
1537 Asm->EmitInt32(TheU->getLength());
1538
1539 // Emit the pubnames for this compilation unit.
1540 for (const auto &GI : Globals) {
1541 const char *Name = GI.getKeyData();
1542 const DIE *Entity = GI.second;
1543
1544 Asm->OutStreamer->AddComment("DIE offset");
1545 Asm->EmitInt32(Entity->getOffset());
1546
1547 if (GnuStyle) {
1548 dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
1549 Asm->OutStreamer->AddComment(
1550 Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
1551 dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
1552 Asm->EmitInt8(Desc.toBits());
1553 }
1554
1555 Asm->OutStreamer->AddComment("External Name");
1556 Asm->OutStreamer->EmitBytes(StringRef(Name, GI.getKeyLength() + 1));
1557 }
1558
1559 Asm->OutStreamer->AddComment("End Mark");
1560 Asm->EmitInt32(0);
1561 Asm->OutStreamer->EmitLabel(EndLabel);
1562 }
1563 }
1564
1565 void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
1566 MCSection *PSec = GnuStyle
1567 ? Asm->getObjFileLowering().getDwarfGnuPubTypesSection()
1568 : Asm->getObjFileLowering().getDwarfPubTypesSection();
1569
1570 emitDebugPubSection(GnuStyle, PSec, "Types",
1571 &DwarfCompileUnit::getGlobalTypes);
1473 bool GnuStyle = TheU->getCUNode()->getGnuPubnames();
1474
1475 Asm->OutStreamer->SwitchSection(
1476 GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection()
1477 : Asm->getObjFileLowering().getDwarfPubNamesSection());
1478 emitDebugPubSection(GnuStyle, "Names", TheU, TheU->getGlobalNames());
1479
1480 Asm->OutStreamer->SwitchSection(
1481 GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubTypesSection()
1482 : Asm->getObjFileLowering().getDwarfPubTypesSection());
1483 emitDebugPubSection(GnuStyle, "Types", TheU, TheU->getGlobalTypes());
1484 }
1485 }
1486
1487 void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
1488 DwarfCompileUnit *TheU,
1489 const StringMap &Globals) {
1490 if (auto *Skeleton = TheU->getSkeleton())
1491 TheU = Skeleton;
1492
1493 // Emit the header.
1494 Asm->OutStreamer->AddComment("Length of Public " + Name + " Info");
1495 MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
1496 MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
1497 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
1498
1499 Asm->OutStreamer->EmitLabel(BeginLabel);
1500
1501 Asm->OutStreamer->AddComment("DWARF Version");
1502 Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION);
1503
1504 Asm->OutStreamer->AddComment("Offset of Compilation Unit Info");
1505 Asm->emitDwarfSymbolReference(TheU->getLabelBegin());
1506
1507 Asm->OutStreamer->AddComment("Compilation Unit Length");
1508 Asm->EmitInt32(TheU->getLength());
1509
1510 // Emit the pubnames for this compilation unit.
1511 for (const auto &GI : Globals) {
1512 const char *Name = GI.getKeyData();
1513 const DIE *Entity = GI.second;
1514
1515 Asm->OutStreamer->AddComment("DIE offset");
1516 Asm->EmitInt32(Entity->getOffset());
1517
1518 if (GnuStyle) {
1519 dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
1520 Asm->OutStreamer->AddComment(
1521 Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
1522 dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
1523 Asm->EmitInt8(Desc.toBits());
1524 }
1525
1526 Asm->OutStreamer->AddComment("External Name");
1527 Asm->OutStreamer->EmitBytes(StringRef(Name, GI.getKeyLength() + 1));
1528 }
1529
1530 Asm->OutStreamer->AddComment("End Mark");
1531 Asm->EmitInt32(0);
1532 Asm->OutStreamer->EmitLabel(EndLabel);
15721533 }
15731534
15741535 /// Emit null-terminated strings into a debug str section.
313313 // Identify a debugger for "tuning" the debug info.
314314 DebuggerKind DebuggerTuning = DebuggerKind::Default;
315315
316 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
317
318 const SmallVectorImpl> &getUnits() {
319 return InfoHolder.getUnits();
320 }
321
322 using InlinedVariable = DbgValueHistoryMap::InlinedVariable;
323
324 void ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable Var,
325 const MDNode *Scope);
326 void ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU, InlinedVariable Var,
327 const MDNode *Scope);
328
329 DbgVariable *createConcreteVariable(DwarfCompileUnit &TheCU,
330 LexicalScope &Scope, InlinedVariable IV);
331
332 /// Construct a DIE for this abstract scope.
333 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
334
335 void finishVariableDefinitions();
336
337 void finishSubprogramDefinitions();
338
339 /// Finish off debug information after all functions have been
340 /// processed.
341 void finalizeModuleInfo();
342
343 /// Emit the debug info section.
344 void emitDebugInfo();
345
346 /// Emit the abbreviation section.
347 void emitAbbreviations();
348
349 /// Emit a specified accelerator table.
350 void emitAccel(DwarfAccelTable &Accel, MCSection *Section,
351 StringRef TableName);
352
353 /// Emit visible names into a hashed accelerator table section.
354 void emitAccelNames();
355
356 /// Emit objective C classes and categories into a hashed
357 /// accelerator table section.
358 void emitAccelObjC();
359
360 /// Emit namespace dies into a hashed accelerator table.
361 void emitAccelNamespaces();
362
363 /// Emit type dies into a hashed accelerator table.
364 void emitAccelTypes();
365
366 /// Emit visible names and types into debug pubnames and pubtypes sections.
367 void emitDebugPubSections();
368
369 void emitDebugPubSection(bool GnuStyle, StringRef Name,
370 DwarfCompileUnit *TheU,
371 const StringMap &Globals);
372
373 /// Emit null-terminated strings into a debug str section.
374 void emitDebugStr();
375
376 /// Emit variable locations into a debug loc section.
377 void emitDebugLoc();
378
379 /// Emit variable locations into a debug loc dwo section.
380 void emitDebugLocDWO();
381
382 /// Emit address ranges into a debug aranges section.
383 void emitDebugARanges();
384
385 /// Emit address ranges into a debug ranges section.
386 void emitDebugRanges();
387
388 /// Emit macros into a debug macinfo section.
389 void emitDebugMacinfo();
390 void emitMacro(DIMacro &M);
391 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
392 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
393
394 /// DWARF 5 Experimental Split Dwarf Emitters
395
396 /// Initialize common features of skeleton units.
397 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
398 std::unique_ptr NewU);
399
400 /// Construct the split debug info compile unit for the debug info
401 /// section.
402 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
403
404 /// Emit the debug info dwo section.
405 void emitDebugInfoDWO();
406
407 /// Emit the debug abbrev dwo section.
408 void emitDebugAbbrevDWO();
409
410 /// Emit the debug line dwo section.
411 void emitDebugLineDWO();
412
413 /// Emit the debug str dwo section.
414 void emitDebugStrDWO();
415
416 /// Flags to let the linker know we have emitted new style pubnames. Only
417 /// emit it here if we don't have a skeleton CU for split dwarf.
418 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
419
420 /// Create new DwarfCompileUnit for the given metadata node with tag
421 /// DW_TAG_compile_unit.
422 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
423
424 /// Construct imported_module or imported_declaration DIE.
425 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
426 const DIImportedEntity *N);
427
428 /// Register a source line with debug info. Returns the unique
429 /// label that was emitted and which provides correspondence to the
430 /// source line list.
431 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
432 unsigned Flags);
433
434 /// Populate LexicalScope entries with variables' info.
435 void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
436 DenseSet &ProcessedVars);
437
438 /// Build the location list for all DBG_VALUEs in the
439 /// function that describe the same variable.
440 void buildLocationList(SmallVectorImpl &DebugLoc,
441 const DbgValueHistoryMap::InstrRanges &Ranges);
442
443 /// Collect variable information from the side table maintained by MF.
444 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
445 DenseSet &P);
446
447 protected:
448 /// Gather pre-function debug information.
449 void beginFunctionImpl(const MachineFunction *MF) override;
450
451 /// Gather and emit post-function debug information.
452 void endFunctionImpl(const MachineFunction *MF) override;
453
454 void skippedNonDebugFunction() override;
455
456 public:
457 //===--------------------------------------------------------------------===//
458 // Main entry points.
459 //
460 DwarfDebug(AsmPrinter *A, Module *M);
461
462 ~DwarfDebug() override;
463
464 /// Emit all Dwarf sections that should come prior to the
465 /// content.
466 void beginModule();
467
468 /// Emit all Dwarf sections that should come after the content.
469 void endModule() override;
470
471 /// Process beginning of an instruction.
472 void beginInstruction(const MachineInstr *MI) override;
473
474 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
475 static uint64_t makeTypeSignature(StringRef Identifier);
476
477 /// Add a DIE to the set of types that we're going to pull into
478 /// type units.
479 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
480 DIE &Die, const DICompositeType *CTy);
481
482 /// Add a label so that arange data can be generated for it.
483 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
484
485 /// For symbols that have a size designated (e.g. common symbols),
486 /// this tracks that size.
487 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
488 SymSize[Sym] = Size;
489 }
490
491 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
492 /// If not, we still might emit certain cases.
493 bool useAllLinkageNames() const { return UseAllLinkageNames; }
494
495 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
496 /// standard DW_OP_form_tls_address opcode
497 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
498
499 /// Returns whether to use the DWARF2 format for bitfields instyead of the
500 /// DWARF4 format.
501 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
502
503 // Experimental DWARF5 features.
504
505 /// Returns whether or not to emit tables that dwarf consumers can
506 /// use to accelerate lookup.
507 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
508
509 bool useAppleExtensionAttributes() const {
510 return HasAppleExtensionAttributes;
511 }
512
513 /// Returns whether or not to change the current debug info for the
514 /// split dwarf proposal support.
515 bool useSplitDwarf() const { return HasSplitDwarf; }
516
517 bool shareAcrossDWOCUs() const;
518
519 /// Returns the Dwarf Version.
520 uint16_t getDwarfVersion() const;
521
522 /// Returns the previous CU that was being updated
523 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
524 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
525
526 /// Returns the entries for the .debug_loc section.
527 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
528
529 /// Emit an entry for the debug loc section. This can be used to
530 /// handle an entry that's going to be emitted into the debug loc section.
531 void emitDebugLocEntry(ByteStreamer &Streamer,
532 const DebugLocStream::Entry &Entry);
533
534 /// Emit the location for a debug loc entry, including the size header.
535 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
536
537 /// Find the MDNode for the given reference.
538 template T *resolve(TypedDINodeRef Ref) const {
539 return Ref.resolve();
540 }
541
542 void addSubprogramNames(const DISubprogram *SP, DIE &Die);
543
544 AddressPool &getAddressPool() { return AddrPool; }
545
546 void addAccelName(StringRef Name, const DIE &Die);
547
548 void addAccelObjC(StringRef Name, const DIE &Die);
549
550 void addAccelNamespace(StringRef Name, const DIE &Die);
551
552 void addAccelType(StringRef Name, const DIE &Die, char Flags);
553
554 const MachineFunction *getCurrentFunction() const { return CurFn; }
555
556 /// A helper function to check whether the DIE for a given Scope is
557 /// going to be null.
558 bool isLexicalScopeDIENull(LexicalScope *Scope);
559
316560 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
317561 ///
318562 /// Returns whether we are "tuning" for a given debugger.
319 /// Should be used only within the constructor, to set feature flags.
320563 /// @{
321564 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
322565 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
323566 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
324567 /// @}
325
326 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
327
328 const SmallVectorImpl> &getUnits() {
329 return InfoHolder.getUnits();
330 }
331
332 using InlinedVariable = DbgValueHistoryMap::InlinedVariable;
333
334 void ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable Var,
335 const MDNode *Scope);
336 void ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU, InlinedVariable Var,
337 const MDNode *Scope);
338
339 DbgVariable *createConcreteVariable(DwarfCompileUnit &TheCU,
340 LexicalScope &Scope, InlinedVariable IV);
341
342 /// Construct a DIE for this abstract scope.
343 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
344
345 void finishVariableDefinitions();
346
347 void finishSubprogramDefinitions();
348
349 /// Finish off debug information after all functions have been
350 /// processed.
351 void finalizeModuleInfo();
352
353 /// Emit the debug info section.
354 void emitDebugInfo();
355
356 /// Emit the abbreviation section.
357 void emitAbbreviations();
358
359 /// Emit a specified accelerator table.
360 void emitAccel(DwarfAccelTable &Accel, MCSection *Section,
361 StringRef TableName);
362
363 /// Emit visible names into a hashed accelerator table section.
364 void emitAccelNames();
365
366 /// Emit objective C classes and categories into a hashed
367 /// accelerator table section.
368 void emitAccelObjC();
369
370 /// Emit namespace dies into a hashed accelerator table.
371 void emitAccelNamespaces();
372
373 /// Emit type dies into a hashed accelerator table.
374 void emitAccelTypes();
375
376 /// Emit visible names into a debug pubnames section.
377 /// \param GnuStyle determines whether or not we want to emit
378 /// additional information into the table ala newer gcc for gdb
379 /// index.
380 void emitDebugPubNames(bool GnuStyle = false);
381
382 /// Emit visible types into a debug pubtypes section.
383 /// \param GnuStyle determines whether or not we want to emit
384 /// additional information into the table ala newer gcc for gdb
385 /// index.
386 void emitDebugPubTypes(bool GnuStyle = false);
387
388 void emitDebugPubSection(
389 bool GnuStyle, MCSection *PSec, StringRef Name,
390 const StringMap &(DwarfCompileUnit::*Accessor)() const);
391
392 /// Emit null-terminated strings into a debug str section.
393 void emitDebugStr();
394
395 /// Emit variable locations into a debug loc section.
396 void emitDebugLoc();
397
398 /// Emit variable locations into a debug loc dwo section.
399 void emitDebugLocDWO();
400
401 /// Emit address ranges into a debug aranges section.
402 void emitDebugARanges();
403
404 /// Emit address ranges into a debug ranges section.
405 void emitDebugRanges();
406
407 /// Emit macros into a debug macinfo section.
408 void emitDebugMacinfo();
409 void emitMacro(DIMacro &M);
410 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
411 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
412
413 /// DWARF 5 Experimental Split Dwarf Emitters
414
415 /// Initialize common features of skeleton units.
416 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
417 std::unique_ptr NewU);
418
419 /// Construct the split debug info compile unit for the debug info
420 /// section.
421 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
422
423 /// Emit the debug info dwo section.
424 void emitDebugInfoDWO();
425
426 /// Emit the debug abbrev dwo section.
427 void emitDebugAbbrevDWO();
428
429 /// Emit the debug line dwo section.
430 void emitDebugLineDWO();
431
432 /// Emit the debug str dwo section.
433 void emitDebugStrDWO();
434
435 /// Flags to let the linker know we have emitted new style pubnames. Only
436 /// emit it here if we don't have a skeleton CU for split dwarf.
437 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
438
439 /// Create new DwarfCompileUnit for the given metadata node with tag
440 /// DW_TAG_compile_unit.
441 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
442
443 /// Construct imported_module or imported_declaration DIE.
444 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
445 const DIImportedEntity *N);
446
447 /// Register a source line with debug info. Returns the unique
448 /// label that was emitted and which provides correspondence to the
449 /// source line list.
450 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
451 unsigned Flags);
452
453 /// Populate LexicalScope entries with variables' info.
454 void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
455 DenseSet &ProcessedVars);
456
457 /// Build the location list for all DBG_VALUEs in the
458 /// function that describe the same variable.
459 void buildLocationList(SmallVectorImpl &DebugLoc,
460 const DbgValueHistoryMap::InstrRanges &Ranges);
461
462 /// Collect variable information from the side table maintained by MF.
463 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
464 DenseSet &P);
465
466 protected:
467 /// Gather pre-function debug information.
468 void beginFunctionImpl(const MachineFunction *MF) override;
469
470 /// Gather and emit post-function debug information.
471 void endFunctionImpl(const MachineFunction *MF) override;
472
473 void skippedNonDebugFunction() override;
474
475 public:
476 //===--------------------------------------------------------------------===//
477 // Main entry points.
478 //
479 DwarfDebug(AsmPrinter *A, Module *M);
480
481 ~DwarfDebug() override;
482
483 /// Emit all Dwarf sections that should come prior to the
484 /// content.
485 void beginModule();
486
487 /// Emit all Dwarf sections that should come after the content.
488 void endModule() override;
489
490 /// Process beginning of an instruction.
491 void beginInstruction(const MachineInstr *MI) override;
492
493 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
494 static uint64_t makeTypeSignature(StringRef Identifier);
495
496 /// Add a DIE to the set of types that we're going to pull into
497 /// type units.
498 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
499 DIE &Die, const DICompositeType *CTy);
500
501 /// Add a label so that arange data can be generated for it.
502 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
503
504 /// For symbols that have a size designated (e.g. common symbols),
505 /// this tracks that size.
506 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
507 SymSize[Sym] = Size;
508 }
509
510 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
511 /// If not, we still might emit certain cases.
512 bool useAllLinkageNames() const { return UseAllLinkageNames; }
513
514 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
515 /// standard DW_OP_form_tls_address opcode
516 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
517
518 /// Returns whether to use the DWARF2 format for bitfields instyead of the
519 /// DWARF4 format.
520 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
521
522 // Experimental DWARF5 features.
523
524 /// Returns whether or not to emit tables that dwarf consumers can
525 /// use to accelerate lookup.
526 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
527
528 bool useAppleExtensionAttributes() const {
529 return HasAppleExtensionAttributes;
530 }
531
532 /// Returns whether or not to change the current debug info for the
533 /// split dwarf proposal support.
534 bool useSplitDwarf() const { return HasSplitDwarf; }
535
536 bool shareAcrossDWOCUs() const;
537
538 /// Returns the Dwarf Version.
539 uint16_t getDwarfVersion() const;
540
541 /// Returns the previous CU that was being updated
542 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
543 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
544
545 /// Returns the entries for the .debug_loc section.
546 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
547
548 /// Emit an entry for the debug loc section. This can be used to
549 /// handle an entry that's going to be emitted into the debug loc section.
550 void emitDebugLocEntry(ByteStreamer &Streamer,
551 const DebugLocStream::Entry &Entry);
552
553 /// Emit the location for a debug loc entry, including the size header.
554 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
555
556 /// Find the MDNode for the given reference.
557 template T *resolve(TypedDINodeRef Ref) const {
558 return Ref.resolve();
559 }
560
561 void addSubprogramNames(const DISubprogram *SP, DIE &Die);
562
563 AddressPool &getAddressPool() { return AddrPool; }
564
565 void addAccelName(StringRef Name, const DIE &Die);
566
567 void addAccelObjC(StringRef Name, const DIE &Die);
568
569 void addAccelNamespace(StringRef Name, const DIE &Die);
570
571 void addAccelType(StringRef Name, const DIE &Die, char Flags);
572
573 const MachineFunction *getCurrentFunction() const { return CurFn; }
574
575 /// A helper function to check whether the DIE for a given Scope is
576 /// going to be null.
577 bool isLexicalScopeDIENull(LexicalScope *Scope);
578
579 bool hasDwarfPubSections(bool includeMinimalInlineScopes) const;
580568 };
581569
582570 } // end namespace llvm
17411741 Printer.printBool("splitDebugInlining", N->getSplitDebugInlining(), true);
17421742 Printer.printBool("debugInfoForProfiling", N->getDebugInfoForProfiling(),
17431743 false);
1744 Printer.printBool("gnuPubnames", N->getGnuPubnames(), false);
17441745 Out << ")";
17451746 }
17461747
126126 unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized,
127127 StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
128128 DICompileUnit::DebugEmissionKind Kind, uint64_t DWOId,
129 bool SplitDebugInlining, bool DebugInfoForProfiling) {
129 bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames) {
130130
131131 assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
132132 (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
136136 CUNode = DICompileUnit::getDistinct(
137137 VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
138138 SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
139 SplitDebugInlining, DebugInfoForProfiling);
139 SplitDebugInlining, DebugInfoForProfiling, GnuPubnames);
140140
141141 // Create a named metadata so that it is easier to find cu in a module.
142142 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
472472 CU->getSplitDebugFilename(), DICompileUnit::LineTablesOnly, EnumTypes,
473473 RetainedTypes, GlobalVariables, ImportedEntities, CU->getMacros(),
474474 CU->getDWOId(), CU->getSplitDebugInlining(),
475 CU->getDebugInfoForProfiling());
475 CU->getDebugInfoForProfiling(), CU->getGnuPubnames());
476476 }
477477
478478 DILocation *getReplacementMDLocation(DILocation *MLD) {
390390 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
391391 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
392392 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
393 StorageType Storage, bool ShouldCreate) {
393 bool GnuPubnames, StorageType Storage, bool ShouldCreate) {
394394 assert(Storage != Uniqued && "Cannot unique DICompileUnit");
395395 assert(isCanonical(Producer) && "Expected canonical MDString");
396396 assert(isCanonical(Flags) && "Expected canonical MDString");
400400 File, Producer, Flags, SplitDebugFilename,
401401 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
402402 Macros};
403 return storeImpl(new (array_lengthof(Ops))
404 DICompileUnit(Context, Storage, SourceLanguage,
405 IsOptimized, RuntimeVersion, EmissionKind,
406 DWOId, SplitDebugInlining,
407 DebugInfoForProfiling, Ops),
403 return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
404 Context, Storage, SourceLanguage, IsOptimized,
405 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
406 DebugInfoForProfiling, GnuPubnames, Ops),
408407 Storage);
409408 }
410409
0 ; RUN: llvm-as -disable-verify -o - %s | llvm-dis | FileCheck %s
1
2 !named = !{!0}
3 ; CHECK: !DICompileUnit({{.*}}, gnuPubnames: true)
4 !0 = distinct !DICompileUnit(language: 12, file: !1, gnuPubnames: true)
5 !1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
None ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
0 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
11
22 ; Generated from:
33
1616 !llvm.dbg.cu = !{!0}
1717 !llvm.module.flags = !{!3, !4}
1818
19 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 191846) (llvm/trunk 191866)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !5, globals: !2, imports: !2)
19 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 191846) (llvm/trunk 191866)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !5, globals: !2, imports: !2, gnuPubnames: true)
2020 !1 = !DIFile(filename: "foo.c", directory: "/usr/local/google/home/echristo/tmp")
2121 !2 = !{}
2222 !3 = !{i32 2, !"Dwarf Version", i32 4}
None ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj < %s -generate-gnu-dwarf-pub-sections | llvm-dwarfdump -v - | FileCheck --check-prefix=GPUB --check-prefix=CHECK %s
0 ; RUN: sed -e 's/gnuPubnames: false/gnuPubnames: true/' %s | llc -mtriple=x86_64-pc-linux-gnu -filetype=obj | llvm-dwarfdump -v - | FileCheck --check-prefix=GPUB --check-prefix=CHECK %s
11 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj < %s -generate-dwarf-pub-sections=Enable | llvm-dwarfdump -v - | FileCheck --check-prefix=PUB --check-prefix=CHECK %s
22 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck --check-prefix=NONE %s
33
5252 !llvm.module.flags = !{!3, !4, !5}
5353 !llvm.ident = !{!6}
5454
55 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 303768) (llvm/trunk 303774)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
55 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 303768) (llvm/trunk 303774)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, gnuPubnames: false)
5656 !1 = !DIFile(filename: "gnu-public-names-gmlt.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
5757 !2 = !{}
5858 !3 = !{i32 2, !"Dwarf Version", i32 4}
0 ; RUN: llc < %s | FileCheck %s
1
2 !llvm.dbg.cu = !{!4, !11}
3 !llvm.module.flags = !{!7}
4
5 ; CHECK: .section .debug_pubnames
6 ; CHECK: .asciz "a"
7
8 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
9 !1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
10 !2 = !DIFile(filename: "g.c", directory: "/tmp")
11 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
12 !4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6)
13 !5 = !{}
14 !6 = !{!0}
15 !7 = !{i32 1, !"Debug Info Version", i32 3}
16
17 ; CHECK: .section .debug_gnu_pubnames
18 ; CHECK: .asciz "b"
19
20 !8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
21 !9 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
22 !10 = !{!8}
23 !11 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !10, gnuPubnames: true)
None ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-type-units -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
0 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-type-units -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
11
22 ; Generated from:
33
3838
3939 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
4040 !1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
41 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 5.0.0 (trunk 293904) (llvm/trunk 293908)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
41 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 5.0.0 (trunk 293904) (llvm/trunk 293908)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, gnuPubnames: true)
4242 !3 = !DIFile(filename: "type.cpp", directory: "/tmp/dbginfo")
4343 !4 = !{}
4444 !5 = !{!0}
None ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s
1 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
0 ; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck -check-prefix=ASM %s
1 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
22 ; ModuleID = 'dwarf-public-names.cpp'
33 ;
44 ; Generated from:
301301
302302 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
303303 !1 = !DIGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", scope: !2, file: !3, line: 7, type: !9, isLocal: false, isDefinition: true, declaration: !8)
304 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.7.0 (trunk 234897) (llvm/trunk 234911)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !21, imports: !44)
304 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.7.0 (trunk 234897) (llvm/trunk 234911)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !21, imports: !44, gnuPubnames: true)
305305 !3 = !DIFile(filename: "gnu-public-names.cpp", directory: "/tmp/dbginfo")
306306 !4 = !{}
307307 !5 = !{!6, !17}
9191 return DIFile::getDistinct(Context, "file.c", "/path/to/dir");
9292 }
9393 DICompileUnit *getUnit() {
94 return DICompileUnit::getDistinct(Context, 1, getFile(), "clang", false,
95 "-g", 2, "", DICompileUnit::FullDebug,
96 getTuple(), getTuple(), getTuple(),
97 getTuple(), getTuple(), 0, true, false);
94 return DICompileUnit::getDistinct(
95 Context, 1, getFile(), "clang", false, "-g", 2, "",
96 DICompileUnit::FullDebug, getTuple(), getTuple(), getTuple(),
97 getTuple(), getTuple(), 0, true, false, false);
9898 }
9999 DIType *getBasicType(StringRef Name) {
100100 return DIBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name);
14161416 Context, SourceLanguage, File, Producer, IsOptimized, Flags,
14171417 RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
14181418 RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId, true,
1419 false);
1419 false, false);
14201420
14211421 EXPECT_EQ(dwarf::DW_TAG_compile_unit, N->getTag());
14221422 EXPECT_EQ(SourceLanguage, N->getSourceLanguage());
14731473 auto *N = DICompileUnit::getDistinct(
14741474 Context, SourceLanguage, File, Producer, IsOptimized, Flags,
14751475 RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
1476 RetainedTypes, nullptr, ImportedEntities, nullptr, DWOId, true, false);
1476 RetainedTypes, nullptr, ImportedEntities, nullptr, DWOId, true, false,
1477 false);
14771478
14781479 auto *GlobalVariables = MDTuple::getDistinct(Context, None);
14791480 EXPECT_EQ(nullptr, N->getGlobalVariables().get());