28 changes: 22 additions & 6 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,32 @@ getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
return nullptr;
}

uint32_t DIEBuilder::finalizeDIEs(DWARFUnit &CU, DIE &Die,
uint32_t &CurOffset) {
uint32_t DIEBuilder::finalizeDIEs(
DWARFUnit &CU, DIE &Die,
std::vector<std::optional<BOLTDWARF5AccelTableData *>> &Parents,
uint32_t &CurOffset) {
getState().DWARFDieAddressesParsed.erase(Die.getOffset());
uint32_t CurSize = 0;
Die.setOffset(CurOffset);
DebugNamesTable.addAccelTableEntry(
CU, Die, SkeletonCU ? SkeletonCU->getDWOId() : std::nullopt);
std::optional<BOLTDWARF5AccelTableData *> NameEntry =
DebugNamesTable.addAccelTableEntry(
CU, Die, SkeletonCU ? SkeletonCU->getDWOId() : std::nullopt,
Parents.back());
// It is possible that an indexed debugging information entry has a parent
// that is not indexed (for example, if its parent does not have a name
// attribute). In such a case, a parent attribute may point to a nameless
// index entry (that is, one that cannot be reached from any entry in the name
// table), or it may point to the nearest ancestor that does have an index
// entry.
if (NameEntry)
Parents.push_back(std::move(NameEntry));
for (DIEValue &Val : Die.values())
CurSize += Val.sizeOf(CU.getFormParams());
CurSize += getULEB128Size(Die.getAbbrevNumber());
CurOffset += CurSize;

for (DIE &Child : Die.children()) {
uint32_t ChildSize = finalizeDIEs(CU, Child, CurOffset);
uint32_t ChildSize = finalizeDIEs(CU, Child, Parents, CurOffset);
CurSize += ChildSize;
}
// for children end mark.
Expand All @@ -400,6 +412,8 @@ uint32_t DIEBuilder::finalizeDIEs(DWARFUnit &CU, DIE &Die,
}

Die.setSize(CurSize);
if (NameEntry)
Parents.pop_back();

return CurSize;
}
Expand All @@ -410,7 +424,9 @@ void DIEBuilder::finish() {
uint32_t HeaderSize = CU.getHeaderSize();
uint32_t CurOffset = HeaderSize;
DebugNamesTable.setCurrentUnit(CU, UnitStartOffset);
finalizeDIEs(CU, *UnitDIE, CurOffset);
std::vector<std::optional<BOLTDWARF5AccelTableData *>> Parents;
Parents.push_back(std::nullopt);
finalizeDIEs(CU, *UnitDIE, Parents, CurOffset);

DWARFUnitInfo &CurUnitInfo = getUnitInfoByDwarfUnit(CU);
CurUnitInfo.UnitOffset = UnitStartOffset;
Expand Down
118 changes: 105 additions & 13 deletions bolt/lib/Core/DebugNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/LEB128.h"
#include <cstdint>
#include <optional>

namespace llvm {
namespace bolt {
Expand Down Expand Up @@ -163,10 +164,16 @@ static uint64_t getNameOffset(BinaryContext &BC, DWARFUnit &Unit,
Index * DwarfOffsetByteSize);
}

void DWARF5AcceleratorTable::addAccelTableEntry(
DWARFUnit &Unit, const DIE &Die, const std::optional<uint64_t> &DWOID) {
static uint64_t getEntryID(const BOLTDWARF5AccelTableData &Entry) {
return reinterpret_cast<uint64_t>(&Entry);
}

std::optional<BOLTDWARF5AccelTableData *>
DWARF5AcceleratorTable::addAccelTableEntry(
DWARFUnit &Unit, const DIE &Die, const std::optional<uint64_t> &DWOID,
std::optional<BOLTDWARF5AccelTableData *> &Parent) {
if (Unit.getVersion() < 5 || !NeedToCreate)
return;
return std::nullopt;
std::string NameToUse = "";
auto canProcess = [&](const DIE &Die) -> bool {
switch (Die.getTag()) {
Expand Down Expand Up @@ -217,7 +224,7 @@ void DWARF5AcceleratorTable::addAccelTableEntry(
};

if (!canProcess(Die))
return;
return std::nullopt;

// Addes a Unit to either CU, LocalTU or ForeignTU list the first time we
// encounter it.
Expand All @@ -227,10 +234,10 @@ void DWARF5AcceleratorTable::addAccelTableEntry(
addUnit(Unit, DWOID);
}

auto addEntry = [&](DIEValue ValName) -> void {
auto getName = [&](DIEValue ValName) -> std::optional<std::string> {
if ((!ValName || ValName.getForm() == dwarf::DW_FORM_string) &&
NameToUse.empty())
return;
return std::nullopt;
std::string Name = "";
uint64_t NameIndexOffset = 0;
if (NameToUse.empty()) {
Expand Down Expand Up @@ -260,7 +267,16 @@ void DWARF5AcceleratorTable::addAccelTableEntry(
// This the same hash function used in DWARF5AccelTableData.
It.HashValue = caseFoldingDjbHash(Name);
}
return Name;
};

auto addEntry =
[&](DIEValue ValName) -> std::optional<BOLTDWARF5AccelTableData *> {
std::optional<std::string> Name = getName(ValName);
if (!Name)
return std::nullopt;

auto &It = Entries[*Name];
bool IsTU = false;
uint32_t DieTag = 0;
uint32_t UnitID = getUnitID(Unit, IsTU, DieTag);
Expand All @@ -270,18 +286,53 @@ void DWARF5AcceleratorTable::addAccelTableEntry(
if (Iter == CUOffsetsToPatch.end())
BC.errs() << "BOLT-WARNING: [internal-dwarf-warning]: Could not find "
"DWO ID in CU offsets for second Unit Index "
<< Name << ". For DIE at offset: "
<< *Name << ". For DIE at offset: "
<< Twine::utohexstr(CurrentUnitOffset + Die.getOffset())
<< ".\n";
SecondIndex = Iter->second;
}
std::optional<uint64_t> ParentOffset =
(Parent ? std::optional<uint64_t>(getEntryID(**Parent)) : std::nullopt);
// This will be populated later in writeEntry.
// This way only parent entries get tracked.
// Keeping memory footprint down.
if (ParentOffset)
EntryRelativeOffsets.insert({*ParentOffset, 0});
It.Values.push_back(new (Allocator) BOLTDWARF5AccelTableData(
Die.getOffset(), std::nullopt, DieTag, UnitID, IsTU, SecondIndex));
Die.getOffset(), ParentOffset, DieTag, UnitID, IsTU, SecondIndex));
return It.Values.back();
};

addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_name));
addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_linkage_name));
return;
// Minor optimization not to add entry twice for DW_TAG_namespace if it has no
// DW_AT_name.
if (!(Die.getTag() == dwarf::DW_TAG_namespace &&
!Die.findAttribute(dwarf::Attribute::DW_AT_name)))
addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_linkage_name));
// For the purposes of determining whether a debugging information entry has a
// particular attribute (such as DW_AT_name), if debugging information entry A
// has a DW_AT_specification or DW_AT_abstract_origin attribute pointing to
// another debugging information entry B, any attributes of B are considered
// to be part of A.
auto processReferencedDie = [&](const dwarf::Attribute &Attr)
-> std::optional<BOLTDWARF5AccelTableData *> {
const DIEValue Value = Die.findAttribute(Attr);
if (!Value)
return std::nullopt;
const DIEEntry &DIEENtry = Value.getDIEEntry();
DIE &EntryDie = DIEENtry.getEntry();
addEntry(EntryDie.findAttribute(dwarf::Attribute::DW_AT_linkage_name));
return addEntry(EntryDie.findAttribute(dwarf::Attribute::DW_AT_name));
};

if (std::optional<BOLTDWARF5AccelTableData *> Entry =
processReferencedDie(dwarf::Attribute::DW_AT_abstract_origin))
return *Entry;
if (std::optional<BOLTDWARF5AccelTableData *> Entry =
processReferencedDie(dwarf::Attribute::DW_AT_specification))
return *Entry;

return addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_name));
;
}

