[llvm] [llvm-objdump] Optimize live element tracking (PR #158763)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 11:11:58 PST 2025
================
@@ -440,20 +568,60 @@ void LiveElementPrinter::printAfterInst(formatted_raw_ostream &OS) {
void LiveElementPrinter::printStartLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
- // Print a line to idenfity the start of an inlined function if line format
- // is specified.
- if (DbgInlinedFunctions == DFLimitsOnly)
- for (const std::unique_ptr<LiveElement> &LE : LiveElements)
- LE->printElementLine(OS, Addr, false);
+ // Only print the start line for inlined functions if DFLimitsOnly is
+ // enabled.
+ if (DbgInlinedFunctions != DFLimitsOnly)
+ return;
+
+ // Use the map to find all elements that start at the given address.
+ std::vector<unsigned> ElementIndices;
+ auto It = LiveElementsByAddress.find(Addr.Address);
+ if (It != LiveElementsByAddress.end()) {
+ for (LiveElement *LE : It->second) {
+ // Look up the ElementIdx from the pointer.
+ auto IndexIt = ElementPtrToIndex.find(LE);
+ if (IndexIt != ElementPtrToIndex.end())
+ ElementIndices.push_back(IndexIt->second);
+ }
+ }
+
+ // Sort the indices to ensure deterministic output order (by DWARF discovery
+ // order).
+ llvm::stable_sort(ElementIndices);
+
+ for (unsigned ElementIdx : ElementIndices) {
+ LiveElement *LE = LiveElements[ElementIdx].get();
+ LE->printElementLine(OS, Addr, false);
+ }
}
void LiveElementPrinter::printEndLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
- // Print a line to idenfity the end of an inlined function if line format is
- // specified.
- if (DbgInlinedFunctions == DFLimitsOnly)
- for (const std::unique_ptr<LiveElement> &LE : LiveElements)
- LE->printElementLine(OS, Addr, true);
+ // Only print the end line for inlined functions if DFLimitsOnly is
----------------
gulfemsavrun wrote:
Done.
https://github.com/llvm/llvm-project/pull/158763
More information about the llvm-commits
mailing list