@@ -438,7 +438,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
438438 }
439439
440440 if (opts::UpdateDebugSections && !Function.getDWARFUnits ().empty ())
441- for (DWARFUnit * Unit : Function.getDWARFUnits ())
441+ for (const auto &[_, Unit] : Function.getDWARFUnits ())
442442 emitLineInfoEnd (Function, EndSymbol, Unit);
443443
444444 // Exception handling info for the function.
@@ -687,10 +687,10 @@ SMLoc BinaryEmitter::emitLineInfo(const BinaryFunction &BF, SMLoc NewLoc,
687687 const ClusteredRows *Cluster = ClusteredRows::fromSMLoc (NewLoc);
688688
689689 auto addToLineTable = [&](DebugLineTableRowRef RowReference,
690- const DWARFUnit * TargetCU, unsigned Flags,
691- MCSymbol * InstrLabel,
690+ const DWARFUnit & TargetCU, unsigned Flags,
691+ MCSymbol & InstrLabel,
692692 const DWARFDebugLine::Row &CurrentRow) {
693- const uint64_t TargetUnitIndex = TargetCU-> getOffset ();
693+ const uint64_t TargetUnitIndex = TargetCU. getOffset ();
694694 unsigned TargetFilenum = CurrentRow.File ;
695695 const uint32_t CurrentUnitIndex = RowReference.DwCompileUnitIndex ;
696696 // If the CU id from the current instruction location does not
@@ -711,7 +711,7 @@ SMLoc BinaryEmitter::emitLineInfo(const BinaryFunction &BF, SMLoc NewLoc,
711711 .getMCLineSections ()
712712 .getMCLineEntries ();
713713 const auto *It = MapLineEntries.find (Streamer.getCurrentSectionOnly ());
714- auto NewLineEntry = MCDwarfLineEntry (InstrLabel, DwarfLoc);
714+ auto NewLineEntry = MCDwarfLineEntry (& InstrLabel, DwarfLoc);
715715
716716 // Check if line table exists and has entries before doing comparison
717717 if (It != MapLineEntries.end () && !It->second .empty ()) {
@@ -750,21 +750,17 @@ SMLoc BinaryEmitter::emitLineInfo(const BinaryFunction &BF, SMLoc NewLoc,
750750 if (FirstInstr)
751751 Flags |= DWARF2_FLAG_IS_STMT;
752752 const auto &FunctionDwarfUnits = BF.getDWARFUnits ();
753- const auto *It = std::find_if (
754- FunctionDwarfUnits.begin (), FunctionDwarfUnits.end (),
755- [RowReference](const DWARFUnit *Unit) {
756- return Unit->getOffset () == RowReference.DwCompileUnitIndex ;
757- });
753+ auto It = FunctionDwarfUnits.find (RowReference.DwCompileUnitIndex );
758754 if (It != FunctionDwarfUnits.end ()) {
759- addToLineTable (RowReference, *It, Flags, InstrLabel, CurrentRow);
755+ addToLineTable (RowReference, *It-> second , Flags, * InstrLabel, CurrentRow);
760756 continue ;
761757 }
762758 // This rows is from CU that did not contain the original function.
763759 // This might happen if BOLT moved/inlined that instruction from other CUs.
764760 // In this case, we need to insert it to all CUs that the function
765761 // originally beloned to.
766- for (const DWARFUnit * Unit : BF.getDWARFUnits ()) {
767- addToLineTable (RowReference, Unit, Flags, InstrLabel, CurrentRow);
762+ for (const auto &[_, Unit] : BF.getDWARFUnits ()) {
763+ addToLineTable (RowReference, * Unit, Flags, * InstrLabel, CurrentRow);
768764 }
769765 }
770766
@@ -1148,7 +1144,7 @@ void BinaryEmitter::emitDebugLineInfoForOriginalFunctions() {
11481144 continue ;
11491145
11501146 // Loop through all CUs in the function
1151- for (DWARFUnit * Unit : Function.getDWARFUnits ()) {
1147+ for (const auto &[_, Unit] : Function.getDWARFUnits ()) {
11521148 const DWARFDebugLine::LineTable *LineTable =
11531149 Function.getDWARFLineTableForUnit (Unit);
11541150 if (!LineTable)
0 commit comments