Skip to content

Commit b2297d0

Browse files
committed
Minor fixes
1 parent 15ef19f commit b2297d0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ class BinaryFunction {
24202420
}
24212421

24222422
/// Return DWARF compile units for this function.
2423-
const SmallVector<DWARFUnit *, 1> getDWARFUnits() const {
2423+
const SmallVector<DWARFUnit *, 1>& getDWARFUnits() const {
24242424
return DwarfUnitVec;
24252425
}
24262426

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,9 +1718,15 @@ void BinaryContext::preprocessDebugInfo() {
17181718
// Clear debug info for functions from units that we are not going to process.
17191719
for (auto &KV : BinaryFunctions) {
17201720
BinaryFunction &BF = KV.second;
1721+
// Collect units to remove to avoid iterator invalidation
1722+
SmallVector<DWARFUnit *, 1> UnitsToRemove;
17211723
for (auto *Unit : BF.getDWARFUnits()) {
17221724
if (!ProcessedCUs.count(Unit))
1723-
BF.removeDWARFUnit(Unit);
1725+
UnitsToRemove.push_back(Unit);
1726+
}
1727+
// Remove the collected units
1728+
for (auto *Unit : UnitsToRemove) {
1729+
BF.removeDWARFUnit(Unit);
17241730
}
17251731
}
17261732

0 commit comments

Comments
 (0)