/// Algorithm from llvm implementation.
Expand Down Expand Up @@ -382,6 +433,11 @@ void DWARF5AcceleratorTable::populateAbbrevsMap() {
if (SecondEntryRet)
Abbrev.addAttribute(SecondEntryRet->Encoding);
Abbrev.addAttribute({dwarf::DW_IDX_die_offset, dwarf::DW_FORM_ref4});
if (std::optional<uint64_t> Offset = Value->getParentDieOffset())
Abbrev.addAttribute({dwarf::DW_IDX_parent, dwarf::DW_FORM_ref4});
else
Abbrev.addAttribute(
{dwarf::DW_IDX_parent, dwarf::DW_FORM_flag_present});
FoldingSetNodeID ID;
Abbrev.Profile(ID);
void *InsertPos;
Expand All @@ -401,7 +457,11 @@ void DWARF5AcceleratorTable::populateAbbrevsMap() {
}
}

void DWARF5AcceleratorTable::writeEntry(const BOLTDWARF5AccelTableData &Entry) {
void DWARF5AcceleratorTable::writeEntry(BOLTDWARF5AccelTableData &Entry) {
const uint64_t EntryID = getEntryID(Entry);
if (EntryRelativeOffsets.find(EntryID) != EntryRelativeOffsets.end())
EntryRelativeOffsets[EntryID] = EntriesBuffer->size();

const std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
getIndexForEntry(Entry);
// For forgeign type (FTU) units that need to refer to the FTU and to the CU.
Expand Down Expand Up @@ -456,6 +516,17 @@ void DWARF5AcceleratorTable::writeEntry(const BOLTDWARF5AccelTableData &Entry) {
llvm::endianness::little);
break;
}
case dwarf::DW_IDX_parent: {
assert(
(AttrEnc.Form == dwarf::DW_FORM_ref4 && Entry.getParentDieOffset()) ||
AttrEnc.Form == dwarf::DW_FORM_flag_present);
if (std::optional<uint64_t> ParentOffset = Entry.getParentDieOffset()) {
Entry.setPatchOffset(EntriesBuffer->size());
support::endian::write(*Entriestream, static_cast<uint32_t>(UINT32_MAX),
llvm::endianness::little);
}
break;
}
}
}
}
Expand All @@ -464,13 +535,34 @@ void DWARF5AcceleratorTable::writeEntries() {
for (auto &Bucket : getBuckets()) {
for (DWARF5AcceleratorTable::HashData *Hash : Bucket) {
Hash->EntryOffset = EntriesBuffer->size();
for (const BOLTDWARF5AccelTableData *Value : Hash->Values) {
for (BOLTDWARF5AccelTableData *Value : Hash->Values) {
writeEntry(*Value);
}
support::endian::write(*Entriestream, static_cast<uint8_t>(0),
llvm::endianness::little);
}
}
// Patching parent offsets.
for (auto &Bucket : getBuckets()) {
for (DWARF5AcceleratorTable::HashData *Hash : Bucket) {
for (BOLTDWARF5AccelTableData *Entry : Hash->Values) {
std::optional<uint64_t> ParentOffset = Entry->getParentDieOffset();
if (!ParentOffset)
continue;
if (const auto Iter = EntryRelativeOffsets.find(*ParentOffset);
Iter != EntryRelativeOffsets.end()) {
const uint64_t PatchOffset = Entry->getPatchOffset();
uint32_t *Ptr = reinterpret_cast<uint32_t *>(
&EntriesBuffer.get()->data()[PatchOffset]);
*Ptr = Iter->second;
} else {
BC.errs() << "BOLT-WARNING: [internal-dwarf-warning]: Could not find "
"entry with offset "
<< *ParentOffset << "\n";
}
}
}
}
}

void DWARF5AcceleratorTable::writeAugmentationString() {
Expand Down
22 changes: 22 additions & 0 deletions bolt/lib/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,28 @@ void MCPlusBuilder::setSize(MCInst &Inst, uint32_t Size) const {
setAnnotationOpValue(Inst, MCAnnotation::kSize, Size);
}

bool MCPlusBuilder::isDynamicBranch(const MCInst &Inst) const {
if (!hasAnnotation(Inst, MCAnnotation::kDynamicBranch))
return false;
assert(isBranch(Inst) && "Branch expected.");
return true;
}

std::optional<uint32_t>
MCPlusBuilder::getDynamicBranchID(const MCInst &Inst) const {
if (std::optional<int64_t> Value =
getAnnotationOpValue(Inst, MCAnnotation::kDynamicBranch)) {
assert(isBranch(Inst) && "Branch expected.");
return static_cast<uint32_t>(*Value);
}
return std::nullopt;
}

void MCPlusBuilder::setDynamicBranch(MCInst &Inst, uint32_t ID) const {
assert(isBranch(Inst) && "Branch expected.");
setAnnotationOpValue(Inst, MCAnnotation::kDynamicBranch, ID);
}

bool MCPlusBuilder::hasAnnotation(const MCInst &Inst, unsigned Index) const {
return (bool)getAnnotationOpValue(Inst, Index);
}
Expand Down
20 changes: 19 additions & 1 deletion bolt/lib/Passes/BinaryPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ static cl::opt<unsigned>
cl::desc("print statistics about basic block ordering"),
cl::init(0), cl::cat(BoltOptCategory));

static cl::opt<bool> PrintLargeFunctions(
"print-large-functions",
cl::desc("print functions that could not be overwritten due to excessive "
"size"),
cl::init(false), cl::cat(BoltOptCategory));

static cl::list<bolt::DynoStats::Category>
PrintSortedBy("print-sorted-by", cl::CommaSeparated,
cl::desc("print functions sorted by order of dyno stats"),
Expand Down Expand Up @@ -570,8 +576,12 @@ Error CheckLargeFunctions::runOnFunctions(BinaryContext &BC) {
uint64_t HotSize, ColdSize;
std::tie(HotSize, ColdSize) =
BC.calculateEmittedSize(BF, /*FixBranches=*/false);
if (HotSize > BF.getMaxSize())
if (HotSize > BF.getMaxSize()) {
if (opts::PrintLargeFunctions)
BC.outs() << "BOLT-INFO: " << BF << " size exceeds allocated space by "
<< (HotSize - BF.getMaxSize()) << " bytes\n";
BF.setSimple(false);
}
};

ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
Expand Down Expand Up @@ -852,6 +862,10 @@ uint64_t SimplifyConditionalTailCalls::fixTailCalls(BinaryFunction &BF) {
assert(Result && "internal error analyzing conditional branch");
assert(CondBranch && "conditional branch expected");

// Skip dynamic branches for now.
if (BF.getBinaryContext().MIB->isDynamicBranch(*CondBranch))
continue;

// It's possible that PredBB is also a successor to BB that may have
// been processed by a previous iteration of the SCTC loop, in which
// case it may have been marked invalid. We should skip rewriting in
Expand Down Expand Up @@ -1012,6 +1026,10 @@ uint64_t ShortenInstructions::shortenInstructions(BinaryFunction &Function) {
const BinaryContext &BC = Function.getBinaryContext();
for (BinaryBasicBlock &BB : Function) {
for (MCInst &Inst : BB) {
// Skip shortening instructions with Size annotation.
if (BC.MIB->getSize(Inst))
continue;

MCInst OriginalInst;
if (opts::Verbosity > 2)
OriginalInst = Inst;
Expand Down
120 changes: 109 additions & 11 deletions bolt/lib/Profile/BoltAddressTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const char *BoltAddressTranslation::SECTION_NAME = ".note.bolt_bat";
void BoltAddressTranslation::writeEntriesForBB(MapTy &Map,
const BinaryBasicBlock &BB,
uint64_t FuncAddress) {
uint64_t HotFuncAddress = ColdPartSource.count(FuncAddress)
? ColdPartSource[FuncAddress]
: FuncAddress;
const uint64_t BBOutputOffset =
BB.getOutputAddressRange().first - FuncAddress;
const uint32_t BBInputOffset = BB.getInputOffset();
Expand All @@ -39,6 +42,11 @@ void BoltAddressTranslation::writeEntriesForBB(MapTy &Map,
LLVM_DEBUG(dbgs() << "BB " << BB.getName() << "\n");
LLVM_DEBUG(dbgs() << " Key: " << Twine::utohexstr(BBOutputOffset)
<< " Val: " << Twine::utohexstr(BBInputOffset) << "\n");
LLVM_DEBUG(dbgs() << formatv(" Hash: {0:x}\n",
getBBHash(HotFuncAddress, BBInputOffset)));
(void)HotFuncAddress;
LLVM_DEBUG(dbgs() << formatv(" Index: {0}\n",
getBBIndex(HotFuncAddress, BBInputOffset)));
// In case of conflicts (same Key mapping to different Vals), the last
// update takes precedence. Of course it is not ideal to have conflicts and
// those happen when we have an empty BB that either contained only
Expand Down Expand Up @@ -72,20 +80,28 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Writing BOLT Address Translation Tables\n");
for (auto &BFI : BC.getBinaryFunctions()) {
const BinaryFunction &Function = BFI.second;
const uint64_t InputAddress = Function.getAddress();
const uint64_t OutputAddress = Function.getOutputAddress();
// We don't need a translation table if the body of the function hasn't
// changed
if (Function.isIgnored() || (!BC.HasRelocations && !Function.isSimple()))
continue;

// TBD: handle BAT functions w/multiple entry points.
if (Function.isMultiEntry())
continue;

LLVM_DEBUG(dbgs() << "Function name: " << Function.getPrintName() << "\n");
LLVM_DEBUG(dbgs() << " Address reference: 0x"
<< Twine::utohexstr(Function.getOutputAddress()) << "\n");
LLVM_DEBUG(dbgs() << formatv(" Hash: {0:x}\n", getBFHash(OutputAddress)));

MapTy Map;
for (const BinaryBasicBlock *const BB :
Function.getLayout().getMainFragment())
writeEntriesForBB(Map, *BB, Function.getOutputAddress());
Maps.emplace(Function.getOutputAddress(), std::move(Map));
ReverseMap.emplace(OutputAddress, InputAddress);

if (!Function.isSplit())
continue;
Expand All @@ -94,12 +110,12 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
LLVM_DEBUG(dbgs() << " Cold part\n");
for (const FunctionFragment &FF :
Function.getLayout().getSplitFragments()) {
ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress());
Map.clear();
for (const BinaryBasicBlock *const BB : FF)
writeEntriesForBB(Map, *BB, FF.getAddress());

Maps.emplace(FF.getAddress(), std::move(Map));
ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress());
}
}

Expand All @@ -109,6 +125,11 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
writeMaps</*Cold=*/true>(Maps, PrevAddress, OS);

BC.outs() << "BOLT-INFO: Wrote " << Maps.size() << " BAT maps\n";
const uint64_t NumBBHashes = std::accumulate(
FuncHashes.begin(), FuncHashes.end(), 0ull,
[](size_t Acc, const auto &B) { return Acc + B.second.second.size(); });
BC.outs() << "BOLT-INFO: Wrote " << FuncHashes.size() << " function and "
<< NumBBHashes << " basic block hashes\n";
}

APInt BoltAddressTranslation::calculateBranchEntriesBitMask(MapTy &Map,
Expand Down Expand Up @@ -155,6 +176,11 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
// Only process cold fragments in cold mode, and vice versa.
if (Cold != ColdPartSource.count(Address))
continue;
// NB: here we use the input address because hashes are saved early (in
// `saveMetadata`) before output addresses are assigned.
const uint64_t HotInputAddress =
ReverseMap[Cold ? ColdPartSource[Address] : Address];
std::pair<size_t, BBHashMap> &FuncHashPair = FuncHashes[HotInputAddress];
MapTy &Map = MapEntry.second;
const uint32_t NumEntries = Map.size();
LLVM_DEBUG(dbgs() << "Writing " << NumEntries << " entries for 0x"
Expand All @@ -166,6 +192,14 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
std::distance(ColdPartSource.begin(), ColdPartSource.find(Address));
encodeULEB128(HotIndex - PrevIndex, OS);
PrevIndex = HotIndex;
} else {
// Function hash
LLVM_DEBUG(dbgs() << "Hash: " << formatv("{0:x}\n", FuncHashPair.first));
OS.write(reinterpret_cast<char *>(&FuncHashPair.first), 8);
// Number of basic blocks
size_t NumBasicBlocks = FuncHashPair.second.size();
LLVM_DEBUG(dbgs() << "Basic blocks: " << NumBasicBlocks << '\n');
encodeULEB128(NumBasicBlocks, OS);
}
encodeULEB128(NumEntries, OS);
// For hot fragments only: encode the number of equal offsets
Expand All @@ -189,6 +223,7 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
}
size_t Index = 0;
uint64_t InOffset = 0;
size_t PrevBBIndex = 0;
// Output and Input addresses and delta-encoded
for (std::pair<const uint32_t, uint32_t> &KeyVal : Map) {
const uint64_t OutputAddress = KeyVal.first + Address;
Expand All @@ -197,6 +232,17 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
if (Index++ >= EqualElems)
encodeSLEB128(KeyVal.second - InOffset, OS);
InOffset = KeyVal.second; // Keeping InOffset as if BRANCHENTRY is encoded
if ((InOffset & BRANCHENTRY) == 0) {
unsigned BBIndex;
size_t BBHash;
std::tie(BBIndex, BBHash) = FuncHashPair.second[InOffset >> 1];
OS.write(reinterpret_cast<char *>(&BBHash), 8);
// Basic block index in the input binary
encodeULEB128(BBIndex - PrevBBIndex, OS);
PrevBBIndex = BBIndex;
LLVM_DEBUG(dbgs() << formatv("{0:x} -> {1:x} {2:x} {3}\n", KeyVal.first,
InOffset >> 1, BBHash, BBIndex));
}
}
}
}
Expand Down Expand Up @@ -239,12 +285,24 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
size_t HotIndex = 0;
for (uint32_t I = 0; I < NumFunctions; ++I) {
const uint64_t Address = PrevAddress + DE.getULEB128(&Offset, &Err);
uint64_t HotAddress = Cold ? 0 : Address;
PrevAddress = Address;
if (Cold) {
HotIndex += DE.getULEB128(&Offset, &Err);
ColdPartSource.emplace(Address, HotFuncs[HotIndex]);
HotAddress = HotFuncs[HotIndex];
ColdPartSource.emplace(Address, HotAddress);
} else {
HotFuncs.push_back(Address);
// Function hash
const size_t FuncHash = DE.getU64(&Offset, &Err);
FuncHashes[Address].first = FuncHash;
LLVM_DEBUG(dbgs() << formatv("{0:x}: hash {1:x}\n", Address, FuncHash));
// Number of basic blocks
const size_t NumBasicBlocks = DE.getULEB128(&Offset, &Err);
NumBasicBlocksMap.emplace(Address, NumBasicBlocks);
LLVM_DEBUG(dbgs() << formatv("{0:x}: #bbs {1}, {2} bytes\n", Address,
NumBasicBlocks,
getULEB128Size(NumBasicBlocks)));
}
const uint32_t NumEntries = DE.getULEB128(&Offset, &Err);
// Equal offsets, hot fragments only.
Expand Down Expand Up @@ -275,6 +333,7 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
LLVM_DEBUG(dbgs() << "Parsing " << NumEntries << " entries for 0x"
<< Twine::utohexstr(Address) << "\n");
uint64_t InputOffset = 0;
size_t BBIndex = 0;
for (uint32_t J = 0; J < NumEntries; ++J) {
const uint64_t OutputDelta = DE.getULEB128(&Offset, &Err);
const uint64_t OutputAddress = PrevAddress + OutputDelta;
Expand All @@ -288,12 +347,28 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
InputOffset += InputDelta;
}
Map.insert(std::pair<uint32_t, uint32_t>(OutputOffset, InputOffset));
LLVM_DEBUG(
dbgs() << formatv("{0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b), {6:x}\n",
OutputOffset, InputOffset, OutputDelta,
getULEB128Size(OutputDelta), InputDelta,
(J < EqualElems) ? 0 : getSLEB128Size(InputDelta),
OutputAddress));
size_t BBHash = 0;
size_t BBIndexDelta = 0;
const bool IsBranchEntry = InputOffset & BRANCHENTRY;
if (!IsBranchEntry) {
BBHash = DE.getU64(&Offset, &Err);
BBIndexDelta = DE.getULEB128(&Offset, &Err);
BBIndex += BBIndexDelta;
// Map basic block hash to hot fragment by input offset
FuncHashes[HotAddress].second.emplace(InputOffset >> 1,
std::pair(BBIndex, BBHash));
}
LLVM_DEBUG({
dbgs() << formatv(
"{0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b), {6:x}", OutputOffset,
InputOffset, OutputDelta, getULEB128Size(OutputDelta), InputDelta,
(J < EqualElems) ? 0 : getSLEB128Size(InputDelta), OutputAddress);
if (!IsBranchEntry) {
dbgs() << formatv(" {0:x} {1}/{2}b", BBHash, BBIndex,
getULEB128Size(BBIndexDelta));
}
dbgs() << '\n';
});
}
Maps.insert(std::pair<uint64_t, MapTy>(Address, Map));
}
Expand All @@ -303,7 +378,12 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
const size_t NumTables = Maps.size();
OS << "BAT tables for " << NumTables << " functions:\n";
for (const auto &MapEntry : Maps) {
OS << "Function Address: 0x" << Twine::utohexstr(MapEntry.first) << "\n";
const uint64_t Address = MapEntry.first;
const uint64_t HotAddress = fetchParentAddress(Address);
OS << "Function Address: 0x" << Twine::utohexstr(Address);
if (HotAddress == 0)
OS << formatv(", hash: {0:x}", getBFHash(Address));
OS << "\n";
OS << "BB mappings:\n";
for (const auto &Entry : MapEntry.second) {
const bool IsBranch = Entry.second & BRANCHENTRY;
Expand All @@ -312,6 +392,9 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
<< "0x" << Twine::utohexstr(Val);
if (IsBranch)
OS << " (branch)";
else
OS << formatv(" hash: {0:x}",
getBBHash(HotAddress ? HotAddress : Address, Val));
OS << "\n";
}
OS << "\n";
Expand Down Expand Up @@ -435,9 +518,24 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) {
FuncHashes[BF.getAddress()].first = BF.computeHash();
BF.computeBlockHashes();
for (const BinaryBasicBlock &BB : BF)
FuncHashes[BF.getAddress()].second.emplace(BB.getInputOffset(),
BB.getHash());
FuncHashes[BF.getAddress()].second.emplace(
BB.getInputOffset(), std::pair(BB.getIndex(), BB.getHash()));
}
}

unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
uint32_t BBInputOffset) const {
return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
}

