@@ -126,10 +126,10 @@ void LiveElementPrinter::addInlinedFunction(DWARFDie FuncDie,
126126 InlinedFuncName, U, FuncDie, InlinedFuncDie, Range));
127127 // Map the element's low address (LowPC) to its pointer for fast range start
128128 // lookup.
129- LiveElementsByAddress. emplace (FuncLowPC, LiveElements.back ().get ());
129+ LiveElementsByAddress[FuncLowPC]. push_back ( LiveElements.back ().get ());
130130 // Map the element's high address (HighPC) to its pointer for fast range end
131131 // lookup.
132- LiveElementsByEndAddress. emplace (FuncHighPC, LiveElements.back ().get ());
132+ LiveElementsByEndAddress[FuncHighPC]. push_back ( LiveElements.back ().get ());
133133 // Map the pointer to its DWARF discovery index (ElementIdx) for deterministic
134134 // ordering.
135135 ElementPtrToIndex[LiveElements.back ().get ()] = LiveElements.size () - 1 ;
@@ -175,10 +175,10 @@ void LiveElementPrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) {
175175 ElementPtrToIndex.emplace (CurrentVar, LiveElements.size () - 1 );
176176 if (CurrentVar->getLocExpr ().Range ) {
177177 // Add the variable to address-based maps.
178- LiveElementsByAddress. emplace ( CurrentVar->getLocExpr ().Range ->LowPC ,
179- CurrentVar);
180- LiveElementsByEndAddress. emplace ( CurrentVar->getLocExpr ().Range ->HighPC ,
181- CurrentVar);
178+ LiveElementsByAddress[ CurrentVar->getLocExpr ().Range ->LowPC ]. push_back (
179+ CurrentVar);
180+ LiveElementsByEndAddress[ CurrentVar->getLocExpr ().Range ->HighPC ]
181+ . push_back ( CurrentVar);
182182 }
183183 }
184184 }
@@ -345,12 +345,13 @@ void LiveElementPrinter::update(object::SectionedAddress ThisAddr,
345345 if (IncludeDefinedVars) {
346346 // Collect all elements starting at ThisAddr and NextAddr.
347347 std::vector<std::pair<unsigned , LiveElement *>> NewLiveElements;
348- // Process elements from a map range and add them to NewLiveElements.
349- auto CollectNewElements = [&](const auto &Range) {
350- for (auto it = Range.first ; it != Range.second ; ++it) {
351- LiveElement *LE = it->second ;
348+ auto CollectNewElements = [&](const auto &It) {
349+ if (It == LiveElementsByAddress.end ())
350+ return ;
352351
353- // Get the ElementIdx for sorting and column management.
352+ const std::vector<LiveElement *> &ElementList = It->second ;
353+ // Get the ElementIdx for sorting and column management.
354+ for (LiveElement *LE : ElementList) {
354355 auto IndexIt = ElementPtrToIndex.find (LE);
355356 if (IndexIt == ElementPtrToIndex.end ()) {
356357 LLVM_DEBUG (
@@ -374,10 +375,10 @@ void LiveElementPrinter::update(object::SectionedAddress ThisAddr,
374375 };
375376
376377 // Collect elements starting at ThisAddr.
377- CollectNewElements (LiveElementsByAddress.equal_range (ThisAddr.Address ));
378- // Collect elements starting at NextAddr (the address immediately following
379- // the instruction).
380- CollectNewElements (LiveElementsByAddress.equal_range (NextAddr.Address ));
378+ CollectNewElements (LiveElementsByAddress.find (ThisAddr.Address ));
379+ // Collect elements starting at NextAddr (the address immediately
380+ // following the instruction).
381+ CollectNewElements (LiveElementsByAddress.find (NextAddr.Address ));
381382 // Sort elements by DWARF discovery order (ElementIdx) for deterministic
382383 // column assignment.
383384 llvm::stable_sort (NewLiveElements, [](const auto &A, const auto &B) {
@@ -573,14 +574,15 @@ void LiveElementPrinter::printStartLine(formatted_raw_ostream &OS,
573574 return ;
574575
575576 // Use the map to find all elements that start at the given address.
576- auto Range = LiveElementsByAddress.equal_range (Addr.Address );
577577 std::vector<unsigned > ElementIndices;
578- for (auto it = Range.first ; it != Range.second ; ++it) {
579- LiveElement *LE = it->second ;
580- // Look up the ElementIdx from the pointer.
581- auto IndexIt = ElementPtrToIndex.find (LE);
582- if (IndexIt != ElementPtrToIndex.end ())
583- ElementIndices.push_back (IndexIt->second );
578+ auto It = LiveElementsByAddress.find (Addr.Address );
579+ if (It != LiveElementsByAddress.end ()) {
580+ for (LiveElement *LE : It->second ) {
581+ // Look up the ElementIdx from the pointer.
582+ auto IndexIt = ElementPtrToIndex.find (LE);
583+ if (IndexIt != ElementPtrToIndex.end ())
584+ ElementIndices.push_back (IndexIt->second );
585+ }
584586 }
585587
586588 // Sort the indices to ensure deterministic output order (by DWARF discovery
@@ -601,14 +603,15 @@ void LiveElementPrinter::printEndLine(formatted_raw_ostream &OS,
601603 return ;
602604
603605 // Use the map to find elements that end at the given address.
604- auto Range = LiveElementsByEndAddress.equal_range (Addr.Address );
605606 std::vector<unsigned > ElementIndices;
606- for (auto it = Range.first ; it != Range.second ; ++it) {
607- LiveElement *LE = it->second ;
608- // Look up the ElementIdx from the pointer.
609- auto IndexIt = ElementPtrToIndex.find (LE);
610- if (IndexIt != ElementPtrToIndex.end ())
611- ElementIndices.push_back (IndexIt->second );
607+ auto It = LiveElementsByEndAddress.find (Addr.Address );
608+ if (It != LiveElementsByEndAddress.end ()) {
609+ for (LiveElement *LE : It->second ) {
610+ // Look up the ElementIdx from the pointer.
611+ auto IndexIt = ElementPtrToIndex.find (LE);
612+ if (IndexIt != ElementPtrToIndex.end ())
613+ ElementIndices.push_back (IndexIt->second );
614+ }
612615 }
613616
614617 // Sort the indices to ensure deterministic output order (by DWARF discovery
0 commit comments