[llvm] [llvm-objdump] Optimize live element tracking (PR #158763)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 01:16:25 PST 2025
================
@@ -126,8 +121,35 @@ void LiveElementPrinter::addInlinedFunction(DWARFDie FuncDie,
DWARFUnit *U = InlinedFuncDie.getDwarfUnit();
const char *InlinedFuncName = InlinedFuncDie.getName(DINameKind::LinkageName);
DWARFAddressRange Range{FuncLowPC, FuncHighPC, SectionIndex};
+ // Add the new element to the main vector.
LiveElements.emplace_back(std::make_unique<InlinedFunction>(
InlinedFuncName, U, FuncDie, InlinedFuncDie, Range));
+ // Map the element's low address (LowPC) to its pointer for fast range start
+ // lookup.
+ LiveElementsByAddress[FuncLowPC].push_back(LiveElements.back().get());
+ // Map the element's high address (HighPC) to its pointer for fast range end
+ // lookup.
+ LiveElementsByEndAddress[FuncHighPC].push_back(LiveElements.back().get());
+ // Map the pointer to its DWARF discovery index for deterministic
+ // ordering.
+ ElementPtrToIndex[LiveElements.back().get()] = LiveElements.size() - 1;
+}
+
+/// Registers the most recently added LiveVariable into all data structures.
+void LiveElementPrinter::registerNewVariable() {
+ assert(
+ !LiveElements.empty() &&
+ "registerNewVariable called before element was added to LiveElements.");
+ LiveVariable *CurrentVar =
----------------
jh7370 wrote:
Perhaps worth an assertion that `CurrentVar` isn't already in `ElementPtrToIndex`?
https://github.com/llvm/llvm-project/pull/158763
More information about the llvm-commits
mailing list