Skip to content

Commit a055e38

Browse files
committed
DebugInfo: Reduce long-distance dependence on what will/won't emit a debug_addr section
This is a no-op/NFC at the moment & generally makes the code /somewhat/ cleaner/less reliant on assumptions about what will produce a debug_addr section. It's still a bit "spooky action at a distance" - the add ranges code pre-emptively inserts addresses into the address pool it knows will eventually be used by the range emission code (or low/high pc). The 'ideal' would be either to actually compute the addresses needed for range (& loc) emission earlier - which would mean decanonicalizing the range/loc representation earlier to account for whether it was going to use addrx encodings or not (which would be unfortunate, but could be refactored to be relatively unobtrusive). Alternatively, emitting the range/loc sections earlier would cause them to request the needed addresses sooner - but then you endup having to split finalizeModuleInfo because some things need to be handled there before the ranges/locs are emitted, I think...
1 parent 39beeef commit a055e38

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,7 @@ void DwarfDebug::finalizeModuleInfo() {
12711271

12721272
// We don't keep track of which addresses are used in which CU so this
12731273
// is a bit pessimistic under LTO.
1274-
if ((!AddrPool.isEmpty() || TheCU.hasRangeLists()) &&
1275-
(getDwarfVersion() >= 5 || HasSplitUnit))
1274+
if ((HasSplitUnit || getDwarfVersion() >= 5) && !AddrPool.isEmpty())
12761275
U.addAddrTableBase();
12771276

12781277
if (getDwarfVersion() >= 5) {
@@ -3271,5 +3270,7 @@ const MCSymbol *DwarfDebug::getSectionLabel(const MCSection *S) {
32713270
return SectionLabels.find(S)->second;
32723271
}
32733272
void DwarfDebug::insertSectionLabel(const MCSymbol *S) {
3274-
SectionLabels.insert(std::make_pair(&S->getSection(), S));
3273+
if (SectionLabels.insert(std::make_pair(&S->getSection(), S)).second)
3274+
if (useSplitDwarf() || getDwarfVersion() >= 5)
3275+
AddrPool.getIndex(S);
32753276
}

0 commit comments

Comments
 (0)