size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress,
uint32_t BBInputOffset) const {
return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second;
}

size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const {
return FuncHashes.at(OutputAddress).first;
}

} // namespace bolt
} // namespace llvm
68 changes: 64 additions & 4 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bolt/Core/BinaryFunction.h"
#include "bolt/Profile/BoltAddressTranslation.h"
#include "bolt/Profile/Heatmap.h"
#include "bolt/Profile/YAMLProfileWriter.h"
#include "bolt/Utils/CommandLineOpts.h"
#include "bolt/Utils/Utils.h"
#include "llvm/ADT/STLExtras.h"
Expand Down Expand Up @@ -85,6 +86,7 @@ MaxSamples("max-samples",
cl::cat(AggregatorCategory));

extern cl::opt<opts::ProfileFormatKind> ProfileFormat;
extern cl::opt<std::string> SaveProfile;

cl::opt<bool> ReadPreAggregated(
"pa", cl::desc("skip perf and read data from a pre-aggregated file format"),
Expand Down Expand Up @@ -594,10 +596,21 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
convertBranchData(Function);
}

if (opts::AggregateOnly &&
opts::ProfileFormat == opts::ProfileFormatKind::PF_Fdata) {
if (std::error_code EC = writeAggregatedFile(opts::OutputFilename))
report_error("cannot create output data file", EC);
if (opts::AggregateOnly) {
if (opts::ProfileFormat == opts::ProfileFormatKind::PF_Fdata)
if (std::error_code EC = writeAggregatedFile(opts::OutputFilename))
report_error("cannot create output data file", EC);

// BAT YAML is handled by DataAggregator since normal YAML output requires
// CFG which is not available in BAT mode.
if (usesBAT()) {
if (opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML)
if (std::error_code EC = writeBATYAML(BC, opts::OutputFilename))
report_error("cannot create output data file", EC);
if (!opts::SaveProfile.empty())
if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
report_error("cannot create output data file", EC);
}
}

return Error::success();
Expand Down Expand Up @@ -2258,6 +2271,53 @@ DataAggregator::writeAggregatedFile(StringRef OutputFilename) const {
return std::error_code();
}

std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
StringRef OutputFilename) const {
std::error_code EC;
raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::OpenFlags::OF_None);
if (EC)
return EC;

