mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[CodeGen] Generate DWARF v5 Accelerator Tables
Summary: This patch adds a DwarfAccelTableEmitter class, which generates an accelerator table, as specified in DWARF v5 standard. At the moment it only generates a DIE offset column and (if we are indexing more than one compile unit) a CU column. Indexing type units is not currently supported, as we don't even have the ability to generate DWARF v5-compatible compile units. The implementation is not data-source agnostic like the one generating apple tables. This was not necessary as we currently only have one user of this code, and without a second user it was not obvious to me how to best abstract this. (The difference between these tables and the apple ones is that they need a lot more metadata about the debug info they are indexing). The generation is triggered by the --accel-tables argument, which supersedes the --dwarf-accel-tables arg -- the latter was a simple on-off switch, but not we can choose between two kinds of accelerator tables we can generate. This is tested by parsing the generated tables with llvm-dwarfdump and the DWARFVerifier, and I've also checked that GNU readelf is able to make sense of the tables. Differential Revision: https://reviews.llvm.org/D43286 llvm-svn: 329179
This commit is contained in:
parent
e86c876871
commit
2baec4289f
@ -108,6 +108,8 @@
|
||||
namespace llvm {
|
||||
|
||||
class AsmPrinter;
|
||||
class DwarfCompileUnit;
|
||||
class DwarfDebug;
|
||||
|
||||
/// Interface which the different types of accelerator table data have to
|
||||
/// conform. It serves as a base class for different values of the template
|
||||
@ -244,6 +246,28 @@ public:
|
||||
static uint32_t hash(StringRef Buffer) { return djbHash(Buffer); }
|
||||
};
|
||||
|
||||
/// The Data class implementation for DWARF v5 accelerator table. Unlike the
|
||||
/// Apple Data classes, this class is just a DIE wrapper, and does not know to
|
||||
/// serialize itself. The complete serialization logic is in the
|
||||
/// emitDWARF5AccelTable function.
|
||||
class DWARF5AccelTableData : public AccelTableData {
|
||||
public:
|
||||
static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
|
||||
|
||||
DWARF5AccelTableData(const DIE &Die) : Die(Die) {}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void print(raw_ostream &OS) const override;
|
||||
#endif
|
||||
|
||||
const DIE &getDie() const { return Die; }
|
||||
|
||||
protected:
|
||||
const DIE &Die;
|
||||
|
||||
uint64_t order() const override { return Die.getOffset(); }
|
||||
};
|
||||
|
||||
void emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
|
||||
StringRef Prefix, const MCSymbol *SecBegin,
|
||||
ArrayRef<AppleAccelTableData::Atom> Atoms);
|
||||
@ -258,6 +282,11 @@ void emitAppleAccelTable(AsmPrinter *Asm, AccelTable<DataT> &Contents,
|
||||
emitAppleAccelTableImpl(Asm, Contents, Prefix, SecBegin, DataT::Atoms);
|
||||
}
|
||||
|
||||
void emitDWARF5AccelTable(AsmPrinter *Asm,
|
||||
AccelTable<DWARF5AccelTableData> &Contents,
|
||||
const DwarfDebug &DD,
|
||||
ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs);
|
||||
|
||||
/// Accelerator table data implementation for simple Apple accelerator tables
|
||||
/// with just a DIE reference.
|
||||
class AppleAccelTableOffsetData : public AppleAccelTableData {
|
||||
|
@ -92,11 +92,11 @@ protected:
|
||||
// can be enabled by a compiler flag.
|
||||
MCSection *DwarfPubNamesSection;
|
||||
|
||||
/// DWARF5 Experimental Debug Info Sections
|
||||
/// DwarfAccelNamesSection, DwarfAccelObjCSection,
|
||||
/// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
|
||||
/// If we use the DWARF accelerated hash tables then we want to emit these
|
||||
/// sections.
|
||||
/// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
|
||||
/// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
|
||||
/// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
|
||||
/// extensions.
|
||||
MCSection *DwarfDebugNamesSection;
|
||||
MCSection *DwarfAccelNamesSection;
|
||||
MCSection *DwarfAccelObjCSection;
|
||||
MCSection *DwarfAccelNamespaceSection;
|
||||
@ -254,7 +254,9 @@ public:
|
||||
MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
|
||||
MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
|
||||
|
||||
// DWARF5 Experimental Debug Info Sections
|
||||
MCSection *getDwarfDebugNamesSection() const {
|
||||
return DwarfDebugNamesSection;
|
||||
}
|
||||
MCSection *getDwarfAccelNamesSection() const {
|
||||
return DwarfAccelNamesSection;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/CodeGen/AccelTable.h"
|
||||
#include "DwarfCompileUnit.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
@ -86,6 +87,8 @@ void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// Base class for writing out Accelerator tables. It holds the common
|
||||
/// functionality for the two Accelerator table types.
|
||||
class AccelTableEmitter {
|
||||
protected:
|
||||
AsmPrinter *const Asm; ///< Destination.
|
||||
@ -176,6 +179,64 @@ public:
|
||||
void dump() const { print(dbgs()); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Class responsible for emitting a DWARF v5 Accelerator Table. The only public
|
||||
/// function is emit(), which performs the actual emission.
|
||||
class Dwarf5AccelTableEmitter : public AccelTableEmitter {
|
||||
struct Header {
|
||||
uint32_t UnitLength = 0;
|
||||
uint16_t Version = 5;
|
||||
uint16_t Padding = 0;
|
||||
uint32_t CompUnitCount;
|
||||
uint32_t LocalTypeUnitCount = 0;
|
||||
uint32_t ForeignTypeUnitCount = 0;
|
||||
uint32_t BucketCount;
|
||||
uint32_t NameCount;
|
||||
uint32_t AbbrevTableSize = 0;
|
||||
uint32_t AugmentationStringSize = sizeof(AugmentationString);
|
||||
char AugmentationString[8] = {'L', 'L', 'V', 'M', '0', '7', '0', '0'};
|
||||
static_assert(sizeof(AugmentationString) % 4 == 0, "");
|
||||
|
||||
Header(uint32_t CompUnitCount, uint32_t BucketCount, uint32_t NameCount)
|
||||
: CompUnitCount(CompUnitCount), BucketCount(BucketCount),
|
||||
NameCount(NameCount) {}
|
||||
|
||||
void emit(const Dwarf5AccelTableEmitter &Ctx) const;
|
||||
};
|
||||
struct AttributeEncoding {
|
||||
dwarf::Index Index;
|
||||
dwarf::Form Form;
|
||||
};
|
||||
|
||||
Header Header;
|
||||
DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
|
||||
const DwarfDebug ⅅ
|
||||
ArrayRef<std::unique_ptr<DwarfCompileUnit>> CompUnits;
|
||||
MCSymbol *ContributionStart = Asm->createTempSymbol("names_start");
|
||||
MCSymbol *ContributionEnd = Asm->createTempSymbol("names_end");
|
||||
MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
|
||||
MCSymbol *AbbrevEnd = Asm->createTempSymbol("names_abbrev_end");
|
||||
MCSymbol *EntryPool = Asm->createTempSymbol("names_entries");
|
||||
|
||||
DenseSet<uint32_t> getUniqueTags() const;
|
||||
|
||||
// Right now, we emit uniform attributes for all tags.
|
||||
SmallVector<AttributeEncoding, 2> getUniformAttributes() const;
|
||||
|
||||
void emitCUList() const;
|
||||
void emitBuckets() const;
|
||||
void emitStringOffsets() const;
|
||||
void emitAbbrevs() const;
|
||||
void emitEntry(const DWARF5AccelTableData &Data) const;
|
||||
void emitData() const;
|
||||
|
||||
public:
|
||||
Dwarf5AccelTableEmitter(
|
||||
AsmPrinter *Asm, const AccelTableBase &Contents, const DwarfDebug &DD,
|
||||
ArrayRef<std::unique_ptr<DwarfCompileUnit>> CompUnits);
|
||||
|
||||
void emit() const;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void AccelTableEmitter::emitHashes() const {
|
||||
@ -294,6 +355,177 @@ void AppleAccelTableEmitter::emit() const {
|
||||
emitData();
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::Header::emit(
|
||||
const Dwarf5AccelTableEmitter &Ctx) const {
|
||||
AsmPrinter *Asm = Ctx.Asm;
|
||||
Asm->OutStreamer->AddComment("Header: unit length");
|
||||
Asm->EmitLabelDifference(Ctx.ContributionEnd, Ctx.ContributionStart,
|
||||
sizeof(uint32_t));
|
||||
Asm->OutStreamer->EmitLabel(Ctx.ContributionStart);
|
||||
Asm->OutStreamer->AddComment("Header: version");
|
||||
Asm->emitInt16(Version);
|
||||
Asm->OutStreamer->AddComment("Header: padding");
|
||||
Asm->emitInt16(Padding);
|
||||
Asm->OutStreamer->AddComment("Header: compilation unit count");
|
||||
Asm->emitInt32(CompUnitCount);
|
||||
Asm->OutStreamer->AddComment("Header: local type unit count");
|
||||
Asm->emitInt32(LocalTypeUnitCount);
|
||||
Asm->OutStreamer->AddComment("Header: foreign type unit count");
|
||||
Asm->emitInt32(ForeignTypeUnitCount);
|
||||
Asm->OutStreamer->AddComment("Header: bucket count");
|
||||
Asm->emitInt32(BucketCount);
|
||||
Asm->OutStreamer->AddComment("Header: name count");
|
||||
Asm->emitInt32(NameCount);
|
||||
Asm->OutStreamer->AddComment("Header: abbreviation table size");
|
||||
Asm->EmitLabelDifference(Ctx.AbbrevEnd, Ctx.AbbrevStart, sizeof(uint32_t));
|
||||
Asm->OutStreamer->AddComment("Header: augmentation string size");
|
||||
Asm->emitInt32(AugmentationStringSize);
|
||||
Asm->OutStreamer->AddComment("Header: augmentation string");
|
||||
Asm->OutStreamer->EmitBytes({AugmentationString, AugmentationStringSize});
|
||||
}
|
||||
|
||||
DenseSet<uint32_t> Dwarf5AccelTableEmitter::getUniqueTags() const {
|
||||
DenseSet<uint32_t> UniqueTags;
|
||||
for (auto &Bucket : Contents.getBuckets()) {
|
||||
for (auto *Hash : Bucket) {
|
||||
for (auto *Value : Hash->Values) {
|
||||
const DIE &Die =
|
||||
static_cast<const DWARF5AccelTableData *>(Value)->getDie();
|
||||
UniqueTags.insert(Die.getTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
return UniqueTags;
|
||||
}
|
||||
|
||||
SmallVector<Dwarf5AccelTableEmitter::AttributeEncoding, 2>
|
||||
Dwarf5AccelTableEmitter::getUniformAttributes() const {
|
||||
SmallVector<AttributeEncoding, 2> UA;
|
||||
if (CompUnits.size() > 1) {
|
||||
size_t LargestCUIndex = CompUnits.size() - 1;
|
||||
dwarf::Form Form = DIEInteger::BestForm(/*IsSigned*/ false, LargestCUIndex);
|
||||
UA.push_back({dwarf::DW_IDX_compile_unit, Form});
|
||||
}
|
||||
UA.push_back({dwarf::DW_IDX_die_offset, dwarf::DW_FORM_ref4});
|
||||
return UA;
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitCUList() const {
|
||||
for (const auto &CU : enumerate(CompUnits)) {
|
||||
assert(CU.index() == CU.value()->getUniqueID());
|
||||
Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index()));
|
||||
Asm->emitDwarfSymbolReference(CU.value()->getLabelBegin());
|
||||
}
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitBuckets() const {
|
||||
uint32_t Index = 1;
|
||||
for (const auto &Bucket : enumerate(Contents.getBuckets())) {
|
||||
Asm->OutStreamer->AddComment("Bucket " + Twine(Bucket.index()));
|
||||
Asm->emitInt32(Bucket.value().empty() ? 0 : Index);
|
||||
Index += Bucket.value().size();
|
||||
}
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitStringOffsets() const {
|
||||
for (const auto &Bucket : enumerate(Contents.getBuckets())) {
|
||||
for (auto *Hash : Bucket.value()) {
|
||||
DwarfStringPoolEntryRef String = Hash->Name;
|
||||
Asm->OutStreamer->AddComment("String in Bucket " + Twine(Bucket.index()) +
|
||||
": " + String.getString());
|
||||
Asm->emitDwarfStringOffset(String);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitAbbrevs() const {
|
||||
Asm->OutStreamer->EmitLabel(AbbrevStart);
|
||||
for (const auto &Abbrev : Abbreviations) {
|
||||
Asm->OutStreamer->AddComment("Abbrev code");
|
||||
assert(Abbrev.first != 0);
|
||||
Asm->EmitULEB128(Abbrev.first);
|
||||
Asm->OutStreamer->AddComment(dwarf::TagString(Abbrev.first));
|
||||
Asm->EmitULEB128(Abbrev.first);
|
||||
for (const auto &AttrEnc : Abbrev.second) {
|
||||
Asm->EmitULEB128(AttrEnc.Index, dwarf::IndexString(AttrEnc.Index).data());
|
||||
Asm->EmitULEB128(AttrEnc.Form,
|
||||
dwarf::FormEncodingString(AttrEnc.Form).data());
|
||||
}
|
||||
Asm->EmitULEB128(0, "End of abbrev");
|
||||
Asm->EmitULEB128(0, "End of abbrev");
|
||||
}
|
||||
Asm->EmitULEB128(0, "End of abbrev list");
|
||||
Asm->OutStreamer->EmitLabel(AbbrevEnd);
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitEntry(
|
||||
const DWARF5AccelTableData &Entry) const {
|
||||
auto AbbrevIt = Abbreviations.find(Entry.getDie().getTag());
|
||||
assert(AbbrevIt != Abbreviations.end() &&
|
||||
"Why wasn't this abbrev generated?");
|
||||
|
||||
Asm->EmitULEB128(AbbrevIt->first, "Abbreviation code");
|
||||
for (const auto &AttrEnc : AbbrevIt->second) {
|
||||
Asm->OutStreamer->AddComment(dwarf::IndexString(AttrEnc.Index));
|
||||
switch (AttrEnc.Index) {
|
||||
case dwarf::DW_IDX_compile_unit: {
|
||||
const DIE *CUDie = Entry.getDie().getUnitDie();
|
||||
DIEInteger ID(DD.lookupCU(CUDie)->getUniqueID());
|
||||
ID.EmitValue(Asm, AttrEnc.Form);
|
||||
break;
|
||||
}
|
||||
case dwarf::DW_IDX_die_offset:
|
||||
assert(AttrEnc.Form == dwarf::DW_FORM_ref4);
|
||||
Asm->emitInt32(Entry.getDie().getOffset());
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unexpected index attribute!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emitData() const {
|
||||
Asm->OutStreamer->EmitLabel(EntryPool);
|
||||
for (auto &Bucket : Contents.getBuckets()) {
|
||||
for (auto *Hash : Bucket) {
|
||||
// Remember to emit the label for our offset.
|
||||
Asm->OutStreamer->EmitLabel(Hash->Sym);
|
||||
for (const auto *Value : Hash->Values)
|
||||
emitEntry(*static_cast<const DWARF5AccelTableData *>(Value));
|
||||
Asm->OutStreamer->AddComment("End of list: " + Hash->Name.getString());
|
||||
Asm->emitInt32(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dwarf5AccelTableEmitter::Dwarf5AccelTableEmitter(
|
||||
AsmPrinter *Asm, const AccelTableBase &Contents, const DwarfDebug &DD,
|
||||
ArrayRef<std::unique_ptr<DwarfCompileUnit>> CompUnits)
|
||||
: AccelTableEmitter(Asm, Contents, false),
|
||||
Header(CompUnits.size(), Contents.getBucketCount(),
|
||||
Contents.getUniqueNameCount()),
|
||||
DD(DD), CompUnits(CompUnits) {
|
||||
DenseSet<uint32_t> UniqueTags = getUniqueTags();
|
||||
SmallVector<AttributeEncoding, 2> UniformAttributes = getUniformAttributes();
|
||||
|
||||
Abbreviations.reserve(UniqueTags.size());
|
||||
for (uint32_t Tag : UniqueTags)
|
||||
Abbreviations.try_emplace(Tag, UniformAttributes);
|
||||
}
|
||||
|
||||
void Dwarf5AccelTableEmitter::emit() const {
|
||||
Header.emit(*this);
|
||||
emitCUList();
|
||||
emitBuckets();
|
||||
emitHashes();
|
||||
emitStringOffsets();
|
||||
emitOffsets(EntryPool);
|
||||
emitAbbrevs();
|
||||
emitData();
|
||||
Asm->OutStreamer->EmitValueToAlignment(4, 0);
|
||||
Asm->OutStreamer->EmitLabel(ContributionEnd);
|
||||
}
|
||||
|
||||
void llvm::emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
|
||||
StringRef Prefix, const MCSymbol *SecBegin,
|
||||
ArrayRef<AppleAccelTableData::Atom> Atoms) {
|
||||
@ -301,6 +533,13 @@ void llvm::emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
|
||||
AppleAccelTableEmitter(Asm, Contents, Atoms, SecBegin).emit();
|
||||
}
|
||||
|
||||
void llvm::emitDWARF5AccelTable(
|
||||
AsmPrinter *Asm, AccelTable<DWARF5AccelTableData> &Contents,
|
||||
const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) {
|
||||
Contents.finalize(Asm, "names");
|
||||
Dwarf5AccelTableEmitter(Asm, Contents, DD, CUs).emit();
|
||||
}
|
||||
|
||||
void AppleAccelTableOffsetData::emit(AsmPrinter *Asm) const {
|
||||
Asm->emitInt32(Die->getDebugSectionOffset());
|
||||
}
|
||||
@ -407,6 +646,11 @@ void AccelTableBase::print(raw_ostream &OS) const {
|
||||
E.second.print(OS);
|
||||
}
|
||||
|
||||
void DWARF5AccelTableData::print(raw_ostream &OS) const {
|
||||
OS << " Offset: " << Die.getOffset() << "\n";
|
||||
OS << " Tag: " << dwarf::TagString(Die.getTag()) << "\n";
|
||||
}
|
||||
|
||||
void AppleAccelTableOffsetData::print(raw_ostream &OS) const {
|
||||
OS << " Offset: " << Die->getOffset() << "\n";
|
||||
}
|
||||
|
@ -107,13 +107,14 @@ static cl::opt<DefaultOnOff> UnknownLocations(
|
||||
clEnumVal(Enable, "In all cases"), clEnumVal(Disable, "Never")),
|
||||
cl::init(Default));
|
||||
|
||||
static cl::opt<DefaultOnOff>
|
||||
DwarfAccelTables("dwarf-accel-tables", cl::Hidden,
|
||||
cl::desc("Output prototype dwarf accelerator tables."),
|
||||
cl::values(clEnumVal(Default, "Default for platform"),
|
||||
clEnumVal(Enable, "Enabled"),
|
||||
clEnumVal(Disable, "Disabled")),
|
||||
cl::init(Default));
|
||||
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));
|
||||
|
||||
static cl::opt<DefaultOnOff>
|
||||
DwarfInlinedStrings("dwarf-inlined-strings", cl::Hidden,
|
||||
@ -303,11 +304,13 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
|
||||
|
||||
// Turn on accelerator tables by default, if tuning for LLDB and the target is
|
||||
// supported.
|
||||
if (DwarfAccelTables == Default)
|
||||
HasDwarfAccelTables =
|
||||
tuneForLLDB() && A->TM.getTargetTriple().isOSBinFormatMachO();
|
||||
else
|
||||
HasDwarfAccelTables = DwarfAccelTables == Enable;
|
||||
if (AccelTables == AccelTableKind::Default) {
|
||||
if (tuneForLLDB() && A->TM.getTargetTriple().isOSBinFormatMachO())
|
||||
AccelTableKind = AccelTableKind::Apple;
|
||||
else
|
||||
AccelTableKind = AccelTableKind::None;
|
||||
} else
|
||||
AccelTableKind = AccelTables;
|
||||
|
||||
UseInlineStrings = DwarfInlinedStrings == Enable;
|
||||
HasAppleExtensionAttributes = tuneForLLDB();
|
||||
@ -839,11 +842,20 @@ void DwarfDebug::endModule() {
|
||||
}
|
||||
|
||||
// Emit info into the dwarf accelerator table sections.
|
||||
if (useDwarfAccelTables()) {
|
||||
switch (getAccelTableKind()) {
|
||||
case AccelTableKind::Apple:
|
||||
emitAccelNames();
|
||||
emitAccelObjC();
|
||||
emitAccelNamespaces();
|
||||
emitAccelTypes();
|
||||
break;
|
||||
case AccelTableKind::Dwarf:
|
||||
emitAccelDebugNames();
|
||||
break;
|
||||
case AccelTableKind::None:
|
||||
break;
|
||||
case AccelTableKind::Default:
|
||||
llvm_unreachable("Default should have already been resolved.");
|
||||
}
|
||||
|
||||
// Emit the pubnames and pubtypes sections if requested.
|
||||
@ -1455,6 +1467,12 @@ void DwarfDebug::emitAccel(AccelTableT &Accel, MCSection *Section,
|
||||
emitAppleAccelTable(Asm, Accel, TableName, Section->getBeginSymbol());
|
||||
}
|
||||
|
||||
void DwarfDebug::emitAccelDebugNames() {
|
||||
Asm->OutStreamer->SwitchSection(
|
||||
Asm->getObjFileLowering().getDwarfDebugNamesSection());
|
||||
emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits());
|
||||
}
|
||||
|
||||
// Emit visible names into a hashed accelerator table section.
|
||||
void DwarfDebug::emitAccelNames() {
|
||||
emitAccel(AccelNames, Asm->getObjFileLowering().getDwarfAccelNamesSection(),
|
||||
@ -2250,27 +2268,58 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
||||
// to reference is in the string table. We do this since the names we
|
||||
// add may not only be identical to the names in the DIE.
|
||||
void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) {
|
||||
if (!useDwarfAccelTables())
|
||||
switch (getAccelTableKind()) {
|
||||
case AccelTableKind::Apple:
|
||||
AccelNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
break;
|
||||
case AccelTableKind::Dwarf:
|
||||
AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
|
||||
Die);
|
||||
break;
|
||||
case AccelTableKind::None:
|
||||
return;
|
||||
AccelNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
case AccelTableKind::Default:
|
||||
llvm_unreachable("Default should have already been resolved.");
|
||||
}
|
||||
}
|
||||
|
||||
void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) {
|
||||
if (!useDwarfAccelTables())
|
||||
if (getAccelTableKind() != AccelTableKind::Apple)
|
||||
return;
|
||||
AccelObjC.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
}
|
||||
|
||||
void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) {
|
||||
if (!useDwarfAccelTables())
|
||||
switch (getAccelTableKind()) {
|
||||
case AccelTableKind::Apple:
|
||||
AccelNamespace.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
|
||||
&Die);
|
||||
break;
|
||||
case AccelTableKind::Dwarf:
|
||||
AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
|
||||
Die);
|
||||
break;
|
||||
case AccelTableKind::None:
|
||||
return;
|
||||
AccelNamespace.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
case AccelTableKind::Default:
|
||||
llvm_unreachable("Default should have already been resolved.");
|
||||
}
|
||||
}
|
||||
|
||||
void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) {
|
||||
if (!useDwarfAccelTables())
|
||||
switch (getAccelTableKind()) {
|
||||
case AccelTableKind::Apple:
|
||||
AccelTypes.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
break;
|
||||
case AccelTableKind::Dwarf:
|
||||
AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
|
||||
Die);
|
||||
break;
|
||||
case AccelTableKind::None:
|
||||
return;
|
||||
AccelTypes.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
|
||||
case AccelTableKind::Default:
|
||||
llvm_unreachable("Default should have already been resolved.");
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t DwarfDebug::getDwarfVersion() const {
|
||||
|
@ -192,6 +192,14 @@ struct SymbolCU {
|
||||
DwarfCompileUnit *CU;
|
||||
};
|
||||
|
||||
/// The kind of accelerator tables we should emit.
|
||||
enum class AccelTableKind {
|
||||
Default, ///< Platform default.
|
||||
None, ///< None.
|
||||
Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
|
||||
Dwarf, ///< DWARF v5 .debug_names.
|
||||
};
|
||||
|
||||
/// Collects and handles dwarf debug information.
|
||||
class DwarfDebug : public DebugHandlerBase {
|
||||
/// All DIEValues are allocated through this allocator.
|
||||
@ -270,7 +278,7 @@ class DwarfDebug : public DebugHandlerBase {
|
||||
|
||||
/// DWARF5 Experimental Options
|
||||
/// @{
|
||||
bool HasDwarfAccelTables;
|
||||
enum AccelTableKind AccelTableKind;
|
||||
bool HasAppleExtensionAttributes;
|
||||
bool HasSplitDwarf;
|
||||
|
||||
@ -302,7 +310,8 @@ class DwarfDebug : public DebugHandlerBase {
|
||||
|
||||
AddressPool AddrPool;
|
||||
|
||||
/// Apple accelerator tables.
|
||||
/// Accelerator tables.
|
||||
AccelTable<DWARF5AccelTableData> AccelDebugNames;
|
||||
AccelTable<AppleAccelTableOffsetData> AccelNames;
|
||||
AccelTable<AppleAccelTableOffsetData> AccelObjC;
|
||||
AccelTable<AppleAccelTableOffsetData> AccelNamespace;
|
||||
@ -351,6 +360,9 @@ class DwarfDebug : public DebugHandlerBase {
|
||||
template <typename AccelTableT>
|
||||
void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
|
||||
|
||||
/// Emit DWARF v5 accelerator table.
|
||||
void emitAccelDebugNames();
|
||||
|
||||
/// Emit visible names into a hashed accelerator table section.
|
||||
void emitAccelNames();
|
||||
|
||||
@ -523,9 +535,8 @@ public:
|
||||
|
||||
// Experimental DWARF5 features.
|
||||
|
||||
/// Returns whether or not to emit tables that dwarf consumers can
|
||||
/// use to accelerate lookup.
|
||||
bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
|
||||
/// Returns what kind (if any) of accelerator tables to emit.
|
||||
enum AccelTableKind getAccelTableKind() const { return AccelTableKind; }
|
||||
|
||||
bool useAppleExtensionAttributes() const {
|
||||
return HasAppleExtensionAttributes;
|
||||
@ -590,6 +601,9 @@ public:
|
||||
|
||||
/// Find the matching DwarfCompileUnit for the given CU DIE.
|
||||
DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
|
||||
const DwarfCompileUnit *lookupCU(const DIE *Die) const {
|
||||
return CUDieMap.lookup(Die);
|
||||
}
|
||||
|
||||
/// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
|
||||
///
|
||||
|
@ -201,6 +201,9 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
|
||||
}
|
||||
|
||||
// Debug Information.
|
||||
DwarfDebugNamesSection =
|
||||
Ctx->getMachOSection("__DWARF", "__debug_names", MachO::S_ATTR_DEBUG,
|
||||
SectionKind::getMetadata(), "debug_names_begin");
|
||||
DwarfAccelNamesSection =
|
||||
Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
|
||||
SectionKind::getMetadata(), "names_begin");
|
||||
@ -558,6 +561,8 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
|
||||
// DWARF5 Experimental Debug Info
|
||||
|
||||
// Accelerator Tables
|
||||
DwarfDebugNamesSection =
|
||||
Ctx->getELFSection(".debug_names", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAccelNamesSection =
|
||||
Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAccelObjCSection =
|
||||
@ -795,6 +800,11 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
|
||||
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ,
|
||||
SectionKind::getMetadata());
|
||||
DwarfDebugNamesSection = Ctx->getCOFFSection(
|
||||
".debug_names",
|
||||
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ,
|
||||
SectionKind::getMetadata(), "debug_names_begin");
|
||||
DwarfAccelNamesSection = Ctx->getCOFFSection(
|
||||
".apple_names",
|
||||
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
|
@ -1,5 +1,5 @@
|
||||
; REQUIRES: object-emission
|
||||
; RUN: %llc_dwarf -dwarf-accel-tables=Enable -filetype=obj -o - < %s \
|
||||
; RUN: %llc_dwarf -accel-tables=Apple -filetype=obj -o - < %s \
|
||||
; RUN: | llvm-dwarfdump -apple-names - | FileCheck %s
|
||||
|
||||
; Generated from the following C code using
|
||||
|
@ -1,7 +1,7 @@
|
||||
; REQUIRES: object-emission
|
||||
|
||||
; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck -implicit-check-not=DW_TAG %s
|
||||
; RUN: %llc_dwarf -dwarf-accel-tables=Enable -dwarf-linkage-names=All -O0 -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
|
||||
; RUN: %llc_dwarf -accel-tables=Apple -dwarf-linkage-names=All -O0 -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
|
||||
|
||||
; Build from source:
|
||||
; $ clang++ a.cpp b.cpp -g -c -emit-llvm
|
||||
|
101
test/DebugInfo/Generic/debug-names-hash-collisions.ll
Normal file
101
test/DebugInfo/Generic/debug-names-hash-collisions.ll
Normal file
@ -0,0 +1,101 @@
|
||||
; REQUIRES: object-emission
|
||||
; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
|
||||
; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
|
||||
; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
|
||||
|
||||
; Generated from the following C code using
|
||||
; clang -S -emit-llvm -g col.c
|
||||
;
|
||||
; These names were carefully chosen to cause hash collisions. Each type-variable
|
||||
; pair will hash to the same value. The also happen to demonstrate a flaw in the
|
||||
; DWARF v5 hash function: A copy constructor and an assignment operator for a
|
||||
; class will always hash to the same value.
|
||||
;
|
||||
; typedef void *_ZN4lldb7SBBlockaSERKS0_;
|
||||
; _ZN4lldb7SBBlockaSERKS0_ _ZN4lldb7SBBlockC1ERKS0_;
|
||||
; typedef void *_ZN4lldb7SBErroraSERKS0_;
|
||||
; _ZN4lldb7SBErroraSERKS0_ _ZN4lldb7SBErrorC1ERKS0_;
|
||||
; typedef void *_ZN4lldb7SBValueaSERKS0_;
|
||||
; _ZN4lldb7SBValueaSERKS0_ _ZN4lldb7SBValueC1ERKS0_;
|
||||
; typedef void *_ZL11numCommutes;
|
||||
; _ZL11numCommutes _ZL11NumCommutes;
|
||||
; typedef void *_ZL9NumRemats;
|
||||
; _ZL9NumRemats _ZL9NumReMats;
|
||||
|
||||
; Check that we have the right amount of hashes and names.
|
||||
; CHECK: Bucket count: 5
|
||||
; CHECK: Name count: 10
|
||||
|
||||
; Check that all the names are present in the output
|
||||
; CHECK: Bucket 0
|
||||
; CHECK: Hash: 0xF8CF70D
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBBlockaSERKS0_"
|
||||
; CHECK: Hash: 0xF8CF70D
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBBlockC1ERKS0_"
|
||||
; CHECK: Hash: 0x135A482C
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBErroraSERKS0_"
|
||||
; CHECK: Hash: 0x135A482C
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBErrorC1ERKS0_"
|
||||
; CHECK-NOT: String:
|
||||
; CHECK: Bucket 1
|
||||
; CHECK-NEXT: EMPTY
|
||||
; CHECK: Bucket 2
|
||||
; CHECK: Hash: 0x2841B989
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL11numCommutes"
|
||||
; CHECK: Hash: 0x2841B989
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL11NumCommutes"
|
||||
; CHECK: Hash: 0x3E190F5F
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL9NumRemats"
|
||||
; CHECK: Hash: 0x3E190F5F
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL9NumReMats"
|
||||
; CHECK-NOT: String:
|
||||
; CHECK: Bucket 3
|
||||
; CHECK: Hash: 0x2642207F
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBValueaSERKS0_"
|
||||
; CHECK: Hash: 0x2642207F
|
||||
; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBValueC1ERKS0_"
|
||||
; CHECK-NOT: String:
|
||||
; CHECK: Bucket 4
|
||||
; CHECK-NEXT: EMPTY
|
||||
|
||||
; VERIFY: No errors.
|
||||
|
||||
; ModuleID = '/tmp/col.c'
|
||||
source_filename = "/tmp/col.c"
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@_ZN4lldb7SBBlockC1ERKS0_ = common dso_local global i8* null, align 8, !dbg !0
|
||||
@_ZN4lldb7SBErrorC1ERKS0_ = common dso_local global i8* null, align 8, !dbg !6
|
||||
@_ZN4lldb7SBValueC1ERKS0_ = common dso_local global i8* null, align 8, !dbg !10
|
||||
@_ZL11NumCommutes = common dso_local global i8* null, align 8, !dbg !13
|
||||
@_ZL9NumReMats = common dso_local global i8* null, align 8, !dbg !16
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!20, !21, !22}
|
||||
!llvm.ident = !{!23}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBBlockC1ERKS0_", scope: !2, file: !3, line: 1, type: !19, isLocal: false, isDefinition: true)
|
||||
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
|
||||
!3 = !DIFile(filename: "/tmp/col.c", directory: "/tmp")
|
||||
!4 = !{}
|
||||
!5 = !{!0, !6, !10, !13, !16}
|
||||
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
|
||||
!7 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBErrorC1ERKS0_", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
|
||||
!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBErroraSERKS0_", file: !3, line: 2, baseType: !9)
|
||||
!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
|
||||
!11 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBValueC1ERKS0_", scope: !2, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true)
|
||||
!12 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBValueaSERKS0_", file: !3, line: 3, baseType: !9)
|
||||
!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression())
|
||||
!14 = distinct !DIGlobalVariable(name: "_ZL11NumCommutes", scope: !2, file: !3, line: 4, type: !15, isLocal: false, isDefinition: true)
|
||||
!15 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZL11numCommutes", file: !3, line: 4, baseType: !9)
|
||||
!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression())
|
||||
!17 = distinct !DIGlobalVariable(name: "_ZL9NumReMats", scope: !2, file: !3, line: 5, type: !18, isLocal: false, isDefinition: true)
|
||||
!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZL9NumRemats", file: !3, line: 5, baseType: !9)
|
||||
!19 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBBlockaSERKS0_", file: !3, line: 1, baseType: !9)
|
||||
!20 = !{i32 2, !"Dwarf Version", i32 4}
|
||||
!21 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!22 = !{i32 1, !"wchar_size", i32 4}
|
||||
!23 = !{!"clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)"}
|
1614
test/DebugInfo/Generic/debug-names-many-cu.ll
Normal file
1614
test/DebugInfo/Generic/debug-names-many-cu.ll
Normal file
File diff suppressed because it is too large
Load Diff
74
test/DebugInfo/Generic/debug-names-name-collisions.ll
Normal file
74
test/DebugInfo/Generic/debug-names-name-collisions.ll
Normal file
@ -0,0 +1,74 @@
|
||||
; REQUIRES: object-emission
|
||||
; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
|
||||
; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
|
||||
; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
|
||||
|
||||
; Generated from the following C code using
|
||||
; clang -S -emit-llvm col.cc
|
||||
;
|
||||
; namespace foo { struct foo {}; struct foo foo; }
|
||||
; namespace bar { struct bar {}; struct bar bar; }
|
||||
; namespace baz { struct baz {}; struct baz baz; }
|
||||
|
||||
; We have 6 names: foo, bar, baz and three mangled names of the variables.
|
||||
; CHECK: Name count: 6
|
||||
|
||||
; Check that all the names are present in the output correct number of times.
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "bar"
|
||||
; CHECK-DAG: Tag: DW_TAG_namespace
|
||||
; CHECK-DAG: Tag: DW_TAG_variable
|
||||
; CHECK-DAG: Tag: DW_TAG_structure_type
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "baz"
|
||||
; CHECK-DAG: Tag: DW_TAG_namespace
|
||||
; CHECK-DAG: Tag: DW_TAG_variable
|
||||
; CHECK-DAG: Tag: DW_TAG_structure_type
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "foo"
|
||||
; CHECK-DAG: Tag: DW_TAG_namespace
|
||||
; CHECK-DAG: Tag: DW_TAG_variable
|
||||
; CHECK-DAG: Tag: DW_TAG_structure_type
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "_ZN3foo3fooE"
|
||||
; CHECK: Tag: DW_TAG_variable
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "_ZN3bar3barE"
|
||||
; CHECK: Tag: DW_TAG_variable
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "_ZN3baz3bazE"
|
||||
; CHECK: Tag: DW_TAG_variable
|
||||
|
||||
; VERIFY: No errors.
|
||||
|
||||
; ModuleID = '/tmp/col.cc'
|
||||
source_filename = "/tmp/col.cc"
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
%"struct.foo::foo" = type { i8 }
|
||||
%"struct.bar::bar" = type { i8 }
|
||||
%"struct.baz::baz" = type { i8 }
|
||||
|
||||
@_ZN3foo3fooE = dso_local global %"struct.foo::foo" zeroinitializer, align 1, !dbg !0
|
||||
@_ZN3bar3barE = dso_local global %"struct.bar::bar" zeroinitializer, align 1, !dbg !6
|
||||
@_ZN3baz3bazE = dso_local global %"struct.baz::baz" zeroinitializer, align 1, !dbg !10
|
||||
|
||||
!llvm.dbg.cu = !{!14}
|
||||
!llvm.module.flags = !{!16, !17, !18}
|
||||
!llvm.ident = !{!19}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "foo", linkageName: "_ZN3foo3fooE", scope: !2, file: !3, line: 1, type: !4, isLocal: false, isDefinition: true)
|
||||
!2 = !DINamespace(name: "foo", scope: null)
|
||||
!3 = !DIFile(filename: "/tmp/col.cc", directory: "/tmp")
|
||||
!4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !2, file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !5, identifier: "_ZTSN3foo3fooE")
|
||||
!5 = !{}
|
||||
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
|
||||
!7 = distinct !DIGlobalVariable(name: "bar", linkageName: "_ZN3bar3barE", scope: !8, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true)
|
||||
!8 = !DINamespace(name: "bar", scope: null)
|
||||
!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", scope: !8, file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !5, identifier: "_ZTSN3bar3barE")
|
||||
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
|
||||
!11 = distinct !DIGlobalVariable(name: "baz", linkageName: "_ZN3baz3bazE", scope: !12, file: !3, line: 3, type: !13, isLocal: false, isDefinition: true)
|
||||
!12 = !DINamespace(name: "baz", scope: null)
|
||||
!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "baz", scope: !12, file: !3, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !5, identifier: "_ZTSN3baz3bazE")
|
||||
!14 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, globals: !15)
|
||||
!15 = !{!0, !6, !10}
|
||||
!16 = !{i32 2, !"Dwarf Version", i32 4}
|
||||
!17 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!18 = !{i32 1, !"wchar_size", i32 4}
|
||||
!19 = !{!"clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)"}
|
44
test/DebugInfo/Generic/debug-names-one-cu.ll
Normal file
44
test/DebugInfo/Generic/debug-names-one-cu.ll
Normal file
@ -0,0 +1,44 @@
|
||||
; REQUIRES: object-emission
|
||||
; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
|
||||
; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
|
||||
; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
|
||||
|
||||
; Check the header
|
||||
; CHECK: CU count: 1
|
||||
; CHECK: Local TU count: 0
|
||||
; CHECK: Foreign TU count: 0
|
||||
; CHECK: Name count: 1
|
||||
; CHECK: CU[0]: 0x{{[0-9a-f]*}}
|
||||
|
||||
; CHECK: Abbreviation [[ABBREV:0x[0-9a-f]*]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_variable
|
||||
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "foobar"
|
||||
; CHECK-NEXT: Entry
|
||||
; CHECK-NEXT: Abbrev: [[ABBREV]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_variable
|
||||
; CHECK-NEXT: DW_IDX_die_offset: 0x{{[0-9a-f]*}}
|
||||
|
||||
; VERIFY: No errors.
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@foobar = common dso_local global i8* null, align 8, !dbg !0
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!7, !8, !9}
|
||||
!llvm.ident = !{!10}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "foobar", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
|
||||
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
|
||||
!3 = !DIFile(filename: "/tmp/cu1.c", directory: "/tmp")
|
||||
!4 = !{}
|
||||
!5 = !{!0}
|
||||
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
!7 = !{i32 2, !"Dwarf Version", i32 4}
|
||||
!8 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!9 = !{i32 1, !"wchar_size", i32 4}
|
||||
!10 = !{!"clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)"}
|
59
test/DebugInfo/Generic/debug-names-two-cu.ll
Normal file
59
test/DebugInfo/Generic/debug-names-two-cu.ll
Normal file
@ -0,0 +1,59 @@
|
||||
; REQUIRES: object-emission
|
||||
; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
|
||||
; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
|
||||
; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
|
||||
|
||||
; Check the header
|
||||
; CHECK: CU count: 2
|
||||
; CHECK: Local TU count: 0
|
||||
; CHECK: Foreign TU count: 0
|
||||
; CHECK: Name count: 2
|
||||
; CHECK: CU[0]: 0x{{[0-9a-f]*}}
|
||||
; CHECK: CU[1]: 0x{{[0-9a-f]*}}
|
||||
|
||||
; CHECK: Abbreviation [[ABBREV:0x[0-9a-f]*]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_variable
|
||||
; CHECK-NEXT: DW_IDX_compile_unit: DW_FORM_data1
|
||||
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
|
||||
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "foobar2"
|
||||
; CHECK-NEXT: Entry
|
||||
; CHECK-NEXT: Abbrev: [[ABBREV]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_variable
|
||||
; CHECK-NEXT: DW_IDX_compile_unit: 0x01
|
||||
; CHECK-NEXT: DW_IDX_die_offset: 0x{{[0-9a-f]*}}
|
||||
|
||||
; CHECK: String: 0x{{[0-9a-f]*}} "foobar1"
|
||||
; CHECK-NEXT: Entry
|
||||
; CHECK-NEXT: Abbrev: [[ABBREV]]
|
||||
; CHECK-NEXT: Tag: DW_TAG_variable
|
||||
; CHECK-NEXT: DW_IDX_compile_unit: 0x00
|
||||
; CHECK-NEXT: DW_IDX_die_offset: 0x{{[0-9a-f]*}}
|
||||
|
||||
; VERIFY: No errors.
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
!llvm.dbg.cu = !{!12, !22}
|
||||
!llvm.module.flags = !{!7, !8, !9}
|
||||
!llvm.ident = !{!0}
|
||||
!7 = !{i32 2, !"Dwarf Version", i32 4}
|
||||
!8 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!9 = !{i32 1, !"wchar_size", i32 4}
|
||||
!0 = !{!"clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)"}
|
||||
!4 = !{}
|
||||
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
!3 = !DIFile(filename: "/tmp/cu2.c", directory: "/tmp")
|
||||
|
||||
@foobar1 = common dso_local global i8* null, align 8, !dbg !10
|
||||
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
|
||||
!11 = distinct !DIGlobalVariable(name: "foobar1", scope: !12, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
|
||||
!12 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !15)
|
||||
!15 = !{!10}
|
||||
|
||||
@foobar2 = common dso_local global i8* null, align 8, !dbg !20
|
||||
!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression())
|
||||
!21 = distinct !DIGlobalVariable(name: "foobar2", scope: !22, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
|
||||
!22 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !25)
|
||||
!25 = !{!20}
|
@ -1,6 +1,6 @@
|
||||
; RUN: llc -mtriple=i686-pc-mingw32 -dwarf-accel-tables=Enable -filetype=asm -O0 < %s | FileCheck %s
|
||||
; RUN: llc -mtriple=i686-pc-cygwin -dwarf-accel-tables=Enable -filetype=asm -O0 < %s | FileCheck %s
|
||||
; RUN: llc -mtriple=i686-w64-mingw32 -dwarf-accel-tables=Enable -filetype=asm -O0 < %s | FileCheck %s
|
||||
; RUN: llc -mtriple=i686-pc-mingw32 -accel-tables=Apple -filetype=asm -O0 < %s | FileCheck %s
|
||||
; RUN: llc -mtriple=i686-pc-cygwin -accel-tables=Apple -filetype=asm -O0 < %s | FileCheck %s
|
||||
; RUN: llc -mtriple=i686-w64-mingw32 -accel-tables=Apple -filetype=asm -O0 < %s | FileCheck %s
|
||||
; CHECK: .section .debug_info
|
||||
; CHECK: .section .apple_names
|
||||
; CHECK: .section .apple_types
|
||||
|
Loading…
Reference in New Issue
Block a user