31 changes: 16 additions & 15 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/YAMLTraits.h"

#include <algorithm>
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <optional>
#include <unordered_map>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -179,8 +176,10 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
}

DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
DWARF5AcceleratorTable &DebugNamesTable,
DWARFUnit *SkeletonCU)
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU),
DebugNamesTable(DebugNamesTable) {}

static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
Expand Down Expand Up @@ -378,18 +377,20 @@ getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
return nullptr;
}

uint32_t DIEBuilder::computeDIEOffset(const DWARFUnit &CU, DIE &Die,
uint32_t &CurOffset) {
uint32_t DIEBuilder::finalizeDIEs(DWARFUnit &CU, DIE &Die,
uint32_t &CurOffset) {
getState().DWARFDieAddressesParsed.erase(Die.getOffset());
uint32_t CurSize = 0;
Die.setOffset(CurOffset);
DebugNamesTable.addAccelTableEntry(
CU, Die, SkeletonCU ? SkeletonCU->getDWOId() : std::nullopt);
for (DIEValue &Val : Die.values())
CurSize += Val.sizeOf(CU.getFormParams());
CurSize += getULEB128Size(Die.getAbbrevNumber());
CurOffset += CurSize;

for (DIE &Child : Die.children()) {
uint32_t ChildSize = computeDIEOffset(CU, Child, CurOffset);
uint32_t ChildSize = finalizeDIEs(CU, Child, CurOffset);
CurSize += ChildSize;
}
// for children end mark.
Expand All @@ -404,12 +405,12 @@ uint32_t DIEBuilder::computeDIEOffset(const DWARFUnit &CU, DIE &Die,
}

void DIEBuilder::finish() {
auto computeOffset = [&](const DWARFUnit &CU,
uint64_t &UnitStartOffset) -> void {
auto finalizeCU = [&](DWARFUnit &CU, uint64_t &UnitStartOffset) -> void {
DIE *UnitDIE = getUnitDIEbyUnit(CU);
uint32_t HeaderSize = CU.getHeaderSize();
uint32_t CurOffset = HeaderSize;
computeDIEOffset(CU, *UnitDIE, CurOffset);
DebugNamesTable.setCurrentUnit(CU, UnitStartOffset);
finalizeDIEs(CU, *UnitDIE, CurOffset);

DWARFUnitInfo &CurUnitInfo = getUnitInfoByDwarfUnit(CU);
CurUnitInfo.UnitOffset = UnitStartOffset;
Expand All @@ -420,18 +421,18 @@ void DIEBuilder::finish() {
// It's processed first when CU is registered so will be at the begginnig of
// the vector.
uint64_t TypeUnitStartOffset = 0;
for (const DWARFUnit *CU : getState().DUList) {
for (DWARFUnit *CU : getState().DUList) {
// We process DWARF$ types first.
if (!(CU->getVersion() < 5 && CU->isTypeUnit()))
break;
computeOffset(*CU, TypeUnitStartOffset);
finalizeCU(*CU, TypeUnitStartOffset);
}

for (const DWARFUnit *CU : getState().DUList) {
for (DWARFUnit *CU : getState().DUList) {
// Skipping DWARF4 types.
if (CU->getVersion() < 5 && CU->isTypeUnit())
continue;
computeOffset(*CU, UnitSize);
finalizeCU(*CU, UnitSize);
}
if (opts::Verbosity >= 1) {
if (!getState().DWARFDieAddressesParsed.empty())
Expand Down
618 changes: 618 additions & 0 deletions bolt/lib/Core/DebugNames.cpp

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bolt/lib/Core/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,11 @@ void BinaryFunction::updateEHRanges() {

// Same symbol is used for the beginning and the end of the range.
MCSymbol *EHSymbol;
if (MCSymbol *InstrLabel = BC.MIB->getLabel(Instr)) {
if (MCSymbol *InstrLabel = BC.MIB->getInstLabel(Instr)) {
EHSymbol = InstrLabel;
} else {
std::unique_lock<llvm::sys::RWMutex> Lock(BC.CtxMutex);
EHSymbol = BC.Ctx->createNamedTempSymbol("EH");
BC.MIB->setLabel(Instr, EHSymbol);
EHSymbol = BC.MIB->getOrCreateInstLabel(Instr, "EH", BC.Ctx.get());
}

// At this point we could be in one of the following states:
Expand Down
19 changes: 16 additions & 3 deletions bolt/lib/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "bolt/Core/MCPlusBuilder.h"
#include "bolt/Core/MCPlus.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrDesc.h"
Expand Down Expand Up @@ -266,17 +267,29 @@ bool MCPlusBuilder::clearOffset(MCInst &Inst) const {
return true;
}

MCSymbol *MCPlusBuilder::getLabel(const MCInst &Inst) const {
MCSymbol *MCPlusBuilder::getInstLabel(const MCInst &Inst) const {
if (std::optional<int64_t> Label =
getAnnotationOpValue(Inst, MCAnnotation::kLabel))
return reinterpret_cast<MCSymbol *>(*Label);
return nullptr;
}

bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label) const {
MCSymbol *MCPlusBuilder::getOrCreateInstLabel(MCInst &Inst, const Twine &Name,
MCContext *Ctx) const {
MCSymbol *Label = getInstLabel(Inst);
if (Label)
return Label;

Label = Ctx->createNamedTempSymbol(Name);
setAnnotationOpValue(Inst, MCAnnotation::kLabel,
reinterpret_cast<int64_t>(Label));
return Label;
}

void MCPlusBuilder::setInstLabel(MCInst &Inst, MCSymbol *Label) const {
assert(!getInstLabel(Inst) && "Instruction already has assigned label.");
setAnnotationOpValue(Inst, MCAnnotation::kLabel,
reinterpret_cast<int64_t>(Label));
return true;
}

std::optional<uint32_t> MCPlusBuilder::getSize(const MCInst &Inst) const {
Expand Down
96 changes: 86 additions & 10 deletions bolt/lib/Passes/Instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "bolt/Utils/Utils.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/RWMutex.h"
#include <queue>
#include <stack>
#include <unordered_set>

#define DEBUG_TYPE "bolt-instrumentation"

Expand Down Expand Up @@ -86,21 +88,89 @@ cl::opt<bool> InstrumentCalls("instrument-calls",
namespace llvm {
namespace bolt {

static bool hasAArch64ExclusiveMemop(BinaryFunction &Function) {
static bool hasAArch64ExclusiveMemop(
BinaryFunction &Function,
std::unordered_set<const BinaryBasicBlock *> &BBToSkip) {
// FIXME ARMv8-a architecture reference manual says that software must avoid
// having any explicit memory accesses between exclusive load and associated
// store instruction. So for now skip instrumentation for functions that have
// these instructions, since it might lead to runtime deadlock.
// store instruction. So for now skip instrumentation for basic blocks that
// have these instructions, since it might lead to runtime deadlock.
BinaryContext &BC = Function.getBinaryContext();
for (const BinaryBasicBlock &BB : Function)
for (const MCInst &Inst : BB)
if (BC.MIB->isAArch64Exclusive(Inst)) {
if (opts::Verbosity >= 1)
BC.outs() << "BOLT-INSTRUMENTER: Function " << Function
<< " has exclusive instructions, skip instrumentation\n";
std::queue<std::pair<BinaryBasicBlock *, bool>> BBQueue; // {BB, isLoad}
std::unordered_set<BinaryBasicBlock *> Visited;

if (Function.getLayout().block_begin() == Function.getLayout().block_end())
return 0;

BinaryBasicBlock *BBfirst = *Function.getLayout().block_begin();
BBQueue.push({BBfirst, false});

while (!BBQueue.empty()) {
BinaryBasicBlock *BB = BBQueue.front().first;
bool IsLoad = BBQueue.front().second;
BBQueue.pop();
if (Visited.find(BB) != Visited.end())
continue;
Visited.insert(BB);

for (const MCInst &Inst : *BB) {
// Two loads one after another - skip whole function
if (BC.MIB->isAArch64ExclusiveLoad(Inst) && IsLoad) {
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: function " << Function.getPrintName()
<< " has two exclusive loads. Ignoring the function.\n";
}
return true;
}

if (BC.MIB->isAArch64ExclusiveLoad(Inst))
IsLoad = true;

if (IsLoad && BBToSkip.find(BB) == BBToSkip.end()) {
BBToSkip.insert(BB);
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: skip BB " << BB->getName()
<< " due to exclusive instruction in function "
<< Function.getPrintName() << "\n";
}
}

if (!IsLoad && BC.MIB->isAArch64ExclusiveStore(Inst)) {
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: function " << Function.getPrintName()
<< " has exclusive store without corresponding load. Ignoring "
"the function.\n";
}
return true;
}

if (IsLoad && (BC.MIB->isAArch64ExclusiveStore(Inst) ||
BC.MIB->isAArch64ExclusiveClear(Inst)))
IsLoad = false;
}

if (IsLoad && BB->succ_size() == 0) {
if (opts::Verbosity >= 2) {
outs()
<< "BOLT-INSTRUMENTER: function " << Function.getPrintName()
<< " has exclusive load in trailing BB. Ignoring the function.\n";
}
return true;
}

for (BinaryBasicBlock *BBS : BB->successors())
BBQueue.push({BBS, IsLoad});
}

if (BBToSkip.size() == Visited.size()) {
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: all BBs are marked with true. Ignoring the "
"function "
<< Function.getPrintName() << "\n";
}
return true;
}

return false;
}

Expand Down Expand Up @@ -307,7 +377,8 @@ void Instrumentation::instrumentFunction(BinaryFunction &Function,
if (BC.isMachO() && Function.hasName("___GLOBAL_init_65535/1"))
return;

if (BC.isAArch64() && hasAArch64ExclusiveMemop(Function))
std::unordered_set<const BinaryBasicBlock *> BBToSkip;
if (BC.isAArch64() && hasAArch64ExclusiveMemop(Function, BBToSkip))
return;

SplitWorklistTy SplitWorklist;
Expand Down Expand Up @@ -389,6 +460,11 @@ void Instrumentation::instrumentFunction(BinaryFunction &Function,

for (auto BBI = Function.begin(), BBE = Function.end(); BBI != BBE; ++BBI) {
BinaryBasicBlock &BB = *BBI;

// Skip BBs with exclusive load/stores
if (BBToSkip.find(&BB) != BBToSkip.end())
continue;

bool HasUnconditionalBranch = false;
bool HasJumpTable = false;
bool IsInvokeBlock = InvokeBlocks.count(&BB) > 0;
Expand Down
34 changes: 27 additions & 7 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ static cl::opt<bool>
"multiple non-relocatable dwarf object files (dwo)."),
cl::init(false), cl::cat(BoltCategory));

static cl::opt<bool> CreateDebugNames(
"create-debug-names-section",
cl::desc("Creates .debug_names section, if the input binary doesn't have "
"it already, for DWARF5 CU/TUs."),
cl::init(false), cl::cat(BoltCategory));

static cl::opt<bool>
DebugSkeletonCu("debug-skeleton-cu",
cl::desc("prints out offsetrs for abbrev and debu_info of "
Expand Down Expand Up @@ -692,6 +698,8 @@ void DWARFRewriter::updateDebugInfo() {
return ObjectName;
};

DWARF5AcceleratorTable DebugNamesTable(opts::CreateDebugNames, BC,
*StrWriter);
DWPState State;
if (opts::WriteDWP)
initDWPState(State);
Expand All @@ -709,7 +717,8 @@ void DWARFRewriter::updateDebugInfo() {
: LegacyRangesSectionWriter.get();
// Skipping CUs that failed to load.
if (SplitCU) {
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), DebugNamesTable,
Unit);
DWODIEBuilder.buildDWOUnit(**SplitCU);
std::string DWOName = updateDWONameCompDir(
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
Expand Down Expand Up @@ -749,7 +758,7 @@ void DWARFRewriter::updateDebugInfo() {
AddrWriter->update(*DIEBlder, *Unit);
};

DIEBuilder DIEBlder(BC, BC.DwCtx.get());
DIEBuilder DIEBlder(BC, BC.DwCtx.get(), DebugNamesTable);
DIEBlder.buildTypeUnits(StrOffstsWriter.get());
SmallVector<char, 20> OutBuffer;
std::unique_ptr<raw_svector_ostream> ObjOS =
Expand Down Expand Up @@ -781,10 +790,13 @@ void DWARFRewriter::updateDebugInfo() {
ThreadPool.wait();
}

DebugNamesTable.emitAccelTable();

if (opts::WriteDWP)
finalizeDWP(State);

finalizeDebugSections(DIEBlder, *Streamer, *ObjOS, OffsetMap);
finalizeDebugSections(DIEBlder, DebugNamesTable, *Streamer, *ObjOS,
OffsetMap);
updateGdbIndexSection(OffsetMap, CUIndex);
}

Expand Down Expand Up @@ -1515,10 +1527,9 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder &DIEBlder,
return CUMap;
}

void DWARFRewriter::finalizeDebugSections(DIEBuilder &DIEBlder,
DIEStreamer &Streamer,
raw_svector_ostream &ObjOS,
CUOffsetMap &CUMap) {
void DWARFRewriter::finalizeDebugSections(
DIEBuilder &DIEBlder, DWARF5AcceleratorTable &DebugNamesTable,
DIEStreamer &Streamer, raw_svector_ostream &ObjOS, CUOffsetMap &CUMap) {
if (StrWriter->isInitialized()) {
RewriteInstance::addToDebugSectionsToOverwrite(".debug_str");
std::unique_ptr<DebugStrBufferVector> DebugStrSectionContents =
Expand Down Expand Up @@ -1616,6 +1627,15 @@ void DWARFRewriter::finalizeDebugSections(DIEBuilder &DIEBlder,
copyByteArray(ARangesContents),
ARangesContents.size());
}

if (DebugNamesTable.isCreated()) {
RewriteInstance::addToDebugSectionsToOverwrite(".debug_names");
std::unique_ptr<DebugBufferVector> DebugNamesSectionContents =
DebugNamesTable.releaseBuffer();
BC.registerOrUpdateNoteSection(".debug_names",
copyByteArray(*DebugNamesSectionContents),
DebugNamesSectionContents->size());
}
}

void DWARFRewriter::finalizeCompileUnits(DIEBuilder &DIEBlder,
Expand Down
14 changes: 4 additions & 10 deletions bolt/lib/Rewrite/LinuxKernelRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,11 +770,8 @@ Error LinuxKernelRewriter::rewriteORCTables() {
continue;

// Issue label for the instruction.
MCSymbol *Label = BC.MIB->getLabel(Inst);
if (!Label) {
Label = BC.Ctx->createTempSymbol("__ORC_");
BC.MIB->setLabel(Inst, Label);
}
MCSymbol *Label =
BC.MIB->getOrCreateInstLabel(Inst, "__ORC_", BC.Ctx.get());

if (Error E = emitORCEntry(0, *ErrorOrState, Label))
return E;
Expand Down Expand Up @@ -908,11 +905,8 @@ Error LinuxKernelRewriter::readStaticCalls() {

BC.MIB->addAnnotation(*Inst, "StaticCall", EntryID);

MCSymbol *Label = BC.MIB->getLabel(*Inst);
if (!Label) {
Label = BC.Ctx->createTempSymbol("__SC_");
BC.MIB->setLabel(*Inst, Label);
}
MCSymbol *Label =
BC.MIB->getOrCreateInstLabel(*Inst, "__SC_", BC.Ctx.get());

StaticCallEntries.push_back({EntryID, BF, Label});
}
Expand Down
26 changes: 16 additions & 10 deletions bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,32 +270,38 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
return isLDRB(Inst) || isLDRH(Inst) || isLDRW(Inst) || isLDRX(Inst);
}

bool isAArch64Exclusive(const MCInst &Inst) const override {
bool isAArch64ExclusiveLoad(const MCInst &Inst) const override {
return (Inst.getOpcode() == AArch64::LDXPX ||
Inst.getOpcode() == AArch64::LDXPW ||
Inst.getOpcode() == AArch64::LDXRX ||
Inst.getOpcode() == AArch64::LDXRW ||
Inst.getOpcode() == AArch64::LDXRH ||
Inst.getOpcode() == AArch64::LDXRB ||
Inst.getOpcode() == AArch64::STXPX ||
Inst.getOpcode() == AArch64::STXPW ||
Inst.getOpcode() == AArch64::STXRX ||
Inst.getOpcode() == AArch64::STXRW ||
Inst.getOpcode() == AArch64::STXRH ||
Inst.getOpcode() == AArch64::STXRB ||
Inst.getOpcode() == AArch64::LDAXPX ||
Inst.getOpcode() == AArch64::LDAXPW ||
Inst.getOpcode() == AArch64::LDAXRX ||
Inst.getOpcode() == AArch64::LDAXRW ||
Inst.getOpcode() == AArch64::LDAXRH ||
Inst.getOpcode() == AArch64::LDAXRB ||
Inst.getOpcode() == AArch64::LDAXRB);
}

bool isAArch64ExclusiveStore(const MCInst &Inst) const override {
return (Inst.getOpcode() == AArch64::STXPX ||
Inst.getOpcode() == AArch64::STXPW ||
Inst.getOpcode() == AArch64::STXRX ||
Inst.getOpcode() == AArch64::STXRW ||
Inst.getOpcode() == AArch64::STXRH ||
Inst.getOpcode() == AArch64::STXRB ||
Inst.getOpcode() == AArch64::STLXPX ||
Inst.getOpcode() == AArch64::STLXPW ||
Inst.getOpcode() == AArch64::STLXRX ||
Inst.getOpcode() == AArch64::STLXRW ||
Inst.getOpcode() == AArch64::STLXRH ||
Inst.getOpcode() == AArch64::STLXRB ||
Inst.getOpcode() == AArch64::CLREX);
Inst.getOpcode() == AArch64::STLXRB);
}

bool isAArch64ExclusiveClear(const MCInst &Inst) const override {
return (Inst.getOpcode() == AArch64::CLREX);
}

bool isLoadFromStack(const MCInst &Inst) const {
Expand Down
90 changes: 83 additions & 7 deletions bolt/test/AArch64/exclusive-instrument.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,108 @@
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
// RUN: %s -o %t.o
// RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q -Wl,-fini=dummy
// RUN: llvm-bolt %t.exe -o %t.bolt -instrument -v=1 | FileCheck %s
// RUN: llvm-bolt %t.exe -o %t.bolt -instrument -v=2 | FileCheck %s

// CHECK: Function foo has exclusive instructions, skip instrumentation
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case1
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case2
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case2
// CHECK: BOLT-INSTRUMENTER: function case3 has exclusive store without corresponding load. Ignoring the function.
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case4
// CHECK: BOLT-INSTRUMENTER: function case4 has two exclusive loads. Ignoring the function.
// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case5
// CHECK: BOLT-INSTRUMENTER: function case5 has exclusive load in trailing BB. Ignoring the function.

.global foo
.type foo, %function
foo:
# exclusive load and store in two bbs
ldaxr w9, [x10]
cbnz w9, .Lret
stlxr w12, w11, [x9]
cbz w12, foo
clrex
.Lret:
clrex
ret
.size foo, .-foo

.global _start
.type _start, %function
_start:
cmp x0, #0
b.eq .Lexit
bl foo
.Lexit:
mov x0, #0
mov x1, #1
mov x2, #2
mov x3, #3

bl case1
bl case2
bl case3
bl case4
bl case5

ret
.size _start, .-_start

# Case 1: exclusive load and store in one basic block
.global case1
.type case1, %function
case1:
str x0, [x2]
ldxr w0, [x2]
add w0, w0, #1
stxr w1, w0, [x2]
ret
.size case1, .-case1

# Case 2: exclusive load and store in different blocks
.global case2
.type case2, %function
case2:
b case2_load

case2_load:
ldxr x0, [x2]
b case2_store

case2_store:
add x0, x0, #1
stxr w1, x0, [x2]
ret
.size case2, .-case2

# Case 3: store without preceding load
.global case3
.type case3, %function
case3:
stxr w1, x3, [x2]
ret
.size case3, .-case3

# Case 4: two exclusive load instructions in neighboring blocks
.global case4
.type case4, %function
case4:
b case4_load

case4_load:
ldxr x0, [x2]
b case4_load_next

case4_load_next:
ldxr x1, [x2]
ret
.size case4, .-case4

# Case 5: Exclusive load without successor
.global case5
.type case5, %function
case5:
ldxr x0, [x2]
ret
.size case5, .-case5

.global dummy
.type dummy, %function
dummy:
Expand Down
487 changes: 487 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-debug-names-helper.s

Large diffs are not rendered by default.

712 changes: 712 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-debug-names-main.s

Large diffs are not rendered by default.

326 changes: 326 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-df-debug-names-helper.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
# clang++ -gsplit-dwarf -g2 -gdwarf-5 -gpubnames -fdebug-compilation-dir='.'
# header.h
# struct Foo2a {
# char *c1;
# char *c2;
# char *c3;
# };
# helper.cpp
# #include "header.h"
# struct Foo2Int {
# int *c1;
# int *c2;
# };
# Foo2Int fint;
# const Foo2a f{nullptr, nullptr};

.text
.file "helper.cpp"
.file 0 "." "helper.cpp" md5 0x2804efac708fd4180d403e6d5dbcc54a
.type fint,@object # @fint
.bss
.globl fint
.p2align 3, 0x0
fint:
.zero 16
.size fint, 16

.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
.byte 74 # DW_TAG_skeleton_unit
.byte 0 # DW_CHILDREN_no
.byte 16 # DW_AT_stmt_list
.byte 23 # DW_FORM_sec_offset
.byte 114 # DW_AT_str_offsets_base
.byte 23 # DW_FORM_sec_offset
.byte 27 # DW_AT_comp_dir
.byte 37 # DW_FORM_strx1
.byte 118 # DW_AT_dwo_name
.byte 37 # DW_FORM_strx1
.byte 115 # DW_AT_addr_base
.byte 23 # DW_FORM_sec_offset
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_info,"",@progbits
.Lcu_begin0:
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.short 5 # DWARF version number
.byte 4 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
.long .debug_abbrev # Offset Into Abbrev. Section
.quad 3223434782003797151
.byte 1 # Abbrev [1] 0x14:0xf DW_TAG_skeleton_unit
.long .Lline_table_start0 # DW_AT_stmt_list
.long .Lstr_offsets_base0 # DW_AT_str_offsets_base
.byte 0 # DW_AT_comp_dir
.byte 1 # DW_AT_dwo_name
.long .Laddr_table_base0 # DW_AT_addr_base
.Ldebug_info_end0:
.section .debug_str_offsets,"",@progbits
.long 12 # Length of String Offsets Set
.short 5
.short 0
.Lstr_offsets_base0:
.section .debug_str,"MS",@progbits,1
.Lskel_string0:
.asciz "." # string offset=0
.Lskel_string1:
.asciz "Foo2Int" # string offset=2
.Lskel_string2:
.asciz "int" # string offset=10
.Lskel_string3:
.asciz "fint" # string offset=14
.Lskel_string4:
.asciz "helper.dwo" # string offset=19
.section .debug_str_offsets,"",@progbits
.long .Lskel_string0
.long .Lskel_string4
.section .debug_str_offsets.dwo,"e",@progbits
.long 36 # Length of String Offsets Set
.short 5
.short 0
.section .debug_str.dwo,"eMS",@progbits,1
.Linfo_string0:
.asciz "fint" # string offset=0
.Linfo_string1:
.asciz "c1" # string offset=5
.Linfo_string2:
.asciz "int" # string offset=8
.Linfo_string3:
.asciz "c2" # string offset=12
.Linfo_string4:
.asciz "Foo2Int" # string offset=15
.Linfo_string5:
.asciz "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git da9e9277be64deca73370a90d22af33e5b37cc52)" # string offset=23
.Linfo_string6:
.asciz "helper.cpp" # string offset=131
.Linfo_string7:
.asciz "helper.dwo" # string offset=142
.section .debug_str_offsets.dwo,"e",@progbits
.long 0
.long 5
.long 8
.long 12
.long 15
.long 23
.long 131
.long 142
.section .debug_info.dwo,"e",@progbits
.long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
.Ldebug_info_dwo_start0:
.short 5 # DWARF version number
.byte 5 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
.long 0 # Offset Into Abbrev. Section
.quad 3223434782003797151
.byte 1 # Abbrev [1] 0x14:0x34 DW_TAG_compile_unit
.byte 5 # DW_AT_producer
.short 33 # DW_AT_language
.byte 6 # DW_AT_name
.byte 7 # DW_AT_dwo_name
.byte 2 # Abbrev [2] 0x1a:0xb DW_TAG_variable
.byte 0 # DW_AT_name
.long 37 # DW_AT_type
# DW_AT_external
.byte 0 # DW_AT_decl_file
.byte 7 # DW_AT_decl_line
.byte 2 # DW_AT_location
.byte 161
.byte 0
.byte 3 # Abbrev [3] 0x25:0x19 DW_TAG_structure_type
.byte 5 # DW_AT_calling_convention
.byte 4 # DW_AT_name
.byte 16 # DW_AT_byte_size
.byte 0 # DW_AT_decl_file
.byte 2 # DW_AT_decl_line
.byte 4 # Abbrev [4] 0x2b:0x9 DW_TAG_member
.byte 1 # DW_AT_name
.long 62 # DW_AT_type
.byte 0 # DW_AT_decl_file
.byte 3 # DW_AT_decl_line
.byte 0 # DW_AT_data_member_location
.byte 4 # Abbrev [4] 0x34:0x9 DW_TAG_member
.byte 3 # DW_AT_name
.long 62 # DW_AT_type
.byte 0 # DW_AT_decl_file
.byte 4 # DW_AT_decl_line
.byte 8 # DW_AT_data_member_location
.byte 0 # End Of Children Mark
.byte 5 # Abbrev [5] 0x3e:0x5 DW_TAG_pointer_type
.long 67 # DW_AT_type
.byte 6 # Abbrev [6] 0x43:0x4 DW_TAG_base_type
.byte 2 # DW_AT_name
.byte 5 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 0 # End Of Children Mark
.Ldebug_info_dwo_end0:
.section .debug_abbrev.dwo,"e",@progbits
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 37 # DW_FORM_strx1
.byte 19 # DW_AT_language
.byte 5 # DW_FORM_data2
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 118 # DW_AT_dwo_name
.byte 37 # DW_FORM_strx1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 52 # DW_TAG_variable
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 2 # DW_AT_location
.byte 24 # DW_FORM_exprloc
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 3 # Abbreviation Code
.byte 19 # DW_TAG_structure_type
.byte 1 # DW_CHILDREN_yes
.byte 54 # DW_AT_calling_convention
.byte 11 # DW_FORM_data1
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 4 # Abbreviation Code
.byte 13 # DW_TAG_member
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 56 # DW_AT_data_member_location
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 5 # Abbreviation Code
.byte 15 # DW_TAG_pointer_type
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 6 # Abbreviation Code
.byte 36 # DW_TAG_base_type
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 62 # DW_AT_encoding
.byte 11 # DW_FORM_data1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_addr,"",@progbits
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
.Ldebug_addr_start0:
.short 5 # DWARF version number
.byte 8 # Address size
.byte 0 # Segment selector size
.Laddr_table_base0:
.quad fint
.Ldebug_addr_end0:
.section .debug_names,"",@progbits
.long .Lnames_end0-.Lnames_start0 # Header: unit length
.Lnames_start0:
.short 5 # Header: version
.short 0 # Header: padding
.long 1 # Header: compilation unit count
.long 0 # Header: local type unit count
.long 0 # Header: foreign type unit count
.long 3 # Header: bucket count
.long 3 # Header: name count
.long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size
.long 8 # Header: augmentation string size
.ascii "LLVM0700" # Header: augmentation string
.long .Lcu_begin0 # Compilation unit 0
.long 1 # Bucket 0
.long 2 # Bucket 1
.long 3 # Bucket 2
.long -1168750522 # Hash in Bucket 0
.long 2090257270 # Hash in Bucket 1
.long 193495088 # Hash in Bucket 2
.long .Lskel_string1 # String in Bucket 0: Foo2Int
.long .Lskel_string3 # String in Bucket 1: fint
.long .Lskel_string2 # String in Bucket 2: int
.long .Lnames0-.Lnames_entries0 # Offset in Bucket 0
.long .Lnames2-.Lnames_entries0 # Offset in Bucket 1
.long .Lnames1-.Lnames_entries0 # Offset in Bucket 2
.Lnames_abbrev_start0:
.ascii "\230\023" # Abbrev code
.byte 19 # DW_TAG_structure_type
.byte 3 # DW_IDX_die_offset
.byte 19 # DW_FORM_ref4
.byte 4 # DW_IDX_parent
.byte 25 # DW_FORM_flag_present
.byte 0 # End of abbrev
.byte 0 # End of abbrev
.ascii "\2304" # Abbrev code
.byte 52 # DW_TAG_variable
.byte 3 # DW_IDX_die_offset
.byte 19 # DW_FORM_ref4
.byte 4 # DW_IDX_parent
.byte 25 # DW_FORM_flag_present
.byte 0 # End of abbrev
.byte 0 # End of abbrev
.ascii "\230$" # Abbrev code
.byte 36 # DW_TAG_base_type
.byte 3 # DW_IDX_die_offset
.byte 19 # DW_FORM_ref4
.byte 4 # DW_IDX_parent
.byte 25 # DW_FORM_flag_present
.byte 0 # End of abbrev
.byte 0 # End of abbrev
.byte 0 # End of abbrev list
.Lnames_abbrev_end0:
.Lnames_entries0:
.Lnames0:
.L1:
.ascii "\230\023" # Abbreviation code
.long 37 # DW_IDX_die_offset
.byte 0 # DW_IDX_parent
# End of list: Foo2Int
.Lnames2:
.L0:
.ascii "\2304" # Abbreviation code
.long 26 # DW_IDX_die_offset
.byte 0 # DW_IDX_parent
# End of list: fint
.Lnames1:
.L2:
.ascii "\230$" # Abbreviation code
.long 67 # DW_IDX_die_offset
.byte 0 # DW_IDX_parent
# End of list: int
.p2align 2, 0x0
.Lnames_end0:
.ident "clang version 19.0.0git (git@github.com:ayermolo/llvm-project.git da9e9277be64deca73370a90d22af33e5b37cc52)"
.section ".note.GNU-stack","",@progbits
.addrsig
.section .debug_line,"",@progbits
.Lline_table_start0:
493 changes: 493 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-df-debug-names-main.s

Large diffs are not rendered by default.

650 changes: 650 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-df-types-debug-names-helper.s

Large diffs are not rendered by default.

626 changes: 626 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-df-types-debug-names-main.s

Large diffs are not rendered by default.

405 changes: 405 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-types-debug-names-helper.s

Large diffs are not rendered by default.

391 changes: 391 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-types-debug-names-main.s

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions bolt/test/X86/dwarf5-debug-names-generate-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
; REQUIRES: system-linux

; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o
; RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
; RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --create-debug-names-section=true
; RUN: llvm-dwarfdump --debug-info -r 0 --debug-names %t.bolt > %t.txt
; RUN: cat %t.txt | FileCheck --check-prefix=BOLT %s

;; Tests BOLT generates .debug_names with --create-debug-names-section.
;; Also applicable when binary has CUs that do not contribute to .debug_names pre-bolt.

; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x103
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 2
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 8
; BOLT-NEXT: Name count: 8
; BOLT-NEXT: Abbreviations table size: 0x19
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET1]]
; BOLT-NEXT: CU[1]: [[OFFSET2]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000033
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000007f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "foo"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005e
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0x8C06E589
; BOLT-NEXT: String: {{.+}} "_Z3usePiS_"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000028
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0xB88B3D2
; BOLT-NEXT: String: {{.+}} "use"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000028
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000049
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 6 {
; BOLT-NEXT: Hash: 0xFDE4B5D2
; BOLT-NEXT: String: {{.+}} "fooVar"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000028
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000092
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 5 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: Name 8 {
; BOLT-NEXT: Hash: 0xB5063CFE
; BOLT-NEXT: String: {{.+}} "_Z3fooi"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005e
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: }
263 changes: 263 additions & 0 deletions bolt/test/X86/dwarf5-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-main.s -o %tmain.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-helper.s -o %thelper.o
; RUN: %clang %cflags -gdwarf-5 %tmain.o %thelper.o -o %tmain.exe
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info -r 0 --debug-names %tmain.exe.bolt > %tlog.txt
; RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with two CUs

; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x1C2
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 2
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 14
; BOLT-NEXT: Name count: 15
; BOLT-NEXT: Abbreviations table size: 0x29
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET1]]
; BOLT-NEXT: CU[1]: [[OFFSET2]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV5:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0x59796C
; BOLT-NEXT: String: {{.+}} "t3"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0x7C96E4DB
; BOLT-NEXT: String: {{.+}} "Foo2"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x000000eb
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0x8CFC710C
; BOLT-NEXT: String: {{.+}} "(anonymous namespace)"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000061
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000061
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0xBA564846
; BOLT-NEXT: String: {{.+}} "Foo2Int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 5 [
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "Foo"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c9
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 6 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "foo"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000033
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000009f
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c5
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: Name 8 {
; BOLT-NEXT: Hash: 0x392140FA
; BOLT-NEXT: String: {{.+}} "t2<&fooint>"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 9 {
; BOLT-NEXT: Hash: 0xFDE48034
; BOLT-NEXT: String: {{.+}} "fooint"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV5]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: Name 10 {
; BOLT-NEXT: Hash: 0xB5063D0B
; BOLT-NEXT: String: {{.+}} "_Z3foov"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000033
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 8 [
; BOLT-NEXT: Name 11 {
; BOLT-NEXT: Hash: 0x5979AC
; BOLT-NEXT: String: {{.+}} "v1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV5]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 9 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 10 [
; BOLT-NEXT: Name 12 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005d
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 13 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000078
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000104
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 14 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000073
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 11 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 12 [
; BOLT-NEXT: Name 15 {
; BOLT-NEXT: Hash: 0x59796A
; BOLT-NEXT: String: {{.+}} "t1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000062
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 13 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: }
192 changes: 192 additions & 0 deletions bolt/test/X86/dwarf5-df-debug-names-generate-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-dualcu-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-dualcu-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe -fno-pic -no-pie
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --create-debug-names-section=true
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt > %t/foo.txt
; RUN: cat %t/foo.txt | FileCheck -check-prefix=BOLT %s

;; Tests BOLT generates .debug_names with --create-debug-names-section.
;; Also applicable when binary has split dwarf CUs that do not contribute to .debug_names pre-bolt.

; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x148
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 2
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 11
; BOLT-NEXT: Name count: 11
; BOLT-NEXT: Abbreviations table size: 0x19
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET1]]
; BOLT-NEXT: CU[1]: [[OFFSET2]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0x2B61E
; BOLT-NEXT: String: {{.+}} "y"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000008c
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0x2B609
; BOLT-NEXT: String: {{.+}} "d"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0x2B61F
; BOLT-NEXT: String: {{.+}} "z"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0xB88B3D2
; BOLT-NEXT: String: {{.+}} "use"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 6 {
; BOLT-NEXT: Hash: 0x45A3B006
; BOLT-NEXT: String: {{.+}} "_Z6helperii"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 5 [
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0x8C06E589
; BOLT-NEXT: String: {{.+}} "_Z3usePiS_"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: Name 8 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000025
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000025
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: Name 9 {
; BOLT-NEXT: Hash: 0x1D853E5
; BOLT-NEXT: String: {{.+}} "helper"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 10 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000057
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 8 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 9 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 10 [
; BOLT-NEXT: Name 11 {
; BOLT-NEXT: Hash: 0x2B61D
; BOLT-NEXT: String: {{.+}} "x"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
149 changes: 149 additions & 0 deletions bolt/test/X86/dwarf5-df-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-debug-names-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-debug-names-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt > log.txt
; RUN: cat log.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with two CUs for split dwarf.

; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
: BOLT: Name Index @ 0x0 {
: BOLT-NEXT: Header {
: BOLT-NEXT: Length: 0xF4
: BOLT-NEXT: Format: DWARF32
: BOLT-NEXT: Version: 5
: BOLT-NEXT: CU count: 2
: BOLT-NEXT: Local TU count: 0
: BOLT-NEXT: Foreign TU count: 0
: BOLT-NEXT: Bucket count: 7
: BOLT-NEXT: Name count: 7
: BOLT-NEXT: Abbreviations table size: 0x21
: BOLT-NEXT: Augmentation: 'BOLT'
: BOLT-NEXT: }
: BOLT-NEXT: Compilation Unit offsets [
: BOLT-NEXT: CU[0]: [[OFFSET]]
: BOLT-NEXT: CU[1]: [[OFFSET1]]
: BOLT-NEXT: ]
: BOLT-NEXT: Abbreviations [
: BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
: BOLT-NEXT: Tag: DW_TAG_structure_type
: BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
: BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
: BOLT-NEXT: }
: BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
: BOLT-NEXT: Tag: DW_TAG_base_type
: BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
: BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
: BOLT-NEXT: }
: BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
: BOLT-NEXT: Tag: DW_TAG_variable
: BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
: BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
: BOLT-NEXT: }
: BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
: BOLT-NEXT: Tag: DW_TAG_subprogram
: BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
: BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
: BOLT-NEXT: }
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 0 [
: BOLT-NEXT: EMPTY
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 1 [
: BOLT-NEXT: Name 1 {
: BOLT-NEXT: Hash: 0x7C96E4DB
: BOLT-NEXT: String: {{.+}} "Foo2"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV1]]
: BOLT-NEXT: Tag: DW_TAG_structure_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x00
: BOLT-NEXT: DW_IDX_die_offset: 0x00000068
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 2 [
: BOLT-NEXT: Name 2 {
: BOLT-NEXT: Hash: 0xBA564846
: BOLT-NEXT: String: {{.+}} "Foo2Int"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV1]]
: BOLT-NEXT: Tag: DW_TAG_structure_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x01
: BOLT-NEXT: DW_IDX_die_offset: 0x00000025
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 3 [
: BOLT-NEXT: Name 3 {
: BOLT-NEXT: Hash: 0xB888030
: BOLT-NEXT: String: {{.+}} "int"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV2]]
: BOLT-NEXT: Tag: DW_TAG_base_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x01
: BOLT-NEXT: DW_IDX_die_offset: 0x00000043
: BOLT-NEXT: }
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV2]]
: BOLT-NEXT: Tag: DW_TAG_base_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x00
: BOLT-NEXT: DW_IDX_die_offset: 0x00000056
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: Name 4 {
: BOLT-NEXT: Hash: 0xF73809C
: BOLT-NEXT: String: {{.+}} "Foo2a"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV1]]
: BOLT-NEXT: Tag: DW_TAG_structure_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x00
: BOLT-NEXT: DW_IDX_die_offset: 0x00000078
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: Name 5 {
: BOLT-NEXT: Hash: 0x7C96CB76
: BOLT-NEXT: String: {{.+}} "fint"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV3]]
: BOLT-NEXT: Tag: DW_TAG_variable
: BOLT-NEXT: DW_IDX_compile_unit: 0x01
: BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: Name 6 {
: BOLT-NEXT: Hash: 0x7C9A7F6A
: BOLT-NEXT: String: {{.+}} "main"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV4]]
: BOLT-NEXT: Tag: DW_TAG_subprogram
: BOLT-NEXT: DW_IDX_compile_unit: 0x00
: BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 4 [
: BOLT-NEXT: EMPTY
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 5 [
: BOLT-NEXT: Name 7 {
: BOLT-NEXT: Hash: 0x7C952063
: BOLT-NEXT: String: {{.+}} "char"
: BOLT-NEXT: Entry @ {{.+}} {
: BOLT-NEXT: Abbrev: [[ABBREV2]]
: BOLT-NEXT: Tag: DW_TAG_base_type
: BOLT-NEXT: DW_IDX_compile_unit: 0x00
: BOLT-NEXT: DW_IDX_die_offset: 0x00000064
: BOLT-NEXT: }
: BOLT-NEXT: }
: BOLT-NEXT: ]
: BOLT-NEXT: Bucket 6 [
: BOLT-NEXT: EMPTY
: BOLT-NEXT: ]
: BOLT-NEXT: }
101 changes: 101 additions & 0 deletions bolt/test/X86/dwarf5-df-one-cu-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-debug-names-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt > log.txt
; RUN: cat log.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with one CU for split dwarf.

; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xA9
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 1
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 5
; BOLT-NEXT: Name count: 5
; BOLT-NEXT: Abbreviations table size: 0x13
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: 0x00000000
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0x7C96E4DB
; BOLT-NEXT: String: {{.+}} "Foo2"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000068
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000056
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000078
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000064
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: }
234 changes: 234 additions & 0 deletions bolt/test/X86/dwarf5-df-types-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-debug-names-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-debug-names-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info -r 0 main.dwo.dwo > log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 helper.dwo.dwo >> log.txt
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt >> log.txt
; RUN: cat log.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with two CUs and foreign TUs.

; BOLT: type_signature = [[TYPE:0x[0-9a-f]*]]
; BOLT: type_signature = [[TYPE1:0x[0-9a-f]*]]
; BOLT: Compile Unit
; BOLT: type_signature = [[TYPE2:0x[0-9a-f]*]]
; BOLT: type_signature = [[TYPE3:0x[0-9a-f]*]]
; BOLT: Compile Unit
; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit

; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x174
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 2
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 4
; BOLT-NEXT: Bucket count: 9
; BOLT-NEXT: Name count: 9
; BOLT-NEXT: Abbreviations table size: 0x2D
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET]]
; BOLT-NEXT: CU[1]: [[OFFSET1]]
; BOLT-NEXT: ]
; BOLT-NEXT: Foreign Type Unit signatures [
; BOLT-NEXT: ForeignTU[0]: [[TYPE]]
; BOLT-NEXT: ForeignTU[1]: [[TYPE1]]
; BOLT-NEXT: ForeignTU[2]: [[TYPE2]]
; BOLT-NEXT: ForeignTU[3]: [[TYPE3]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0x7C96E4DB
; BOLT-NEXT: String: {{.+}} "Foo2"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0xB5063D0B
; BOLT-NEXT: String: {{.+}} "_Z3foov"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0xFDE48034
; BOLT-NEXT: String: {{.+}} "fooint"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000025
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x5
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x02
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000056
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "foo"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 6 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x03
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0xBA564846
; BOLT-NEXT: String: {{.+}} "Foo2Int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x02
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 5 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: Name 8 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 8 [
; BOLT-NEXT: Name 9 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x5
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000036
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x5
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000048
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x5
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x03
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000048
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000064
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: }
129 changes: 129 additions & 0 deletions bolt/test/X86/dwarf5-df-types-one-cu-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-debug-names-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info -r 0 main.dwo.dwo > log.txt
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt >> log.txt
; RUN: cat log.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with one CU and foreign TUs.

; BOLT: type_signature = [[TYPE:0x[0-9a-f]*]]
; BOLT: type_signature = [[TYPE1:0x[0-9a-f]*]]
; BOLT: Compile Unit
; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xD1
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 1
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 2
; BOLT-NEXT: Bucket count: 5
; BOLT-NEXT: Name count: 5
; BOLT-NEXT: Abbreviations table size: 0x1D
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET]]
; BOLT-NEXT: ]
; BOLT-NEXT: Foreign Type Unit signatures [
; BOLT-NEXT: ForeignTU[0]: [[TYPE]]
; BOLT-NEXT: ForeignTU[1]: [[TYPE1]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0x7C96E4DB
; BOLT-NEXT: String: {{.+}} "Foo2"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000056
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000036
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000048
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000064
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: }
178 changes: 178 additions & 0 deletions bolt/test/X86/dwarf5-one-cu-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-main.s -o %tmain.o
; RUN: %clang %cflags -gdwarf-5 %tmain.o -o %tmain.exe
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info -r 0 --debug-names %tmain.exe.bolt > %tlog.txt
; RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with one CUs

; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x13E
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 1
; BOLT-NEXT: Local TU count: 0
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 11
; BOLT-NEXT: Name count: 11
; BOLT-NEXT: Abbreviations table size: 0x1F
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET1]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV5:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000104
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c5
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "Foo"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c9
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0x392140FA
; BOLT-NEXT: String: {{.+}} "t2<&fooint>"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 5 {
; BOLT-NEXT: Hash: 0x7C96E4DB
; BOLT-NEXT: String: {{.+}} "Foo2"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000eb
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 4 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 5 [
; BOLT-NEXT: Name 6 {
; BOLT-NEXT: Hash: 0x59796A
; BOLT-NEXT: String: {{.+}} "t1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000062
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0x5979AC
; BOLT-NEXT: String: {{.+}} "v1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: Name 8 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005d
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: Name 9 {
; BOLT-NEXT: Hash: 0x59796C
; BOLT-NEXT: String: {{.+}} "t3"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 10 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x00000073
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 8 [
; BOLT-NEXT: Name 11 {
; BOLT-NEXT: Hash: 0x8CFC710C
; BOLT-NEXT: String: {{.+}} "(anonymous namespace)"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV5]]
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_die_offset: 0x00000061
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV5]]
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_die_offset: 0x00000061
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 9 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 10 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: }
129 changes: 129 additions & 0 deletions bolt/test/X86/dwarf5-types-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-debug-names-main.s -o %tmain.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-debug-names-helper.s -o %thelper.o
; RUN: %clang %cflags -gdwarf-5 %tmain.o %thelper.o -o %tmain.exe
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info --debug-names %tmain.exe.bolt > %tlog.txt
; RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with two CUs and a local TU.

; BOLT: [[OFFSET:0x[0-9a-f]*]]: Type Unit
; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit


; BOLT: Name Index @ 0x0 {
; BOLT: Header {
; BOLT: Length: 0xE1
; BOLT: Format: DWARF32
; BOLT: Version: 5
; BOLT: CU count: 2
; BOLT: Local TU count: 1
; BOLT: Foreign TU count: 0
; BOLT: Bucket count: 6
; BOLT: Name count: 6
; BOLT: Abbreviations table size: 0x21
; BOLT: Augmentation: 'BOLT'
; BOLT: }
; BOLT: Compilation Unit offsets [
; BOLT: CU[0]: [[OFFSET1]]
; BOLT: CU[1]: [[OFFSET2]]
; BOLT: ]
; BOLT: Local Type Unit offsets [
; BOLT: LocalTU[0]: [[OFFSET]]
; BOLT: ]
; BOLT: Abbreviations [
; BOLT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
; BOLT: Tag: DW_TAG_structure_type
; BOLT: DW_IDX_type_unit: DW_FORM_data1
; BOLT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT: }
; BOLT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT: Tag: DW_TAG_subprogram
; BOLT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT: }
; BOLT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT: Tag: DW_TAG_base_type
; BOLT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT: }
; BOLT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT: Tag: DW_TAG_base_type
; BOLT: DW_IDX_type_unit: DW_FORM_data1
; BOLT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT: }
; BOLT: ]
; BOLT: Bucket 0 [
; BOLT: Name 1 {
; BOLT: Hash: 0xF73809C
; BOLT: String: {{.+}} "Foo2a"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV]]
; BOLT: Tag: DW_TAG_structure_type
; BOLT: DW_IDX_type_unit: 0x00
; BOLT: DW_IDX_die_offset: 0x00000023
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: Bucket 1 [
; BOLT: Name 2 {
; BOLT: Hash: 0xB5063D0B
; BOLT: String: {{.+}} "_Z3foov"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV1]]
; BOLT: Tag: DW_TAG_subprogram
; BOLT: DW_IDX_compile_unit: 0x01
; BOLT: DW_IDX_die_offset: 0x00000024
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: Bucket 2 [
; BOLT: Name 3 {
; BOLT: Hash: 0xB888030
; BOLT: String: {{.+}} "int"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV2]]
; BOLT: Tag: DW_TAG_base_type
; BOLT: DW_IDX_compile_unit: 0x01
; BOLT: DW_IDX_die_offset: 0x00000040
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: Bucket 3 [
; BOLT: Name 4 {
; BOLT: Hash: 0xB887389
; BOLT: String: {{.+}} "foo"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV1]]
; BOLT: Tag: DW_TAG_subprogram
; BOLT: DW_IDX_compile_unit: 0x01
; BOLT: DW_IDX_die_offset: 0x00000024
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: Bucket 4 [
; BOLT: Name 5 {
; BOLT: Hash: 0x7C9A7F6A
; BOLT: String: {{.+}} "main"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV1]]
; BOLT: Tag: DW_TAG_subprogram
; BOLT: DW_IDX_compile_unit: 0x00
; BOLT: DW_IDX_die_offset: 0x00000024
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: Bucket 5 [
; BOLT: Name 6 {
; BOLT: Hash: 0x7C952063
; BOLT: String: {{.+}} "char"
; BOLT: Entry @ {{.+}} {
; BOLT: Abbrev: [[ABBREV3]]
; BOLT: Tag: DW_TAG_base_type
; BOLT: DW_IDX_type_unit: 0x00
; BOLT: DW_IDX_die_offset: 0x00000038
; BOLT: }
; BOLT: }
; BOLT: ]
; BOLT: }
98 changes: 98 additions & 0 deletions bolt/test/X86/dwarf5-types-one-cu-debug-names.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-debug-names-main.s -o %tmain.o
; RUN: %clang %cflags -gdwarf-5 %tmain.o -o %tmain.exe
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --debug-info --debug-names %tmain.exe.bolt > %tlog.txt
; RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s

;; Tests that BOLT correctly generates .debug_names section with one CU and a local TU.

; BOLT: [[OFFSET:0x[0-9a-f]*]]: Type Unit
; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit

; BOLT:Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xA3
; BOLT-NEXT: Format: DWARF32
; BOLT-NEXT: Version: 5
; BOLT-NEXT: CU count: 1
; BOLT-NEXT: Local TU count: 1
; BOLT-NEXT: Foreign TU count: 0
; BOLT-NEXT: Bucket count: 4
; BOLT-NEXT: Name count: 4
; BOLT-NEXT: Abbreviations table size: 0x1D
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: [[OFFSET1]]
; BOLT-NEXT: ]
; BOLT-NEXT: Local Type Unit offsets [
; BOLT-NEXT: LocalTU[0]: [[OFFSET]]
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
; BOLT-NEXT: Hash: 0xB888030
; BOLT-NEXT: String: {{.+}} "int"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
; BOLT-NEXT: Hash: 0xF73809C
; BOLT-NEXT: String: {{.+}} "Foo2a"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000023
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 1 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 3 {
; BOLT-NEXT: Hash: 0x7C9A7F6A
; BOLT-NEXT: String: {{.+}} "main"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 3 [
; BOLT-NEXT: Name 4 {
; BOLT-NEXT: Hash: 0x7C952063
; BOLT-NEXT: String: {{.+}} "char"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000038
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT:}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Test that BOLT errs when trying to instrument a binary with a different
# architecture than the one BOLT is built for.

# REQUIRES: x86_64-linux,bolt-runtime,target=x86_64{{.*}}
# REQUIRES: system-linux,bolt-runtime
# REQUIRES: aarch64-registered-target

# RUN: llvm-mc -triple aarch64 -filetype=obj %s -o %t.o
# RUN: ld.lld -q -pie -o %t.exe %t.o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
hasAncestor(functionDecl().bind("func")),
hasAncestor(functionDecl(
isDefinition(), equalsBoundNode("func"), ToParam,
unless(hasDescendant(std::move(ForwardCallMatcher)))))),
unless(anyOf(isDeleted(), hasDescendant(std::move(
ForwardCallMatcher))))))),
this);
}

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/unused-local-non-trivial-variable>` check by
ignoring local variable with ``[maybe_unused]`` attribute.

- Improved :doc:`cppcoreguidelines-missing-std-forward
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by no longer
giving false positives for deleted functions.

- Cleaned up :doc:`cppcoreguidelines-prefer-member-initializer
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>`
by removing enforcement of rule `C.48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,18 @@ void lambda_value_reference_auxiliary_var(T&& t) {
}

} // namespace negative_cases

namespace deleted_functions {

template <typename T>
void f(T &&) = delete;

struct S {
template <typename T>
S(T &&) = delete;

template <typename T>
void operator&(T &&) = delete;
};

} // namespace deleted_functions
140 changes: 140 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,146 @@ the configuration (without a prefix: ``Auto``).
bbb >>= 2;


.. _AlignConsecutiveTableGenDefinitionColons:

**AlignConsecutiveTableGenDefinitionColons** (``AlignConsecutiveStyle``) :versionbadge:`clang-format 19` :ref:`ΒΆ <AlignConsecutiveTableGenDefinitionColons>`
Style of aligning consecutive TableGen definition colons.
This aligns the inheritance colons of consecutive definitions.

.. code-block:: c++

def Def : Parent {}
def DefDef : Parent {}
def DefDefDef : Parent {}

Nested configuration flags:

Alignment options.

They can also be read as a whole for compatibility. The choices are:
- None
- Consecutive
- AcrossEmptyLines
- AcrossComments
- AcrossEmptyLinesAndComments

For example, to align across empty lines and not across comments, either
of these work.

.. code-block:: c++

AlignConsecutiveMacros: AcrossEmptyLines

AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false

* ``bool Enabled`` Whether aligning is enabled.

.. code-block:: c++

#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define foo(x) (x * x)
#define bar(y, z) (y + z)

int a = 1;
int somelongname = 2;
double c = 3;

int aaaa : 1;
int b : 12;
int ccc : 8;

int aaaa = 12;
float b = 23;
std::string ccc;

* ``bool AcrossEmptyLines`` Whether to align across empty lines.

.. code-block:: c++

true:
int a = 1;
int somelongname = 2;
double c = 3;

int d = 3;

false:
int a = 1;
int somelongname = 2;
double c = 3;

int d = 3;

* ``bool AcrossComments`` Whether to align across comments.

.. code-block:: c++

true:
int d = 3;
/* A comment. */
double e = 4;
false:
int d = 3;
/* A comment. */
double e = 4;
* ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound assignments
like ``+=`` are aligned along with ``=``.

.. code-block:: c++

true:
a &= 2;
bbb = 2;

false:
a &= 2;
bbb = 2;

* ``bool AlignFunctionPointers`` Only for ``AlignConsecutiveDeclarations``. Whether function pointers are
aligned.

.. code-block:: c++

true:
unsigned i;
int &r;
int *p;
int (*f)();
false:
unsigned i;
int &r;
int *p;
int (*f)();
* ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``. Whether short assignment
operators are left-padded to the same length as long ones in order to
put all assignment operators to the right of the left hand side.

.. code-block:: c++

true:
a >>= 2;
bbb = 2;

a = 2;
bbb >>= 2;

false:
a >>= 2;
bbb = 2;

a = 2;
bbb >>= 2;


.. _AlignEscapedNewlines:

**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5` :ref:`ΒΆ <AlignEscapedNewlines>`
Expand Down
Loading