[llvm] [llvm-objdump] Optimize live element tracking (PR #158763)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 00:29:56 PST 2025
================
@@ -142,13 +145,18 @@ void LiveElementPrinter::registerNewVariable() {
"registerNewVariable called before element was added to LiveElements.");
LiveVariable *CurrentVar =
static_cast<LiveVariable *>(LiveElements.back().get());
+ assert(ElementPtrToIndex.count(CurrentVar) == 0 &&
+ "Element already registered!");
+
// Map from a LiveElement pointer to its index in the LiveElements.
ElementPtrToIndex[CurrentVar] = LiveElements.size() - 1;
- if (const auto &Range = CurrentVar->getLocExpr().Range) {
+ if (const std::optional<DWARFAddressRange> &RangeOpt =
+ CurrentVar->getLocExpr().Range) {
+ const DWARFAddressRange &Range = *RangeOpt;
----------------
jh7370 wrote:
FWIW, I don't think in this case the local variable adds any value, since you can just use `->` instead of `.` to access `LowPC` etc without it. I also don't feel strongly about it if you prefer to keep it.
https://github.com/llvm/llvm-project/pull/158763
More information about the llvm-commits
mailing list