yaml::bolt::BinaryProfile BP;

// Fill out the header info.
BP.Header.Version = 1;
BP.Header.FileName = std::string(BC.getFilename());
std::optional<StringRef> BuildID = BC.getFileBuildID();
BP.Header.Id = BuildID ? std::string(*BuildID) : "<unknown>";
BP.Header.Origin = std::string(getReaderName());
// Only the input binary layout order is supported.
BP.Header.IsDFSOrder = false;
// FIXME: Need to match hash function used to produce BAT hashes.
BP.Header.HashFunction = HashFunction::Default;

ListSeparator LS(",");
raw_string_ostream EventNamesOS(BP.Header.EventNames);
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames)
EventNamesOS << LS << EventEntry.first().str();

BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE
: BinaryFunction::PF_LBR;

if (!opts::BasicAggregation) {
// Convert profile for functions not covered by BAT
for (auto &BFI : BC.getBinaryFunctions()) {
BinaryFunction &Function = BFI.second;
if (!Function.hasProfile())
continue;
if (BAT->isBATFunction(Function.getAddress()))
continue;
BP.Functions.emplace_back(
YAMLProfileWriter::convert(Function, /*UseDFS=*/false));
}
}

// Write the profile.
yaml::Output Out(OutFile, nullptr, 0);
Out << BP;
return std::error_code();
}

