Skip to content

[BOLT][DWARF] Add support for transitive DW_AT_name/DW_AT_linkage_name resolution for DW_AT_name/DW_AT_linkage_name. #119493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DIEBuilder {

/// Clone an attribute in reference format.
void cloneDieOffsetReferenceAttribute(
DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE,
DIE &Die, DWARFUnit &U, const DWARFDie &InputDIE,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec, uint64_t Ref);

/// Clone an attribute in block format.
Expand Down
29 changes: 26 additions & 3 deletions bolt/include/bolt/Core/DebugNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class DWARF5AcceleratorTable {
return std::move(FullTableBuffer);
}
/// Adds a DIE that is referenced across CUs.
void addCrossCUDie(const DIE *Die) {
CrossCUDies.insert({Die->getOffset(), Die});
void addCrossCUDie(DWARFUnit *Unit, const DIE *Die) {
CrossCUDies.insert({Die->getOffset(), {Unit, Die}});
}
/// Returns true if the DIE can generate an entry for a cross cu reference.
/// This only checks TAGs of a DIE because when this is invoked DIE might not
Expand Down Expand Up @@ -145,7 +145,7 @@ class DWARF5AcceleratorTable {
llvm::DenseMap<uint64_t, uint32_t> CUOffsetsToPatch;
// Contains a map of Entry ID to Entry relative offset.
llvm::DenseMap<uint64_t, uint32_t> EntryRelativeOffsets;
llvm::DenseMap<uint64_t, const DIE *> CrossCUDies;
llvm::DenseMap<uint64_t, std::pair<DWARFUnit *, const DIE *>> CrossCUDies;
/// Adds Unit to either CUList, LocalTUList or ForeignTUList.
/// Input Unit being processed, and DWO ID if Unit is being processed comes
/// from a DWO section.
Expand Down Expand Up @@ -191,6 +191,29 @@ class DWARF5AcceleratorTable {
void emitData();
/// Emit augmentation string.
void emitAugmentationString() const;
/// Creates a new entry for a given DIE.
std::optional<BOLTDWARF5AccelTableData *>
addEntry(DWARFUnit &DU, const DIE &CurrDie,
const std::optional<uint64_t> &DWOID,
const std::optional<BOLTDWARF5AccelTableData *> &Parent,
const std::optional<std::string> &Name,
const uint32_t NumberParentsInChain);
/// Returns UnitID for a given DWARFUnit.
uint32_t getUnitID(const DWARFUnit &Unit,
const std::optional<uint64_t> &DWOID, bool &IsTU);
std::optional<std::string> getName(DWARFUnit &DU,
const std::optional<uint64_t> &DWOID,
const std::string &NameToUse,
DIEValue ValName);
/// Processes a DIE with references to other DIEs for DW_AT_name and
/// DW_AT_linkage_name resolution.
/// If DW_AT_name exists method creates a new entry for this DIE and returns
/// it.
std::optional<BOLTDWARF5AccelTableData *> processReferencedDie(
DWARFUnit &Unit, const DIE &Die, const std::optional<uint64_t> &DWOID,
const std::optional<BOLTDWARF5AccelTableData *> &Parent,
const std::string &NameToUse, const uint32_t NumberParentsInChain,
const dwarf::Attribute &Attr);
};
} // namespace bolt
} // namespace llvm
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ DWARFDie DIEBuilder::resolveDIEReference(
}

void DIEBuilder::cloneDieOffsetReferenceAttribute(
DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE,
DIE &Die, DWARFUnit &U, const DWARFDie &InputDIE,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec, uint64_t Ref) {
DIE *NewRefDie = nullptr;
DWARFUnit *RefUnit = nullptr;
Expand Down Expand Up @@ -654,7 +654,7 @@ void DIEBuilder::cloneDieOffsetReferenceAttribute(
// Adding referenced DIE to DebugNames to be used when entries are created
// that contain cross cu references.
if (DebugNamesTable.canGenerateEntryWithCrossCUReference(U, Die, AttrSpec))
DebugNamesTable.addCrossCUDie(DieInfo.Die);
DebugNamesTable.addCrossCUDie(&U, DieInfo.Die);
// no matter forward reference or backward reference, we are supposed
// to calculate them in `finish` due to the possible modification of
// the DIE.
Expand Down
Loading
Loading