[llvm] [llvm-objdump] Optimize live element tracking (PR #158763)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 10:53:05 PDT 2025
================
@@ -97,11 +98,22 @@ class LiveElementPrinter {
std::numeric_limits<unsigned>::max();
};
- // All live elements we know about in the object/image file.
+ // Vector that owns all LiveElement objects for memory management.
std::vector<std::unique_ptr<LiveElement>> LiveElements;
-
- // The columns we are currently drawing.
- IndexedMap<Column> ActiveCols;
+ // Map for fast lookup of live elements by their starting address (LowPC).
+ std::unordered_multimap<uint64_t, LiveElement *> LiveElementsByAddress;
+ // Map for fast lookup of live elements by their ending address (HighPC).
+ std::unordered_multimap<uint64_t, LiveElement *> LiveElementsByEndAddress;
+ // Map from a LiveElement pointer to its index in the LiveElements vector.
+ std::unordered_map<LiveElement *, unsigned> ElementPtrToIndex;
+ // Map from a live element index to column index for efficient lookup.
+ std::unordered_map<unsigned, unsigned> ElementToColumn;
+ // Vector of columns currently used for printing live ranges.
+ std::vector<Column> ActiveCols;
+ // Set of available column indices kept sorted for efficient reuse.
+ std::set<unsigned> FreeCols;
----------------
jh7370 wrote:
Would a `SmallSet` be more appropriate? I imagine the norm would be for only a small number of columns to be needed at any one time.
https://github.com/llvm/llvm-project/pull/158763
More information about the llvm-commits
mailing list