[llvm] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #68131)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 10:25:53 PDT 2023
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/68131
- [LLVM][DWARF] Add support for monolithic types in .debug_names
>From 2af18d23554a1b62e0217a2ad6fedc1b86a0ddb6 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Fri, 1 Sep 2023 13:36:43 -0700
Subject: [PATCH 1/2] [llvm][dwarf][rfc][donotcommit] Enable print of ranges
addresses from .debug_info.dwo
Summary:
For split dwarf some of the sections remain in the main binary. For DWARF4 it's
.debug_ranges, .debug_addr. For DWARF5 it's .debug_addr. When using
llvm-dwarfdump on .dwo/.dwp files this results in not being able to see what ranges
and addresses for DW_AT_low_pc are used in DIEs, and output having "Error: " in it.
I added a new option --main-binary=<binary> that will create a link in
DWARFContext between DWO context and main binary. This allows tool to display
addresses for DW_AT_ranges and DW_AT_low_pc.
Example (DWARF5):
DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x00000b21 "flush_RL")
DW_AT_ranges (indexed (0x0) rangelist = 0x00000054
[0x0000000000403fe2, 0x0000000000403ff3)
[0x0000000000403ff6, 0x0000000000403ffe))
DW_TAG_subprogram
DW_AT_low_pc (0x0000000000403940)
---
.../llvm/DebugInfo/DWARF/DWARFContext.h | 24 ++++++++++
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 48 +++++++++++++++++--
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 7 ++-
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 21 ++++++++
4 files changed, 94 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
index 4bd8394e6b4ec82..f05106522c4b554 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -125,6 +125,12 @@ class DWARFContext : public DIContext {
DWARFUnitVector &getDWOUnits(bool Lazy = false);
std::unique_ptr<const DWARFObject> DObj;
+ /// Can be optionally set by tools that work with .dwo/.dwp files to reference
+ /// main binary debug information. Usefull for accessing .debug_ranges and
+ /// .debug_addr section.
+ std::unique_ptr<const DWARFObject> MainBinaryDObj = nullptr;
+ /// DWARFContext for main binary.
+ std::unique_ptr<DWARFContext> MainBinaryDICtx = nullptr;
// When set parses debug_info.dwo/debug_abbrev.dwo manually and populates CU
// Index, and TU Index for DWARF5.
@@ -145,6 +151,13 @@ class DWARFContext : public DIContext {
const DWARFObject &getDWARFObj() const { return *DObj; }
+ const DWARFObject *getMainBinaryDWARFObj() const {
+ return MainBinaryDObj.get();
+ }
+ const DWARFContext *getDWARFContextMainBinary() const {
+ return MainBinaryDICtx.get();
+ }
+
static bool classof(const DIContext *DICtx) {
return DICtx->getKind() == CK_DWARF;
}
@@ -478,6 +491,17 @@ class DWARFContext : public DIContext {
/// manually only for DWARF5.
void setParseCUTUIndexManually(bool PCUTU) { ParseCUTUIndexManually = PCUTU; }
+ /// Sets the object corresponding to the main binary to which the .dwo/.dwp
+ /// file belongs.
+ void setMainBinaryObjAndCreateContext(
+ const object::ObjectFile &Obj,
+ ProcessDebugRelocations RelocAction = ProcessDebugRelocations::Process,
+ const LoadedObjectInfo *L = nullptr,
+ std::function<void(Error)> RecoverableErrorHandler =
+ WithColor::defaultErrorHandler,
+ std::function<void(Error)> WarningHandler =
+ WithColor::defaultWarningHandler);
+
private:
void addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram, DWARFDie Die,
std::vector<DILocal> &Result);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 1e1ab814673f423..6e57937e841512f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -47,8 +47,8 @@
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/LEB128.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
@@ -56,7 +56,9 @@
#include <cstdint>
#include <deque>
#include <map>
+#include <optional>
#include <string>
+#include <unordered_map>
#include <utility>
#include <vector>
@@ -1004,21 +1006,47 @@ void DWARFContext::dump(
DObj->getAbbrevDWOSection()))
getDebugAbbrevDWO()->dump(OS);
+ std::unordered_map<uint64_t, DWARFUnit *> DwoIDToDUMap;
+ auto SetSections = [&](DWARFUnit &U) -> void {
+ std::optional<uint64_t> DWOID = U.getDWOId();
+ if (U.isDWOUnit() && DWOID) {
+ auto MapIter = DwoIDToDUMap.find(*DWOID);
+ if (MapIter != DwoIDToDUMap.end()) {
+ DWARFDie UnitDie = MapIter->second->getUnitDIE();
+ std::optional<uint64_t> RangeBase = UnitDie.getRangesBaseAttribute();
+ if (U.getVersion() < 5 && RangeBase)
+ U.setRangesSection(&MainBinaryDObj->getRangesSection(), *RangeBase);
+ if (std::optional<uint64_t> AddrBase =
+ MapIter->second->getAddrOffsetSectionBase())
+ U.setAddrOffsetSection(&MainBinaryDObj->getAddrSection(), *AddrBase);
+ }
+ }
+ };
auto dumpDebugInfo = [&](const char *Name, unit_iterator_range Units) {
OS << '\n' << Name << " contents:\n";
if (auto DumpOffset = DumpOffsets[DIDT_ID_DebugInfo])
- for (const auto &U : Units)
+ for (const auto &U : Units) {
+ SetSections(*U);
U->getDIEForOffset(*DumpOffset)
.dump(OS, 0, DumpOpts.noImplicitRecursion());
+ }
else
- for (const auto &U : Units)
+ for (const auto &U : Units) {
+ SetSections(*U);
U->dump(OS, DumpOpts);
+ }
};
if ((DumpType & DIDT_DebugInfo)) {
if (Explicit || getNumCompileUnits())
dumpDebugInfo(".debug_info", info_section_units());
- if (ExplicitDWO || getNumDWOCompileUnits())
+ if (ExplicitDWO || getNumDWOCompileUnits()) {
+ if (MainBinaryDObj) {
+ for (const auto &U : MainBinaryDICtx->compile_units())
+ if (std::optional<uint64_t> DWOID = U->getDWOId())
+ DwoIDToDUMap.insert({*DWOID, U.get()});
+ }
dumpDebugInfo(".debug_info.dwo", dwo_info_section_units());
+ }
}
auto dumpDebugType = [&](const char *Name, unit_iterator_range Units) {
@@ -2428,3 +2456,15 @@ uint8_t DWARFContext::getCUAddrSize() {
auto CUs = compile_units();
return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize();
}
+
+void DWARFContext::setMainBinaryObjAndCreateContext(
+ const object::ObjectFile &Obj, ProcessDebugRelocations RelocAction,
+ const LoadedObjectInfo *L,
+ std::function<void(Error)> RecoverableErrorHandler,
+ std::function<void(Error)> WarningHandler) {
+ MainBinaryDObj = std::make_unique<DWARFObjInMemory>(
+ Obj, L, RecoverableErrorHandler, WarningHandler, RelocAction);
+ MainBinaryDICtx =
+ DWARFContext::create(Obj, DWARFContext::ProcessDebugRelocations::Process,
+ nullptr, "", RecoverableErrorHandler);
+}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 387345a4ac2d601..6d6759d892d9396 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -366,8 +366,11 @@ Error DWARFUnit::extractRangeList(uint64_t RangeListOffset,
DWARFDebugRangeList &RangeList) const {
// Require that compile unit is extracted.
assert(!DieArray.empty());
- DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
- IsLittleEndian, getAddressByteSize());
+ DWARFDataExtractor RangesData(isDWOUnit() && Context.getMainBinaryDWARFObj()
+ ? *Context.getMainBinaryDWARFObj()
+ : Context.getDWARFObj(),
+ *RangeSection, IsLittleEndian,
+ getAddressByteSize());
uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
return RangeList.extract(RangesData, &ActualRangeListOffset);
}
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 8180ad2138f41fe..3588b49c012f379 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -154,6 +154,11 @@ static std::array<std::optional<uint64_t>, (unsigned)DIDT_ID_Count> DumpOffsets;
static alias DumpDebugFrameAlias("eh-frame", desc("Alias for --debug-frame"),
NotHidden, cat(SectionCategory),
aliasopt(DumpDebugFrame));
+static cl::opt<std::string>
+ MainBinary("main-binary",
+ desc("Specifies the main binary for cases when .dwo/.dwp file "
+ "is processed."),
+ cl::init(""), cat(DwarfDumpCategory));
static list<std::string>
ArchFilters("arch",
desc("Dump debug information for the specified CPU "
@@ -714,6 +719,9 @@ static bool handleArchive(StringRef Filename, Archive &Arch,
static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
HandlerFn HandleObj, raw_ostream &OS) {
Expected<std::unique_ptr<Binary>> BinOrErr = object::createBinary(Buffer);
+ std::unique_ptr<MemoryBuffer> MainBuffer = nullptr;
+ ErrorOr<std::unique_ptr<MemoryBuffer>> MainBuffOrErr = nullptr;
+ std::unique_ptr<Binary> MainBin = nullptr;
error(Filename, BinOrErr.takeError());
bool Result = true;
@@ -727,6 +735,19 @@ static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
*Obj, DWARFContext::ProcessDebugRelocations::Process, nullptr, "",
RecoverableErrorHandler);
DICtx->setParseCUTUIndexManually(ManuallyGenerateUnitIndex);
+ if (!MainBinary.empty()) {
+ MainBuffOrErr = MemoryBuffer::getFileOrSTDIN(MainBinary);
+ error(MainBinary, MainBuffOrErr.getError());
+ MainBuffer = std::move(MainBuffOrErr.get());
+ Expected<std::unique_ptr<Binary>> MainBinOrErr =
+ object::createBinary(*MainBuffer);
+ error(MainBinary, MainBinOrErr.takeError());
+ MainBin = std::move(MainBinOrErr.get());
+ if (auto *Obj = dyn_cast<ObjectFile>(MainBin.get()))
+ DICtx->setMainBinaryObjAndCreateContext(
+ *Obj, DWARFContext::ProcessDebugRelocations::Process, nullptr,
+ RecoverableErrorHandler);
+ }
if (!HandleObj(*Obj, *DICtx, Filename, OS))
Result = false;
}
>From cae691e44aecd8c1f4ae485811f86ee728edf7d7 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Tue, 3 Oct 2023 10:23:28 -0700
Subject: [PATCH 2/2] [LLVM][DWARF] Add support for monolithic types in
.debug_names
Summary:
Adding support for Type Units in monolithic DWARF in .debug_names.
---
llvm/include/llvm/CodeGen/AccelTable.h | 35 +++-
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 172 ++++++++++++------
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 31 +++-
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 11 ++
llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 4 +
llvm/lib/CodeGen/AsmPrinter/DwarfFile.h | 14 ++
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 4 +
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 9 +
llvm/lib/DWARFLinker/DWARFStreamer.cpp | 13 +-
.../DWARFLinkerParallel/DWARFEmitterImpl.cpp | 18 +-
.../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 2 +-
.../test/DebugInfo/X86/accel-tables-dwarf5.ll | 1 -
.../test/DebugInfo/X86/debug-names-dwarf64.ll | 22 ++-
.../X86/debug-names-types-monolithic.ll | 168 +++++++++++++++++
.../DebugInfo/X86/debug-names-types-split.ll | 57 ++++++
.../DebugInfo/X86/dwarfdump-debug-names.s | 36 ++--
.../X86/debug-names-misaligned.s | 2 +-
17 files changed, 489 insertions(+), 110 deletions(-)
create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll
diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h
index d521b31e3d16ab4..537f6a4d42bef0e 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -106,6 +106,7 @@ namespace llvm {
class AsmPrinter;
class DwarfCompileUnit;
class DwarfDebug;
+class DwarfTypeUnit;
class MCSymbol;
class raw_ostream;
@@ -197,6 +198,9 @@ template <typename DataT> class AccelTable : public AccelTableBase {
template <typename... Types>
void addName(DwarfStringPoolEntryRef Name, Types &&... Args);
+ void clear() { Entries.clear(); }
+ void addEntries(AccelTable<DataT> &Table);
+ const StringEntries getEntries() const { return Entries; }
};
template <typename AccelTableDataT>
@@ -215,6 +219,16 @@ void AccelTable<AccelTableDataT>::addName(DwarfStringPoolEntryRef Name,
AccelTableDataT(std::forward<Types>(Args)...));
}
+template <typename AccelTableDataT>
+void AccelTable<AccelTableDataT>::addEntries(
+ AccelTable<AccelTableDataT> &Table) {
+ for (auto &Entry : Table.getEntries()) {
+ for (AccelTableData *Value : Entry.second.Values)
+ addName(Entry.second.Name,
+ static_cast<AccelTableDataT *>(Value)->getDie());
+ }
+}
+
/// A base class for different implementations of Data classes for Apple
/// Accelerator Tables. The columns in the table are defined by the static Atoms
/// variable defined on the subclasses.
@@ -250,6 +264,10 @@ class AppleAccelTableData : public AccelTableData {
/// emitDWARF5AccelTable function.
class DWARF5AccelTableData : public AccelTableData {
public:
+ struct AttributeEncoding {
+ dwarf::Index Index;
+ dwarf::Form Form;
+ };
static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
DWARF5AccelTableData(const DIE &Die) : Die(Die) {}
@@ -309,17 +327,20 @@ void emitAppleAccelTable(AsmPrinter *Asm, AccelTable<DataT> &Contents,
void emitDWARF5AccelTable(AsmPrinter *Asm,
AccelTable<DWARF5AccelTableData> &Contents,
const DwarfDebug &DD,
- ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs);
-
+ ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs,
+ ArrayRef<std::unique_ptr<DwarfTypeUnit>> TUs);
+using GetIndexForEntryReturnType =
+ std::optional<std::pair<unsigned, DWARF5AccelTableData::AttributeEncoding>>;
/// Emit a DWARFv5 Accelerator Table consisting of entries in the specified
/// AccelTable. The \p CUs contains either symbols keeping offsets to the
/// start of compilation unit, either offsets to the start of compilation
/// unit themselves.
-void emitDWARF5AccelTable(
- AsmPrinter *Asm, AccelTable<DWARF5AccelTableStaticData> &Contents,
- ArrayRef<std::variant<MCSymbol *, uint64_t>> CUs,
- llvm::function_ref<unsigned(const DWARF5AccelTableStaticData &)>
- getCUIndexForEntry);
+void emitDWARF5AccelTable(AsmPrinter *Asm,
+ AccelTable<DWARF5AccelTableStaticData> &Contents,
+ ArrayRef<std::variant<MCSymbol *, uint64_t>> CUs,
+ llvm::function_ref<GetIndexForEntryReturnType(
+ const DWARF5AccelTableStaticData &)>
+ getIndexForEntry);
/// Accelerator table data implementation for simple Apple accelerator tables
/// with just a DIE reference.
diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
index 8f936037d132537..5510932e96d2598 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
@@ -13,7 +13,6 @@
#include "llvm/CodeGen/AccelTable.h"
#include "DwarfCompileUnit.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/AsmPrinter.h"
@@ -200,32 +199,30 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
uint32_t AugmentationStringSize = sizeof(AugmentationString);
char AugmentationString[8] = {'L', 'L', 'V', 'M', '0', '7', '0', '0'};
- Header(uint32_t CompUnitCount, uint32_t BucketCount, uint32_t NameCount)
- : CompUnitCount(CompUnitCount), BucketCount(BucketCount),
- NameCount(NameCount) {}
+ Header(uint32_t CompUnitCount, uint32_t LocalTypeUnitCount,
+ uint32_t BucketCount, uint32_t NameCount)
+ : CompUnitCount(CompUnitCount), LocalTypeUnitCount(LocalTypeUnitCount),
+ BucketCount(BucketCount), NameCount(NameCount) {}
void emit(Dwarf5AccelTableWriter &Ctx);
};
- struct AttributeEncoding {
- dwarf::Index Index;
- dwarf::Form Form;
- };
Header Header;
- DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
+ DenseMap<uint32_t, SmallVector<DWARF5AccelTableData::AttributeEncoding, 2>>
+ Abbreviations;
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits;
- llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry;
+ ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits;
+ llvm::function_ref<GetIndexForEntryReturnType(const DataT &)>
+ getIndexForEntry;
MCSymbol *ContributionEnd = nullptr;
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 populateAbbrevsMap();
void emitCUList() const;
+ void emitTUList() const;
void emitBuckets() const;
void emitStringOffsets() const;
void emitAbbrevs() const;
@@ -236,7 +233,9 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
Dwarf5AccelTableWriter(
AsmPrinter *Asm, const AccelTableBase &Contents,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
- llvm::function_ref<unsigned(const DataT &)> GetCUIndexForEntry);
+ ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits,
+ llvm::function_ref<GetIndexForEntryReturnType(const DataT &)>
+ getIndexForEntry);
void emit();
};
@@ -388,31 +387,39 @@ void Dwarf5AccelTableWriter<DataT>::Header::emit(Dwarf5AccelTableWriter &Ctx) {
Asm->OutStreamer->emitBytes({AugmentationString, AugmentationStringSize});
}
+static uint32_t constexpr LowerBitSize = dwarf::DW_IDX_type_hash;
+static uint32_t getTagFromAbbreviationTag(const uint32_t AbbrvTag) {
+ return AbbrvTag >> LowerBitSize;
+}
+static uint32_t
+constructAbbreviationTag(const unsigned Tag,
+ const GetIndexForEntryReturnType &EntryRet) {
+ uint32_t AbbrvTag = 0;
+ if (EntryRet)
+ AbbrvTag |= 1 << EntryRet->second.Index;
+ AbbrvTag |= 1 << dwarf::DW_IDX_die_offset;
+ AbbrvTag |= Tag << LowerBitSize;
+ return AbbrvTag;
+}
template <typename DataT>
-DenseSet<uint32_t> Dwarf5AccelTableWriter<DataT>::getUniqueTags() const {
- DenseSet<uint32_t> UniqueTags;
+void Dwarf5AccelTableWriter<DataT>::populateAbbrevsMap() {
for (auto &Bucket : Contents.getBuckets()) {
for (auto *Hash : Bucket) {
for (auto *Value : Hash->Values) {
+ GetIndexForEntryReturnType EntryRet =
+ getIndexForEntry(*static_cast<const DataT *>(Value));
unsigned Tag = static_cast<const DataT *>(Value)->getDieTag();
- UniqueTags.insert(Tag);
+ uint32_t AbbrvTag = constructAbbreviationTag(Tag, EntryRet);
+ if (Abbreviations.count(AbbrvTag) == 0) {
+ SmallVector<DWARF5AccelTableData::AttributeEncoding, 2> UA;
+ if (EntryRet)
+ UA.push_back(EntryRet->second);
+ UA.push_back({dwarf::DW_IDX_die_offset, dwarf::DW_FORM_ref4});
+ Abbreviations.try_emplace(AbbrvTag, UA);
+ }
}
}
}
- return UniqueTags;
-}
-
-template <typename DataT>
-SmallVector<typename Dwarf5AccelTableWriter<DataT>::AttributeEncoding, 2>
-Dwarf5AccelTableWriter<DataT>::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;
}
template <typename DataT>
@@ -426,6 +433,17 @@ void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
}
}
+template <typename DataT>
+void Dwarf5AccelTableWriter<DataT>::emitTUList() const {
+ for (const auto &TU : enumerate(TypeUnits)) {
+ Asm->OutStreamer->AddComment("Type unit " + Twine(TU.index()));
+ if (std::holds_alternative<MCSymbol *>(TU.value()))
+ Asm->emitDwarfSymbolReference(std::get<MCSymbol *>(TU.value()));
+ else
+ Asm->emitDwarfLengthOrOffset(std::get<uint64_t>(TU.value()));
+ }
+}
+
template <typename DataT>
void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
uint32_t Index = 1;
@@ -453,10 +471,11 @@ void Dwarf5AccelTableWriter<DataT>::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));
+ uint32_t Tag = getTagFromAbbreviationTag(Abbrev.first);
+ assert(Tag != 0);
Asm->emitULEB128(Abbrev.first);
+ Asm->OutStreamer->AddComment(dwarf::TagString(Tag));
+ Asm->emitULEB128(Tag);
for (const auto &AttrEnc : Abbrev.second) {
Asm->emitULEB128(AttrEnc.Index, dwarf::IndexString(AttrEnc.Index).data());
Asm->emitULEB128(AttrEnc.Form,
@@ -471,16 +490,21 @@ void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
template <typename DataT>
void Dwarf5AccelTableWriter<DataT>::emitEntry(const DataT &Entry) const {
- auto AbbrevIt = Abbreviations.find(Entry.getDieTag());
+ GetIndexForEntryReturnType EntryRet = getIndexForEntry(Entry);
+ uint32_t AbbrvTag = constructAbbreviationTag(Entry.getDieTag(), EntryRet);
+ auto AbbrevIt = Abbreviations.find(AbbrvTag);
assert(AbbrevIt != Abbreviations.end() &&
"Why wasn't this abbrev generated?");
-
+ assert(getTagFromAbbreviationTag(AbbrevIt->first) == Entry.getDieTag() &&
+ "Invalid Tag");
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: {
- DIEInteger ID(getCUIndexForEntry(Entry));
+ case dwarf::DW_IDX_compile_unit:
+ case dwarf::DW_IDX_type_unit: {
+ DIEInteger ID(EntryRet->first);
ID.emitValue(Asm, AttrEnc.Form);
break;
}
@@ -512,22 +536,21 @@ template <typename DataT>
Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
AsmPrinter *Asm, const AccelTableBase &Contents,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
- llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry)
+ ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits,
+ llvm::function_ref<GetIndexForEntryReturnType(const DataT &)>
+ getIndexForEntry)
: AccelTableWriter(Asm, Contents, false),
- Header(CompUnits.size(), Contents.getBucketCount(),
+ Header(CompUnits.size(), TypeUnits.size(), Contents.getBucketCount(),
Contents.getUniqueNameCount()),
- CompUnits(CompUnits), getCUIndexForEntry(std::move(getCUIndexForEntry)) {
- DenseSet<uint32_t> UniqueTags = getUniqueTags();
- SmallVector<AttributeEncoding, 2> UniformAttributes = getUniformAttributes();
-
- Abbreviations.reserve(UniqueTags.size());
- for (uint32_t Tag : UniqueTags)
- Abbreviations.try_emplace(Tag, UniformAttributes);
+ CompUnits(CompUnits), TypeUnits(TypeUnits),
+ getIndexForEntry(std::move(getIndexForEntry)) {
+ populateAbbrevsMap();
}
template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emit() {
Header.emit(*this);
emitCUList();
+ emitTUList();
emitBuckets();
emitHashes();
emitStringOffsets();
@@ -545,12 +568,17 @@ void llvm::emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
AppleAccelTableWriter(Asm, Contents, Atoms, SecBegin).emit();
}
-void llvm::emitDWARF5AccelTable(
- AsmPrinter *Asm, AccelTable<DWARF5AccelTableData> &Contents,
- const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) {
+void llvm::emitDWARF5AccelTable(AsmPrinter *Asm,
+ AccelTable<DWARF5AccelTableData> &Contents,
+ const DwarfDebug &DD,
+ ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs,
+ ArrayRef<std::unique_ptr<DwarfTypeUnit>> TUs) {
std::vector<std::variant<MCSymbol *, uint64_t>> CompUnits;
+ std::vector<std::variant<MCSymbol *, uint64_t>> TypeUnits;
SmallVector<unsigned, 1> CUIndex(CUs.size());
- int Count = 0;
+ DenseMap<const DIE *, unsigned> TUIndex(TUs.size());
+ int CUCount = 0;
+ int TUCount = 0;
for (const auto &CU : enumerate(CUs)) {
switch (CU.value()->getCUNode()->getNameTableKind()) {
case DICompileUnit::DebugNameTableKind::Default:
@@ -559,13 +587,25 @@ void llvm::emitDWARF5AccelTable(
default:
continue;
}
- CUIndex[CU.index()] = Count++;
+ CUIndex[CU.index()] = CUCount++;
assert(CU.index() == CU.value()->getUniqueID());
const DwarfCompileUnit *MainCU =
DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get();
CompUnits.push_back(MainCU->getLabelBegin());
}
+ for (const auto &TU : enumerate(TUs)) {
+ switch (TU.value()->getCUNode()->getNameTableKind()) {
+ case DICompileUnit::DebugNameTableKind::Default:
+ break;
+ default:
+ continue;
+ }
+ TUIndex[&TU.value()->getUnitDie()] = TUCount++;
+ const DwarfTypeUnit *MainTU = TU.value().get();
+ TypeUnits.push_back(MainTU->getLabelBegin());
+ }
+
if (CompUnits.empty())
return;
@@ -573,11 +613,21 @@ void llvm::emitDWARF5AccelTable(
Asm->getObjFileLowering().getDwarfDebugNamesSection());
Contents.finalize(Asm, "names");
+ dwarf::Form CUIndexForm =
+ DIEInteger::BestForm(/*IsSigned*/ false, CompUnits.size() - 1);
+ dwarf::Form TUIndexForm =
+ DIEInteger::BestForm(/*IsSigned*/ false, TypeUnits.size() - 1);
Dwarf5AccelTableWriter<DWARF5AccelTableData>(
- Asm, Contents, CompUnits,
- [&](const DWARF5AccelTableData &Entry) {
+ Asm, Contents, CompUnits, TypeUnits,
+ [&](const DWARF5AccelTableData &Entry) -> GetIndexForEntryReturnType {
const DIE *CUDie = Entry.getDie().getUnitDie();
- return CUIndex[DD.lookupCU(CUDie)->getUniqueID()];
+ GetIndexForEntryReturnType Index = std::nullopt;
+ if (CUDie->getTag() == dwarf::DW_TAG_type_unit)
+ Index = {TUIndex[CUDie], {dwarf::DW_IDX_type_unit, TUIndexForm}};
+ else if (CUIndex.size() > 1)
+ Index = {CUIndex[DD.lookupCU(CUDie)->getUniqueID()],
+ {dwarf::DW_IDX_compile_unit, CUIndexForm}};
+ return Index;
})
.emit();
}
@@ -585,11 +635,13 @@ void llvm::emitDWARF5AccelTable(
void llvm::emitDWARF5AccelTable(
AsmPrinter *Asm, AccelTable<DWARF5AccelTableStaticData> &Contents,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CUs,
- llvm::function_ref<unsigned(const DWARF5AccelTableStaticData &)>
- getCUIndexForEntry) {
+ llvm::function_ref<
+ GetIndexForEntryReturnType(const DWARF5AccelTableStaticData &)>
+ getIndexForEntry) {
+ std::vector<std::variant<MCSymbol *, uint64_t>> TypeUnits;
Contents.finalize(Asm, "names");
- Dwarf5AccelTableWriter<DWARF5AccelTableStaticData>(Asm, Contents, CUs,
- getCUIndexForEntry)
+ Dwarf5AccelTableWriter<DWARF5AccelTableStaticData>(
+ Asm, Contents, CUs, TypeUnits, getIndexForEntry)
.emit();
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index ee2ab71ad28e47f..8a680dd9c6976e0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -305,6 +305,7 @@ void Loc::MMI::addFrameIndexExpr(const DIExpression *Expr, int FI) {
static AccelTableKind computeAccelTableKind(unsigned DwarfVersion,
bool GenerateTypeUnits,
+ bool HasSplitDwarf,
DebuggerKind Tuning,
const Triple &TT) {
// Honor an explicit request.
@@ -312,7 +313,8 @@ static AccelTableKind computeAccelTableKind(unsigned DwarfVersion,
return AccelTables;
// Accelerator tables with type units are currently not supported.
- if (GenerateTypeUnits)
+ if (GenerateTypeUnits &&
+ (DwarfVersion < 5 || HasSplitDwarf || !TT.isOSBinFormatELF()))
return AccelTableKind::None;
// Accelerator tables get emitted if targetting DWARF v5 or LLDB. DWARF v5
@@ -325,6 +327,9 @@ static AccelTableKind computeAccelTableKind(unsigned DwarfVersion,
: AccelTableKind::Dwarf;
return AccelTableKind::None;
}
+void DwarfDebug::addTypeUnit(std::unique_ptr<DwarfTypeUnit> U) {
+ InfoHolder.addTypeUnit(std::move(U));
+}
DwarfDebug::DwarfDebug(AsmPrinter *A)
: DebugHandlerBase(A), DebugLocs(A->OutStreamer->isVerboseAsm()),
@@ -400,8 +405,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
A->TM.getTargetTriple().isOSBinFormatWasm()) &&
GenerateDwarfTypeUnits;
- TheAccelTableKind = computeAccelTableKind(
- DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple());
+ TheAccelTableKind =
+ computeAccelTableKind(DwarfVersion, GenerateTypeUnits, HasSplitDwarf,
+ DebuggerTuning, A->TM.getTargetTriple());
// Work around a GDB bug. GDB doesn't support the standard opcode;
// SCE doesn't support GNU's; LLDB prefers the standard opcode, which
@@ -2394,7 +2400,7 @@ void DwarfDebug::emitAccelDebugNames() {
if (getUnits().empty())
return;
- emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits());
+ emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits(), getTypeUnits());
}
// Emit visible names into a hashed accelerator table section.
@@ -3499,7 +3505,7 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
// Types referencing entries in the address table cannot be placed in type
// units.
if (AddrPool.hasBeenUsed()) {
-
+ AccelTypeUntsDebugNames.clear();
// Remove all the types built while building this type.
// This is pessimistic as some of these types might not be dependent on
// the type that used an address.
@@ -3514,11 +3520,15 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
return;
}
- // If the type wasn't dependent on fission addresses, finish adding the type
- // and all its dependent types.
for (auto &TU : TypeUnitsToAdd) {
InfoHolder.computeSizeAndOffsetsForUnit(TU.first.get());
InfoHolder.emitUnit(TU.first.get(), useSplitDwarf());
+ if (getDwarfVersion() >= 5 &&
+ getAccelTableKind() == AccelTableKind::Dwarf) {
+ addTypeUnit(std::move(TU.first));
+ AccelDebugNames.addEntries(AccelTypeUntsDebugNames);
+ AccelTypeUntsDebugNames.clear();
+ }
}
}
CU.addDIETypeSignature(RefDie, Signature);
@@ -3548,7 +3558,12 @@ void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU,
AppleAccel.addName(Ref, Die);
break;
case AccelTableKind::Dwarf:
- AccelDebugNames.addName(Ref, Die);
+ // The type unit can be discarded, so need to add references to final
+ // acceleration table once we know it's complete and we emit it.
+ if (TypeUnitsUnderConstruction.empty())
+ AccelDebugNames.addName(Ref, Die);
+ else
+ AccelTypeUntsDebugNames.addName(Ref, Die);
break;
case AccelTableKind::Default:
llvm_unreachable("Default should have already been resolved.");
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 75649a747602ef5..f6870d514ea0ee7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -497,6 +497,7 @@ class DwarfDebug : public DebugHandlerBase {
/// Accelerator tables.
AccelTable<DWARF5AccelTableData> AccelDebugNames;
+ AccelTable<DWARF5AccelTableData> AccelTypeUntsDebugNames;
AccelTable<AppleAccelTableOffsetData> AccelNames;
AccelTable<AppleAccelTableOffsetData> AccelObjC;
AccelTable<AppleAccelTableOffsetData> AccelNamespace;
@@ -515,6 +516,13 @@ class DwarfDebug : public DebugHandlerBase {
return InfoHolder.getUnits();
}
+ /// Returns Type Units constructed for this module.
+ const SmallVectorImpl<std::unique_ptr<DwarfTypeUnit>> &getTypeUnits() {
+ return InfoHolder.getTypeUnits();
+ }
+
+ void addTypeUnit(std::unique_ptr<DwarfTypeUnit> U);
+
using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
@@ -780,6 +788,9 @@ class DwarfDebug : public DebugHandlerBase {
/// Returns what kind (if any) of accelerator tables to emit.
AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
+ /// Seet TheAccelTableKind
+ void setTheAccelTableKind(AccelTableKind K) { TheAccelTableKind = K; };
+
bool useAppleExtensionAttributes() const {
return HasAppleExtensionAttributes;
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index eab798c0da78438..5de7c91f021a871 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -24,6 +24,10 @@ void DwarfFile::addUnit(std::unique_ptr<DwarfCompileUnit> U) {
CUs.push_back(std::move(U));
}
+void DwarfFile::addTypeUnit(std::unique_ptr<DwarfTypeUnit> U) {
+ TUs.push_back(std::move(U));
+}
+
// Emit the various dwarf units to the unit section USection with
// the abbreviations going into ASection.
void DwarfFile::emitUnits(bool UseOffsets) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
index f76858fc2f36a02..452a8f82379cd5f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -28,6 +28,7 @@ class DbgLabel;
class DINode;
class DILocalScope;
class DwarfCompileUnit;
+class DwarfTypeUnit;
class DwarfUnit;
class LexicalScope;
class MCSection;
@@ -59,6 +60,9 @@ class DwarfFile {
// A pointer to all units in the section.
SmallVector<std::unique_ptr<DwarfCompileUnit>, 1> CUs;
+ // A pointer to all type units in the section.
+ SmallVector<std::unique_ptr<DwarfTypeUnit>, 1> TUs;
+
DwarfStringPool StrPool;
// List of range lists for a given compile unit, separate from the ranges for
@@ -103,6 +107,11 @@ class DwarfFile {
return CUs;
}
+ /// Returns type units that were constructed.
+ const SmallVectorImpl<std::unique_ptr<DwarfTypeUnit>> &getTypeUnits() {
+ return TUs;
+ }
+
std::pair<uint32_t, RangeSpanList *> addRange(const DwarfCompileUnit &CU,
SmallVector<RangeSpan, 2> R);
@@ -124,6 +133,11 @@ class DwarfFile {
/// Add a unit to the list of CUs.
void addUnit(std::unique_ptr<DwarfCompileUnit> U);
+ /// Add a unit to the list of TUs.
+ /// Preserves type unit so that memory is not released before DWARF5
+ /// accelerator table is created.
+ void addTypeUnit(std::unique_ptr<DwarfTypeUnit> U);
+
/// Emit all of the units to the section listed with the given
/// abbreviation section.
void emitUnits(bool UseOffsets);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index d30f0ef7af348af..620f4288bd72025 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1778,6 +1778,10 @@ void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) {
}
void DwarfTypeUnit::emitHeader(bool UseOffsets) {
+ if (!DD->useSplitDwarf()) {
+ LabelBegin = Asm->createTempSymbol("tu_begin");
+ Asm->OutStreamer->emitLabel(LabelBegin);
+ }
DwarfUnit::emitCommonHeader(UseOffsets,
DD->useSplitDwarf() ? dwarf::DW_UT_split_type
: dwarf::DW_UT_type);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 8f17e94c2d1c331..1cda82db0b269dd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -362,6 +362,8 @@ class DwarfTypeUnit final : public DwarfUnit {
DwarfCompileUnit &CU;
MCDwarfDwoLineTable *SplitLineTable;
bool UsedLineTable = false;
+ /// The start of the type unit within .debug_nfo section.
+ MCSymbol *LabelBegin = nullptr;
unsigned getOrCreateSourceID(const DIFile *File) override;
void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override;
@@ -372,6 +374,8 @@ class DwarfTypeUnit final : public DwarfUnit {
DwarfFile *DWU, MCDwarfDwoLineTable *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
+ /// Returns Type Signature.
+ uint64_t getTypeSignature() const { return TypeSignature; }
void setType(const DIE *Ty) { this->Ty = Ty; }
/// Emit the header for this unit, not including the initial length field.
@@ -385,6 +389,11 @@ class DwarfTypeUnit final : public DwarfUnit {
void addGlobalType(const DIType *Ty, const DIE &Die,
const DIScope *Context) override;
DwarfCompileUnit &getCU() override { return CU; }
+ /// Get the the symbol for start of the section for this type unit.
+ MCSymbol *getLabelBegin() const {
+ assert(LabelBegin && "LabelBegin is not initialized");
+ return LabelBegin;
+ }
};
} // end llvm namespace
#endif
diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
index ff719d0a59bafaa..e097e3f742d115a 100644
--- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
@@ -307,10 +307,19 @@ void DwarfStreamer::emitDebugNames(
}
Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection());
+ dwarf::Form Form =
+ DIEInteger::BestForm(/*IsSigned*/ false, UniqueIdToCuMap.size() - 1);
+ /// llvm-dwarfutil doesn't support type units + .debug_names right now anyway,
+ /// so just keeping current behavior.
emitDWARF5AccelTable(
Asm.get(), Table, CompUnits,
- [&UniqueIdToCuMap](const DWARF5AccelTableStaticData &Entry) {
- return UniqueIdToCuMap[Entry.getCUIndex()];
+ [&UniqueIdToCuMap, &Form](const DWARF5AccelTableStaticData &Entry)
+ -> GetIndexForEntryReturnType {
+ GetIndexForEntryReturnType Index = std::nullopt;
+ if (UniqueIdToCuMap.size() > 1)
+ Index = {UniqueIdToCuMap[Entry.getCUIndex()],
+ {dwarf::DW_IDX_compile_unit, Form}};
+ return Index;
});
}
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp
index 7885e3013a51d3f..02c8f940af618f9 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp
+++ b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp
@@ -230,10 +230,20 @@ void DwarfEmitterImpl::emitDebugNames(
return;
Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection());
- emitDWARF5AccelTable(Asm.get(), Table, CUOffsets,
- [&CUidToIdx](const DWARF5AccelTableStaticData &Entry) {
- return CUidToIdx[Entry.getCUIndex()];
- });
+ dwarf::Form Form =
+ DIEInteger::BestForm(/*IsSigned*/ false, CUidToIdx.size() - 1);
+ /// DWARFLinker doesn't support type units + .debug_names right now anyway,
+ /// so just keeping current behavior.
+ emitDWARF5AccelTable(
+ Asm.get(), Table, CUOffsets,
+ [&CUidToIdx, &Form](const DWARF5AccelTableStaticData &Entry)
+ -> GetIndexForEntryReturnType {
+ GetIndexForEntryReturnType Index = std::nullopt;
+ if (CUidToIdx.size() > 1)
+ Index = {CUidToIdx[Entry.getCUIndex()],
+ {dwarf::DW_IDX_compile_unit, Form}};
+ return Index;
+ });
}
void DwarfEmitterImpl::emitAppleNamespaces(
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 7d8289ed420abb9..2c090599c22cd67 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -635,7 +635,7 @@ std::optional<uint64_t> DWARFDebugNames::Entry::getCUOffset() const {
}
void DWARFDebugNames::Entry::dump(ScopedPrinter &W) const {
- W.printHex("Abbrev", Abbr->Code);
+ DictScope AbbrevScope(W, ("Abbrev: 0x" + Twine::utohexstr(Abbr->Code)).str());
W.startLine() << formatv("Tag: {0}\n", Abbr->Tag);
assert(Abbr->Attributes.size() == Values.size());
for (auto Tuple : zip_first(Abbr->Attributes, Values)) {
diff --git a/llvm/test/DebugInfo/X86/accel-tables-dwarf5.ll b/llvm/test/DebugInfo/X86/accel-tables-dwarf5.ll
index e7cf7968003d9a6..243dea608a2d7f7 100644
--- a/llvm/test/DebugInfo/X86/accel-tables-dwarf5.ll
+++ b/llvm/test/DebugInfo/X86/accel-tables-dwarf5.ll
@@ -22,7 +22,6 @@
; RUN: | llvm-readobj --sections - | FileCheck --check-prefix=DEBUG_NAMES %s
; NONE-NOT: apple_names
-; NONE-NOT: debug_names
; DEBUG_NAMES-NOT: apple_names
; DEBUG_NAMES: debug_names
diff --git a/llvm/test/DebugInfo/X86/debug-names-dwarf64.ll b/llvm/test/DebugInfo/X86/debug-names-dwarf64.ll
index 3fc91ef85df1fb8..f3b1d5c88996a21 100644
--- a/llvm/test/DebugInfo/X86/debug-names-dwarf64.ll
+++ b/llvm/test/DebugInfo/X86/debug-names-dwarf64.ll
@@ -26,12 +26,12 @@
; CHECK-NEXT: CU[0]: 0x00000000
; CHECK-NEXT: ]
; CHECK-NEXT: Abbreviations [
-; CHECK-NEXT: Abbreviation 0x34 {
-; CHECK-NEXT: Tag: DW_TAG_variable
+; CHECK-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; CHECK-NEXT: }
-; CHECK-NEXT: Abbreviation 0x24 {
-; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_variable
; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; CHECK-NEXT: }
; CHECK-NEXT: ]
@@ -40,9 +40,10 @@
; CHECK-NEXT: Hash: 0xB888030
; CHECK-NEXT: String: {{.+}} "int"
; CHECK-NEXT: Entry @ {{.+}} {
-; CHECK-NEXT: Abbrev: 0x24
-; CHECK-NEXT: Tag: DW_TAG_base_type
-; CHECK-NEXT: DW_IDX_die_offset: [[TYPEDIE]]
+; CHECK-NEXT: Abbrev: [[ABBREV]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: DW_IDX_die_offset: [[TYPEDIE]]
+; CHECK-NEXT: }
; CHECK-NEXT: }
; CHECK-NEXT: }
; CHECK-NEXT: ]
@@ -51,9 +52,10 @@
; CHECK-NEXT: Hash: 0xB887389
; CHECK-NEXT: String: {{.+}} "foo"
; CHECK-NEXT: Entry @ {{.+}} {
-; CHECK-NEXT: Abbrev: 0x34
-; CHECK-NEXT: Tag: DW_TAG_variable
-; CHECK-NEXT: DW_IDX_die_offset: [[VARDIE]]
+; CHECK-NEXT: Abbrev: [[ABBREV1]] {
+; CHECK-NEXT: Tag: DW_TAG_variable
+; CHECK-NEXT: DW_IDX_die_offset: [[VARDIE]]
+; CHECK-NEXT: }
; CHECK-NEXT: }
; CHECK-NEXT: }
; CHECK-NEXT: ]
diff --git a/llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll b/llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
new file mode 100644
index 000000000000000..e86a226fc880ac1
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
@@ -0,0 +1,168 @@
+; This checks that .debug_names can be generated with monolithic -fdebug-type-sections.
+
+; RUN: llc -mtriple=x86_64 -generate-type-units -dwarf-version=5 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-names %t | FileCheck %s
+
+; CHECK: .debug_info contents:
+; CHECK: DW_TAG_type_unit
+; CHECK-NEXT: DW_AT_language (DW_LANG_C_plus_plus_14)
+; CHECK-NEXT: DW_AT_stmt_list (0x00000000)
+; CHECK-NEXT: DW_AT_str_offsets_base (0x00000008)
+; CHECK: DW_TAG_structure_type
+; CHECK-NEXT: DW_AT_calling_convention (DW_CC_pass_by_value)
+; CHECK-NEXT: DW_AT_name ("Foo")
+; CHECK-NEXT: DW_AT_byte_size (0x08)
+; CHECK-NEXT: DW_AT_decl_file ("/typeSmall/main.cpp")
+; CHECK-NEXT: DW_AT_decl_line (1)
+; CHECK: DW_TAG_member
+; CHECK-NEXT: DW_AT_name ("c1")
+; CHECK-NEXT: DW_AT_type (0x00000033 "char *")
+; CHECK-NEXT: DW_AT_decl_file ("/typeSmall/main.cpp")
+; CHECK-NEXT: DW_AT_decl_line (2)
+; CHECK-NEXT: DW_AT_data_member_location (0x00)
+; CHECK: DW_TAG_pointer_type
+; CHECK-NEXT: DW_AT_type (0x00000038 "char")
+; CHECK: DW_TAG_base_type
+; CHECK-NEXT: DW_AT_name ("char")
+; CHECK-NEXT: DW_AT_encoding (DW_ATE_signed_char)
+; CHECK-NEXT: DW_AT_byte_size (0x01)
+; CHECK: .debug_names contents:
+; CHECK: Compilation Unit offsets [
+; CHECK-NEXT: CU[0]: 0x00000000
+; CHECK-NEXT: ]
+; CHECK-NEXT: Local Type Unit offsets [
+; CHECK-NEXT: LocalTU[0]: 0x00000000
+; CHECK-NEXT: ]
+; CHECK: Abbreviations [
+; CHECK-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_structure_type
+; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+; CHECK-NEXT: }
+; CHECK-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_structure_type
+; CHECK-NEXT: DW_IDX_type_unit: DW_FORM_data1
+; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+; CHECK-NEXT: }
+; CHECK-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+; CHECK-NEXT: }
+; CHECK-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_subprogram
+; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+; CHECK-NEXT: }
+; CHECK-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: DW_IDX_type_unit: DW_FORM_data1
+; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Bucket 0 [
+; CHECK-NEXT: Name 1 {
+; CHECK-NEXT: Hash: 0xB888030
+; CHECK-NEXT: String: {{.+}} "int"
+; CHECK-NEXT: Entry @ {{.+}} {
+; CHECK-NEXT: Abbrev: [[ABBREV]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: DW_IDX_die_offset: 0x0000003e
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Bucket 1 [
+; CHECK-NEXT: Name 2 {
+; CHECK-NEXT: Hash: 0xB887389
+; CHECK-NEXT: String: {{.+}} "Foo"
+; CHECK-NEXT: Entry @ {{.+}} {
+; CHECK-NEXT: Abbrev: [[ABBREV3]] {
+; CHECK-NEXT: Tag: DW_TAG_structure_type
+; CHECK-NEXT: DW_IDX_type_unit: 0x00
+; CHECK-NEXT: DW_IDX_die_offset: 0x00000023
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: Entry @ 0xaa {
+; CHECK-NEXT: Abbrev: [[ABBREV1]] {
+; CHECK-NEXT: Tag: DW_TAG_structure_type
+; CHECK-NEXT: DW_IDX_die_offset: 0x00000042
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Bucket 2 [
+; CHECK-NEXT: Name 3 {
+; CHECK-NEXT: Hash: 0x7C9A7F6A
+; CHECK-NEXT: String: {{.+}} "main"
+; CHECK-NEXT: Entry @ {{.+}} {
+; CHECK-NEXT: Abbrev: [[ABBREV2]] {
+; CHECK-NEXT: Tag: DW_TAG_subprogram
+; CHECK-NEXT: DW_IDX_die_offset: 0x00000023
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Bucket 3 [
+; CHECK-NEXT: Name 4 {
+; CHECK-NEXT: Hash: 0x7C952063
+; CHECK-NEXT: String: {{.+}} "char"
+; CHECK-NEXT: Entry @ {{.+}} {
+; CHECK-NEXT: Abbrev: [[ABBREV4]] {
+; CHECK-NEXT: Tag: DW_TAG_base_type
+; CHECK-NEXT: DW_IDX_type_unit: 0x00
+; CHECK-NEXT: DW_IDX_die_offset: 0x00000038
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: }
+
+
+; ModuleID = 'main.cpp'
+source_filename = "main.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.Foo = type { ptr }
+
+; Function Attrs: mustprogress noinline norecurse nounwind optnone uwtable
+define dso_local noundef i32 @main() #0 !dbg !10 {
+entry:
+ %retval = alloca i32, align 4
+ %f = alloca %struct.Foo, align 8
+ store i32 0, ptr %retval, align 4
+ call void @llvm.dbg.declare(metadata ptr %f, metadata !15, metadata !DIExpression()), !dbg !21
+ ret i32 0, !dbg !22
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { mustprogress noinline norecurse nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 18.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
+!1 = !DIFile(filename: "main.cpp", directory: "/typeSmall", checksumkind: CSK_MD5, checksum: "e5b402e9dbafe24c7adbb087d1f03549")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 18.0.0"}
+!10 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14)
+!11 = !DISubroutineType(types: !12)
+!12 = !{!13}
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !{}
+!15 = !DILocalVariable(name: "f", scope: !10, file: !1, line: 5, type: !16)
+!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !17, identifier: "_ZTS3Foo")
+!17 = !{!18}
+!18 = !DIDerivedType(tag: DW_TAG_member, name: "c1", scope: !16, file: !1, line: 2, baseType: !19, size: 64)
+!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
+!20 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!21 = !DILocation(line: 5, column: 6, scope: !10)
+!22 = !DILocation(line: 6, column: 2, scope: !10)
diff --git a/llvm/test/DebugInfo/X86/debug-names-types-split.ll b/llvm/test/DebugInfo/X86/debug-names-types-split.ll
new file mode 100644
index 000000000000000..d5908aeaf114a20
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug-names-types-split.ll
@@ -0,0 +1,57 @@
+; This checks that .debug_names is not generated with split-dwarf + -fdebug-type-sections.
+
+; RUN: llc -mtriple=x86_64 -generate-type-units -dwarf-version=5 -filetype=obj -split-dwarf-file=mainTypes.dwo --split-dwarf-output=mainTypes.dwo %s -o %t
+; RUN: llvm-readelf --sections %t | FileCheck %s
+
+; CHECK-NOT: .debug_names
+
+; ModuleID = 'main.cpp'
+source_filename = "main.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.Foo = type { ptr }
+
+; Function Attrs: mustprogress noinline norecurse nounwind optnone uwtable
+define dso_local noundef i32 @main() #0 !dbg !10 {
+entry:
+ %retval = alloca i32, align 4
+ %f = alloca %struct.Foo, align 8
+ store i32 0, ptr %retval, align 4
+ call void @llvm.dbg.declare(metadata ptr %f, metadata !15, metadata !DIExpression()), !dbg !21
+ ret i32 0, !dbg !22
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { mustprogress noinline norecurse nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 18.0.0 (ssh://git.vip.facebook.com/data/gitrepos/osmeta/external/llvm-project 680deb27e25976d9b74ad7b48ec5cb96be0e44b6)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "main.dwo", emissionKind: FullDebug, splitDebugInlining: false)
+!1 = !DIFile(filename: "main.cpp", directory: "/home/ayermolo/local/tasks/T138552329/typeSmallSplit", checksumkind: CSK_MD5, checksum: "e5b402e9dbafe24c7adbb087d1f03549")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 18.0.0 (ssh://git.vip.facebook.com/data/gitrepos/osmeta/external/llvm-project 680deb27e25976d9b74ad7b48ec5cb96be0e44b6)"}
+!10 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14)
+!11 = !DISubroutineType(types: !12)
+!12 = !{!13}
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !{}
+!15 = !DILocalVariable(name: "f", scope: !10, file: !1, line: 5, type: !16)
+!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !17, identifier: "_ZTS3Foo")
+!17 = !{!18}
+!18 = !DIDerivedType(tag: DW_TAG_member, name: "c1", scope: !16, file: !1, line: 2, baseType: !19, size: 64)
+!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
+!20 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!21 = !DILocation(line: 5, column: 6, scope: !10)
+!22 = !DILocation(line: 6, column: 2, scope: !10)
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s
index 009a87325e8b4fe..cb211733c6f8e09 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s
@@ -151,7 +151,7 @@
# CHECK-NEXT: CU[0]: 0x00000000
# CHECK-NEXT: ]
# CHECK-NEXT: Abbreviations [
-# CHECK-NEXT: Abbreviation 0x2e {
+# CHECK-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
# CHECK-NEXT: Tag: DW_TAG_subprogram
# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
# CHECK-NEXT: }
@@ -164,18 +164,20 @@
# CHECK-NEXT: Hash: 0xB887389
# CHECK-NEXT: String: 0x00000000 "foo"
# CHECK-NEXT: Entry @ 0x4f {
-# CHECK-NEXT: Abbrev: 0x2E
-# CHECK-NEXT: Tag: DW_TAG_subprogram
-# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: Abbrev: [[ABBREV]]
+# CHECK-NEXT: Tag: DW_TAG_subprogram
+# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: Name 2 {
# CHECK-NEXT: Hash: 0xB5063D0B
# CHECK-NEXT: String: 0x00000004 "_Z3foov"
# CHECK-NEXT: Entry @ 0x58 {
-# CHECK-NEXT: Abbrev: 0x2E
-# CHECK-NEXT: Tag: DW_TAG_subprogram
-# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: Abbrev: [[ABBREV]]
+# CHECK-NEXT: Tag: DW_TAG_subprogram
+# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: ]
@@ -197,7 +199,7 @@
# CHECK-NEXT: CU[0]: 0x00000002
# CHECK-NEXT: ]
# CHECK-NEXT: Abbreviations [
-# CHECK-NEXT: Abbreviation 0x34 {
+# CHECK-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
# CHECK-NEXT: Tag: DW_TAG_variable
# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4
# CHECK-NEXT: }
@@ -207,9 +209,10 @@
# CHECK-NEXT: Hash: 0xB8860BA
# CHECK-NEXT: String: 0x0000000c "bar"
# CHECK-NEXT: Entry @ 0xa3 {
-# CHECK-NEXT: Abbrev: 0x34
-# CHECK-NEXT: Tag: DW_TAG_variable
-# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: Abbrev: [[ABBREV1]]
+# CHECK-NEXT: Tag: DW_TAG_variable
+# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
+# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: ]
@@ -237,7 +240,7 @@
# CHECK-NEXT: ForeignTU[0]: 0xffffff00ffffffff
# CHECK-NEXT: ]
# CHECK-NEXT: Abbreviations [
-# CHECK-NEXT: Abbreviation 0x1 {
+# CHECK-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
# CHECK-NEXT: Tag: DW_TAG_base_type
# CHECK-NEXT: DW_IDX_type_unit: DW_FORM_data4
# CHECK-NEXT: DW_IDX_type_hash: DW_FORM_data8
@@ -248,10 +251,11 @@
# CHECK-NEXT: Hash: 0xB887389
# CHECK-NEXT: String: 0x00000000 "foo"
# CHECK-NEXT: Entry @ 0x111 {
-# CHECK-NEXT: Abbrev: 0x1
-# CHECK-NEXT: Tag: DW_TAG_base_type
-# CHECK-NEXT: DW_IDX_type_unit: 0x00000001
-# CHECK-NEXT: DW_IDX_type_hash: 0x0000ff03ffffffff
+# CHECK-NEXT: Abbrev: [[ABBREV2]]
+# CHECK-NEXT: Tag: DW_TAG_base_type
+# CHECK-NEXT: DW_IDX_type_unit: 0x00000001
+# CHECK-NEXT: DW_IDX_type_hash: 0x0000ff03ffffffff
+# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: ]
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-misaligned.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-misaligned.s
index 0acc745af1e5aa4..0ad4f50e98d988f 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-misaligned.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-misaligned.s
@@ -84,7 +84,7 @@
# CHECK: Name 1 {
# CHECK-NEXT: String: 0x00000000 "foo"
# CHECK-NEXT: Entry @ 0x37 {
-# CHECK-NEXT: Abbrev: 0x2E
+# CHECK-NEXT: Abbrev: 0x2e
# CHECK-NEXT: Tag: DW_TAG_subprogram
# CHECK-NEXT: DW_IDX_die_offset: 0x00000001
# CHECK-NEXT: }
More information about the llvm-commits
mailing list