void DataAggregator::dump() const { DataReader::dump(); }

void DataAggregator::dump(const LBREntry &LBR) const {
Expand Down
3 changes: 3 additions & 0 deletions bolt/lib/Profile/StaleProfileMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ void assignProfile(BinaryFunction &BF,

bool YAMLProfileReader::inferStaleProfile(
BinaryFunction &BF, const yaml::bolt::BinaryFunctionProfile &YamlBF) {
if (!BF.hasCFG())
return false;

LLVM_DEBUG(dbgs() << "BOLT-INFO: applying profile inference for "
<< "\"" << BF.getPrintName() << "\"\n");

Expand Down
35 changes: 13 additions & 22 deletions bolt/lib/Profile/YAMLProfileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "bolt/Core/BinaryBasicBlock.h"
#include "bolt/Core/BinaryFunction.h"
#include "bolt/Profile/ProfileReaderBase.h"
#include "bolt/Profile/ProfileYAMLMapping.h"
#include "bolt/Rewrite/RewriteInstance.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
Expand All @@ -26,15 +25,15 @@ extern llvm::cl::opt<bool> ProfileUseDFS;
namespace llvm {
namespace bolt {

namespace {
void convert(const BinaryFunction &BF,
yaml::bolt::BinaryFunctionProfile &YamlBF) {
yaml::bolt::BinaryFunctionProfile
YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS) {
yaml::bolt::BinaryFunctionProfile YamlBF;
const BinaryContext &BC = BF.getBinaryContext();

const uint16_t LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_LBR;

// Prepare function and block hashes
BF.computeHash(opts::ProfileUseDFS);
BF.computeHash(UseDFS);
BF.computeBlockHashes();

YamlBF.Name = BF.getPrintName();
Expand All @@ -44,7 +43,7 @@ void convert(const BinaryFunction &BF,
YamlBF.ExecCount = BF.getKnownExecutionCount();

BinaryFunction::BasicBlockOrderType Order;
llvm::copy(opts::ProfileUseDFS ? BF.dfs() : BF.getLayout().blocks(),
llvm::copy(UseDFS ? BF.dfs() : BF.getLayout().blocks(),
std::back_inserter(Order));

for (const BinaryBasicBlock *BB : Order) {
Expand Down Expand Up @@ -106,20 +105,14 @@ void convert(const BinaryFunction &BF,
TargetName = Callee->getOneName();
}

auto getAnnotationWithDefault = [&](const MCInst &Inst, StringRef Ann) {
return BC.MIB->getAnnotationWithDefault(Instr, Ann, 0ull);
};
if (BC.MIB->getConditionalTailCall(Instr)) {
auto CTCCount =
BC.MIB->tryGetAnnotationAs<uint64_t>(Instr, "CTCTakenCount");
if (CTCCount) {
CSI.Count = *CTCCount;
auto CTCMispreds =
BC.MIB->tryGetAnnotationAs<uint64_t>(Instr, "CTCMispredCount");
if (CTCMispreds)
CSI.Mispreds = *CTCMispreds;
}
CSI.Count = getAnnotationWithDefault(Instr, "CTCTakenCount");
CSI.Mispreds = getAnnotationWithDefault(Instr, "CTCMispredCount");
} else {
auto Count = BC.MIB->tryGetAnnotationAs<uint64_t>(Instr, "Count");
if (Count)
CSI.Count = *Count;
CSI.Count = getAnnotationWithDefault(Instr, "Count");
}

if (CSI.Count)
Expand Down Expand Up @@ -165,8 +158,8 @@ void convert(const BinaryFunction &BF,

YamlBF.Blocks.emplace_back(YamlBB);
}
return YamlBF;
}
} // end anonymous namespace

std::error_code YAMLProfileWriter::writeProfile(const RewriteInstance &RI) {
const BinaryContext &BC = RI.getBinaryContext();
Expand Down Expand Up @@ -222,9 +215,7 @@ std::error_code YAMLProfileWriter::writeProfile(const RewriteInstance &RI) {
if (!BF.hasValidProfile() && !RI.getProfileReader()->isTrustedSource())
continue;

yaml::bolt::BinaryFunctionProfile YamlBF;
convert(BF, YamlBF);
BP.Functions.emplace_back(YamlBF);
BP.Functions.emplace_back(convert(BF, opts::ProfileUseDFS));
}
}

Expand Down
6 changes: 2 additions & 4 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,9 @@ class DIEStreamer : public DwarfStreamer {
DIEStreamer(DIEBuilder *DIEBldr, DWARFRewriter &Rewriter,
DWARFLinkerBase::OutputFileType OutFileType,
raw_pwrite_stream &OutFile,
std::function<StringRef(StringRef Input)> Translator,
DWARFLinkerBase::MessageHandlerTy Warning)
: DwarfStreamer(OutFileType, OutFile, Translator, Warning),
DIEBldr(DIEBldr), Rewriter(Rewriter){};
: DwarfStreamer(OutFileType, OutFile, Warning), DIEBldr(DIEBldr),
Rewriter(Rewriter){};

using DwarfStreamer::emitCompileUnitHeader;

Expand Down Expand Up @@ -469,7 +468,6 @@ createDIEStreamer(const Triple &TheTriple, raw_pwrite_stream &OutFile,

std::unique_ptr<DIEStreamer> Streamer = std::make_unique<DIEStreamer>(
&DIEBldr, Rewriter, DWARFLinkerBase::OutputFileType::Object, OutFile,
[](StringRef Input) -> StringRef { return Input; },
[&](const Twine &Warning, StringRef Context, const DWARFDie *) {});
Error Err = Streamer->init(TheTriple, Swift5ReflectionSegmentName);
if (Err)
Expand Down
387 changes: 387 additions & 0 deletions bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ static cl::opt<cl::boolOrDefault> RelocationMode(
"relocs", cl::desc("use relocations in the binary (default=autodetect)"),
cl::cat(BoltCategory));

static cl::opt<std::string>
SaveProfile("w",
cl::desc("save recorded profile to a file"),
cl::cat(BoltOutputCategory));
extern cl::opt<std::string> SaveProfile;

static cl::list<std::string>
SkipFunctionNames("skip-funcs",
Expand Down Expand Up @@ -732,6 +729,13 @@ Error RewriteInstance::run() {
// Skip disassembling if we have a translation table and we are running an
// aggregation job.
if (opts::AggregateOnly && BAT->enabledFor(InputFile)) {
// YAML profile in BAT mode requires CFG for .bolt.org.text functions
if (!opts::SaveProfile.empty() ||
opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML) {
selectFunctionsToProcess();
disassembleFunctions();
buildFunctionsCFG();
}
processProfileData();
return Error::success();
}
Expand Down Expand Up @@ -2027,14 +2031,6 @@ void RewriteInstance::adjustCommandLineOptions() {

if (opts::Lite)
BC->outs() << "BOLT-INFO: enabling lite mode\n";

if (!opts::SaveProfile.empty() && BAT->enabledFor(InputFile)) {
BC->errs()
<< "BOLT-ERROR: unable to save profile in YAML format for input "
"file processed by BOLT. Please remove -w option and use branch "
"profile.\n";
exit(1);
}
}

namespace {
Expand Down Expand Up @@ -3126,12 +3122,13 @@ void RewriteInstance::processProfileData() {
}
}

if (!opts::SaveProfile.empty()) {
if (!opts::SaveProfile.empty() && !BAT->enabledFor(InputFile)) {
YAMLProfileWriter PW(opts::SaveProfile);
PW.writeProfile(*this);
}
if (opts::AggregateOnly &&
opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML) {
opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML &&
!BAT->enabledFor(InputFile)) {
YAMLProfileWriter PW(opts::OutputFilename);
PW.writeProfile(*this);
}
Expand Down
13 changes: 13 additions & 0 deletions bolt/lib/Target/X86/X86MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
}

bool isUnsupportedBranch(const MCInst &Inst) const override {
if (isDynamicBranch(Inst))
return true;

switch (Inst.getOpcode()) {
default:
return false;
Expand Down Expand Up @@ -2728,6 +2731,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {

void createUncondBranch(MCInst &Inst, const MCSymbol *TBB,
MCContext *Ctx) const override {
Inst.clear();
Inst.setOpcode(X86::JMP_1);
Inst.clear();
Inst.addOperand(MCOperand::createExpr(
Expand Down Expand Up @@ -2776,6 +2780,15 @@ class X86MCPlusBuilder : public MCPlusBuilder {
Inst.addOperand(MCOperand::createImm(CC));
}

void createLongCondBranch(MCInst &Inst, const MCSymbol *Target, unsigned CC,
MCContext *Ctx) const override {
Inst.setOpcode(X86::JCC_4);
Inst.clear();
Inst.addOperand(MCOperand::createExpr(
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx)));
Inst.addOperand(MCOperand::createImm(CC));
}

bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
MCContext *Ctx) const override {
unsigned InvCC = getInvertedCondCode(getCondCode(Inst));
Expand Down
4 changes: 4 additions & 0 deletions bolt/lib/Utils/CommandLineOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ cl::opt<ProfileFormatKind> ProfileFormat(
clEnumValN(PF_YAML, "yaml", "dense YAML representation")),
cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));

cl::opt<std::string> SaveProfile("w",
cl::desc("save recorded profile to a file"),
cl::cat(BoltOutputCategory));

cl::opt<bool> SplitEH("split-eh", cl::desc("split C++ exception handling code"),
cl::Hidden, cl::cat(BoltOptCategory));

Expand Down
81 changes: 81 additions & 0 deletions bolt/test/X86/Inputs/blarge_new.preagg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
B 40164b 401608 109 0
B 401611 4017e0 115 0
B 4017f0 401616 117 0
B 401ba2 4015da 6 0
B 4015d5 401b60 1 0
B 40159a 401b60 5 0
B 401b9d 401b70 615 2
B 401b90 401b99 344 37
B 401ba2 40159f 8 0
B 4015b0 401070 9 0
B 401544 4014a0 6 0
B 40188a 401928 5 0
B 40152a 4014b0 21 0
B 40169e 40165b 2 0
B 4014dd 401070 12 1
B 401509 4014ec 2 2
B 401510 401030 673 0
B 4019de 401080 1 0
B 401500 401070 22 0
B 401921 4014d6 9 0
B 4019b3 401080 3 0
B 40162d 401070 113 0
B 4014d1 401800 27 0
B 401a3f 401080 1 0
B 4018d2 401050 17 0
B 401664 4017c0 2 0
B 401680 401070 2 0
B 4017d0 401669 2 0
B 4018f7 40190d 9 0
B 4015bc 401592 6 0
B 401964 401090 5 0
B 4015f8 4015cd 1 0
B 4015ec 401070 6 0
F 40165b 401664 2
F 4017c0 4017d0 2
F 401669 401680 2
F 40190d 401921 9
F 4014d6 4014dd 9
F 401800 4018d2 17
F 4018d7 4018f7 9
F 40159f 4015b0 8
F 401515 401544 6
F 401070 401500 1
F 401070 401070 157
F 4014a0 4014d1 6
F 401616 40162d 112
F 4019e3 401a3f 1
F 4014e2 401500 19
F 401090 401090 5
F 401030 401030 673
F 401505 401510 668
F 401616 4017f0 2
F 401070 4015b0 1
F 4015da 4015ec 6
F 401b60 401b90 6
F 4019b8 4019de 1
F 401969 4019b3 3
F 401505 401509 2
F 401515 40152a 21
F 401592 40159a 4
F 401050 401050 17
F 4015cd 4015d5 1
F 401070 4014dd 1
F 401b99 401ba2 8
F 401b70 401b90 326
F 401b99 401b9d 324
F 401592 4015bc 1
F 401608 401611 109
F 401b70 401b9d 268
F 4015b5 4015bc 5
F 401b99 401b90 1
F 401b70 401ba2 5
F 401632 40164b 108
F 401080 401080 5
F 4014b0 4014d1 21
F 4017e0 4017f0 115
F 4015f1 4015f8 1
F 401685 40169e 2
F 401928 401964 5
F 401800 40188a 5
F 4014ec 401500 2
1,648 changes: 1,648 additions & 0 deletions bolt/test/X86/Inputs/blarge_new.yaml

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions bolt/test/X86/Inputs/blarge_new_bat.preagg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
B 40169e 40165b 7 0
B 401664 800012 7 0
B 401680 401070 7 0
B 800022 401669 7 0
B 401611 800000 121 0
B 40162d 401070 119 0
B 4015d5 800040 2 0
B 800080 4015da 6 0
B 40164b 401608 115 0
B 800080 40159f 24 0
B 4015ec 401070 6 0
B 8001d0 401090 1 0
B 4014d1 800082 25 0
B 401510 401030 616 0
B 8002ab 401080 1 0
B 80007b 80004c 483 1
B 800072 80004c 597 77
B 80010c 800194 1 0
B 401509 4014ec 1 0
B 800010 401616 119 0
B 80024a 401080 1 0
B 800154 401050 20 0
B 4014dd 401070 9 0
B 80021f 401080 1 0
B 800193 4014d6 8 0
B 40159a 800040 19 0
B 4015f8 4015cd 2 0
B 40152a 4014b0 24 0
B 401500 401070 15 0
B 4015bc 401592 21 0
B 401544 4014a0 1 0
B 80004a 800052 24 0
B 4015b0 401070 20 0
B 800050 80007d 29 29
F 401685 40169e 7
F 4014a0 4014d1 1
F 401090 401090 1
F 401050 401050 20
F 40159f 4015b0 20
F 80007d 800080 27
F 401515 401544 1
F 4014e2 401500 13
F 401592 40159a 19
F 401505 401509 1
F 4014b0 4014d1 24
F 800194 8001d0 1
F 8001d5 80021f 1
F 401616 40162d 114
F 80024f 8002ab 1
F 800159 800193 7
F 80004c 800050 26
F 800224 80024a 1
F 800082 80010c 1
F 401080 401080 3
F 401070 401070 168
F 80004c 800072 555
F 401616 800010 2
F 401070 40162d 4
F 800082 800154 20
F 401669 401680 7
F 40159f 800080 1
F 4014ec 401500 1
F 800012 800022 7
F 401030 401030 616
F 80004c 80007b 473
F 800052 800072 24
F 800040 80004a 21
F 4015b5 4015bc 18
F 4015cd 4015d5 2
F 401592 4015bc 1
F 4015da 4015ec 6
F 4015f1 4015f8 2
F 800000 800010 116
F 401608 401611 115
F 401632 40164b 114
F 401515 40152a 24
F 40165b 401664 7
F 401505 401510 612
F 4014d6 4014dd 8
40 changes: 40 additions & 0 deletions bolt/test/X86/bolt-address-translation-yaml.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Check new BAT format containing hashes for YAML profile.

RUN: yaml2obj %p/Inputs/blarge_new.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.out --pa -p %p/Inputs/blarge_new.preagg.txt \
RUN: --reorder-blocks=ext-tsp --split-functions --split-strategy=cdsplit \
RUN: --reorder-functions=cdsort --enable-bat --dyno-stats --skip-funcs=main \
RUN: 2>&1 | FileCheck --check-prefix WRITE-BAT-CHECK %s
RUN: perf2bolt %t.out --pa -p %p/Inputs/blarge_new_bat.preagg.txt -w %t.yaml -o %t.fdata \
RUN: 2>&1 | FileCheck --check-prefix READ-BAT-CHECK %s
RUN: FileCheck --input-file %t.yaml --check-prefix YAML-BAT-CHECK %s
# Check that YAML converted from fdata matches YAML created directly with BAT.
RUN: llvm-bolt %t.exe -data %t.fdata -w %t.yaml-fdata -o /dev/null
RUN: FileCheck --input-file %t.yaml-fdata --check-prefix YAML-BAT-CHECK %s

# Test resulting YAML profile with the original binary (no-stale mode)
RUN: llvm-bolt %t.exe -data %t.yaml -o %t.null -dyno-stats \
RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s

WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps
WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes
WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380

READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT
READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries
READ-BAT-CHECK: PERF2BOLT: read 79 aggregated LBR entries

YAML-BAT-CHECK: functions:
YAML-BAT-CHECK: - name: main
YAML-BAT-CHECK-NEXT: fid: 2
YAML-BAT-CHECK-NEXT: hash: 0x9895746D48B2C876
YAML-BAT-CHECK-NEXT: exec: 0
YAML-BAT-CHECK-NEXT: nblocks: 46
YAML-BAT-CHECK-NEXT: blocks:
YAML-BAT-CHECK-NEXT: - bid: 0
YAML-BAT-CHECK-NEXT: insns: 26
YAML-BAT-CHECK-NEXT: hash: 0xA900AE79CFD40000
YAML-BAT-CHECK-NEXT: succ: [ { bid: 3, cnt: 0 }, { bid: 1, cnt: 0 } ]

CHECK-BOLT-YAML: pre-processing profile using YAML profile reader
CHECK-BOLT-YAML-NEXT: 1 out of 16 functions in the binary (6.2%) have non-empty execution profile
11 changes: 6 additions & 5 deletions bolt/test/X86/bolt-address-translation.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@
#
# CHECK: BOLT: 3 out of 7 functions were overwritten.
# CHECK: BOLT-INFO: Wrote 6 BAT maps
# CHECK: BOLT-INFO: BAT section size (bytes): 336
# CHECK: BOLT-INFO: Wrote 3 function and 58 basic block hashes
# CHECK: BOLT-INFO: BAT section size (bytes): 920
#
# usqrt mappings (hot part). We match against any key (left side containing
# the bolted binary offsets) because BOLT may change where it puts instructions
# depending on whether it is relaxing a branch or not. But the original input
# binary offsets (right side) should be the same because these addresses are
# hardcoded in the blarge.yaml file.
#
# CHECK-BAT-DUMP: Function Address: 0x401170
# CHECK-BAT-DUMP: Function Address: 0x401170, hash: 0xace6cbc638b31983
# CHECK-BAT-DUMP-NEXT: BB mappings:
# CHECK-BAT-DUMP-NEXT: 0x0 -> 0x0
# CHECK-BAT-DUMP-NEXT: 0x0 -> 0x0 hash: 0x36007ba1d80c0000
# CHECK-BAT-DUMP-NEXT: 0x8 -> 0x8 (branch)
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x39
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x39 hash: 0x5c06705524800039
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x3d (branch)
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x10
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x10 hash: 0xd70d7a64320e0010
# CHECK-BAT-DUMP-NEXT: 0x{{.*}} -> 0x30 (branch)
#
# CHECK-BAT-DUMP: 3 cold mappings
Expand Down
694 changes: 694 additions & 0 deletions bolt/test/X86/dwarf5-debug-names-dw-at-specification.s

Large diffs are not rendered by default.

267 changes: 163 additions & 104 deletions bolt/test/X86/dwarf5-debug-names-generate-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x103
; BOLT-NEXT: Length: 0x155
; 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: Bucket count: 10
; BOLT-NEXT: Name count: 10
; BOLT-NEXT: Abbreviations table size: 0x29
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -31,124 +31,183 @@
; BOLT-NEXT: ]
; BOLT-NEXT: Abbreviations [
; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_base_type
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: Tag: DW_TAG_inlined_subroutine
; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: DW_IDX_parent: 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: Name 1 {
; BOLT-NEXT: Hash: 0x2124BB36
; BOLT-NEXT: String: {{.+}} "useFoo"
; 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: 0x00000037
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_inlined_subroutine
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000081
; BOLT-NEXT: DW_IDX_parent: Entry @ 0x14b
; BOLT-NEXT: }
; 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: Bucket 1 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 2 [
; BOLT-NEXT: Name 2 {
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Bucket 3 [
; BOLT-NEXT: EMPTY
; 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 3 {
; BOLT-NEXT: Hash: 0xB88B3D2
; BOLT-NEXT: String: {{.+}} "use"
; 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: 0x00000028
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Name 4 {
; BOLT-NEXT: Hash: 0x69A7307E
; BOLT-NEXT: String: {{.+}} "_Z6useFooPi"
; 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: 0x00000037
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_inlined_subroutine
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000081
; BOLT-NEXT: DW_IDX_parent: Entry @ 0x14b
; BOLT-NEXT: }
; 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: Name 5 {
; 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: 0x00000049
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Name 6 {
; BOLT-NEXT: Hash: 0xB5063CFE
; BOLT-NEXT: String: {{.+}} "_Z3fooi"
; 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: 0x0000005e
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Bucket 7 [
; BOLT-NEXT: Name 7 {
; BOLT-NEXT: Hash: 0x8C06E589
; BOLT-NEXT: String: {{.+}} "_Z3usePiS_"
; 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: 0x00000028
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Bucket 8 [
; BOLT-NEXT: Name 8 {
; 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: 0x00000033
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: Entry @ 0x{{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000007f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; 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: Bucket 9 [
; BOLT-NEXT: Name 9 {
; BOLT-NEXT: Hash: 0xB887389
; BOLT-NEXT: String: {{.+}} "foo"
; BOLT-NEXT: Entry @ 0x14b {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005e
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 7 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: }
; BOLT-NEXT: Name 10 {
; 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: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000092
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: }
43 changes: 33 additions & 10 deletions bolt/test/X86/dwarf5-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x1C2
; BOLT-NEXT: Length: 0x1D4
; 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: Abbreviations table size: 0x3D
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -31,27 +31,38 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV6: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: DW_IDX_parent: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
; BOLT-NEXT: Name 1 {
Expand All @@ -62,6 +73,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -74,24 +86,20 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x000000eb
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: Entry @ [[ENTRY:0x[0-9a-f]*]] {
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
Expand All @@ -102,6 +110,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -120,6 +129,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c9
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 6 {
Expand All @@ -130,6 +140,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000033
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 7 {
Expand All @@ -140,12 +151,14 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000009f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -158,6 +171,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 9 {
Expand All @@ -168,6 +182,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -180,6 +195,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000033
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -192,6 +208,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -207,12 +224,14 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 13 {
Expand All @@ -223,12 +242,14 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000078
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 14 {
Expand All @@ -239,6 +260,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000073
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -250,10 +272,11 @@
; BOLT-NEXT: Hash: 0x59796A
; BOLT-NEXT: String: {{.+}} "t1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Abbrev: [[ABBREV6]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000062
; BOLT-NEXT: DW_IDX_parent: Entry @ [[ENTRY]]
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand Down
19 changes: 17 additions & 2 deletions bolt/test/X86/dwarf5-df-debug-names-generate-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x148
; BOLT-NEXT: Length: 0x14E
; 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: Abbreviations table size: 0x1F
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -37,16 +37,19 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
Expand All @@ -58,6 +61,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
Expand All @@ -68,6 +72,7 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000008c
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -80,6 +85,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
Expand All @@ -90,6 +96,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -102,6 +109,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -114,6 +122,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -129,6 +138,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -141,12 +151,14 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000025
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -159,6 +171,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000034
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 10 {
Expand All @@ -169,6 +182,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000057
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -187,6 +201,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
278 changes: 145 additions & 133 deletions bolt/test/X86/dwarf5-df-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,136 +14,148 @@

; 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: }
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xFC
; 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: 0x29
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 6 [
; BOLT-NEXT: EMPTY
; BOLT-NEXT: ]
; BOLT-NEXT: }
3 changes: 3 additions & 0 deletions bolt/test/X86/dwarf5-df-main-debug-names-ftu-ltu-mix.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x02
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001e
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT: Name 6 {
Expand All @@ -42,6 +43,7 @@
; BOLT-NEXT: DW_IDX_type_unit: 0x02
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT: Name 7 {
Expand All @@ -52,5 +54,6 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000023
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
12 changes: 10 additions & 2 deletions bolt/test/X86/dwarf5-df-one-cu-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xA9
; BOLT-NEXT: Length: 0xAF
; 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: Abbreviations table size: 0x19
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -31,14 +31,17 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
Expand All @@ -52,6 +55,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000068
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
Expand All @@ -61,6 +65,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -75,6 +80,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000056
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -86,6 +92,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000078
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 5 {
Expand All @@ -95,6 +102,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000064
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand Down
24 changes: 22 additions & 2 deletions bolt/test/X86/dwarf5-df-types-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x174
; BOLT-NEXT: Length: 0x17E
; 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: Abbreviations table size: 0x37
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -52,27 +52,32 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
Expand All @@ -88,6 +93,7 @@
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
Expand All @@ -98,6 +104,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 3 {
Expand All @@ -108,6 +115,7 @@
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -120,19 +128,22 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000025
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -145,6 +156,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000029
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 6 {
Expand All @@ -156,13 +168,15 @@
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 7 {
Expand All @@ -174,6 +188,7 @@
; BOLT-NEXT: DW_IDX_type_unit: 0x02
; BOLT-NEXT: DW_IDX_compile_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -195,6 +210,7 @@
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -208,26 +224,30 @@
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000036
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand Down
15 changes: 13 additions & 2 deletions bolt/test/X86/dwarf5-df-types-one-cu-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
; BOLT: [[OFFSET:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0xD1
; BOLT-NEXT: Length: 0xD9
; 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: Abbreviations table size: 0x25
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -40,19 +40,23 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
Expand All @@ -67,6 +71,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
Expand All @@ -76,6 +81,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001a
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -90,6 +96,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000056
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -102,6 +109,7 @@
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x01
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 5 {
Expand All @@ -112,17 +120,20 @@
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000036
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; 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: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand Down
7 changes: 3 additions & 4 deletions bolt/test/X86/dwarf5-label-low-pc.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s

# This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addrx] that is part of DW_TAG_label.

Expand Down Expand Up @@ -35,16 +36,14 @@
# POSTCHECK-NEXT: DW_AT_name
# POSTCHECK-NEXT: DW_AT_decl_file
# POSTCHECK-NEXT: DW_AT_decl_line
# POSTCHECK-NEXT:
# POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
# POSTCHECK-SAME: [0x[[#ADDR]]
# POSTCHECK-SAME: 0x[[#ADDR]]
# POSTCHECK: DW_TAG_label
# POSTCHECK-NEXT: DW_AT_name
# POSTCHECK-NEXT: DW_AT_decl_file
# POSTCHECK-NEXT: DW_AT_decl_line
# POSTCHECK-NEXT:
# POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003)
# POSTCHECK-SAME: [0x[[#ADDR2]]
# POSTCHECK-SAME: 0x[[#ADDR2]]

# clang++ main.cpp -g -S
# int main() {
Expand Down
44 changes: 30 additions & 14 deletions bolt/test/X86/dwarf5-one-cu-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit
; BOLT: Name Index @ 0x0 {
; BOLT-NEXT: Header {
; BOLT-NEXT: Length: 0x13E
; BOLT-NEXT: Length: 0x14F
; 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: Abbreviations table size: 0x31
; BOLT-NEXT: Augmentation: 'BOLT'
; BOLT-NEXT: }
; BOLT-NEXT: Compilation Unit offsets [
Expand All @@ -27,22 +27,32 @@
; 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: DW_IDX_parent: DW_FORM_flag_present
; 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: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: DW_IDX_parent: DW_FORM_ref4
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {
; BOLT-NEXT: Abbreviation [[ABBREV5:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: Abbreviation [[ABBREV5:0x[0-9a-f]*]] {
; BOLT-NEXT: Abbreviation [[ABBREV6:0x[0-9a-f]*]] {
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4
; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present
; BOLT-NEXT: }
; BOLT-NEXT: ]
; BOLT-NEXT: Bucket 0 [
Expand All @@ -53,6 +63,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000104
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 2 {
Expand All @@ -62,6 +73,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c5
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -73,6 +85,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000c9
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: Name 4 {
Expand All @@ -82,6 +95,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000003f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -93,6 +107,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x000000eb
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -107,18 +122,20 @@
; BOLT-NEXT: Hash: 0x59796A
; BOLT-NEXT: String: {{.+}} "t1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Abbrev: [[ABBREV3]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x00000062
; BOLT-NEXT: DW_IDX_parent: Entry @ 0x14d
; 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: Abbrev: [[ABBREV4]]
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_die_offset: 0x00000024
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -130,6 +147,7 @@
; BOLT-NEXT: Abbrev: [[ABBREV2]]
; BOLT-NEXT: Tag: DW_TAG_base_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000005d
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand All @@ -141,31 +159,29 @@
; BOLT-NEXT: Abbrev: [[ABBREV1]]
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_die_offset: 0x0000002f
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: Abbrev: [[ABBREV5]]
; BOLT-NEXT: Tag: DW_TAG_subprogram
; BOLT-NEXT: DW_IDX_die_offset: 0x00000073
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; 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: Entry @ 0x14d {
; BOLT-NEXT: Abbrev: [[ABBREV6]]
; BOLT-NEXT: Tag: DW_TAG_namespace
; BOLT-NEXT: DW_IDX_die_offset: 0x00000061
; BOLT-NEXT: DW_IDX_parent: <parent not indexed>
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT-NEXT: ]
Expand Down
Loading