Skip to content

Commit 343bbda

Browse files
committed
Use a stable sort to handle overlapping/duplicate line sequences
This can occur due to linker ICF and stable sort will ensure the results are stable. No explicit/new test coverage, because nondeterminism is non-testable. It should already be covered by the DWARFDebugLineTest that was failing some internal testing on an ARM machine which might've been what changed the sort order. But `llvm::sort` also deliberately randomizes the contents (under EXPENSIVE_CHECKS) so I'd have expected failures to show up in any EXPENSIVE_CHECKS Build...
1 parent 51e7dc8 commit 343bbda

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,13 +1274,14 @@ Error DWARFDebugLine::LineTable::parse(
12741274

12751275
// Sort all sequences so that address lookup will work faster.
12761276
if (!Sequences.empty()) {
1277-
llvm::sort(Sequences, Sequence::orderByHighPC);
1277+
llvm::stable_sort(Sequences, Sequence::orderByHighPC);
12781278
// Note: actually, instruction address ranges of sequences should not
12791279
// overlap (in shared objects and executables). If they do, the address
12801280
// lookup would still work, though, but result would be ambiguous.
12811281
// We don't report warning in this case. For example,
12821282
// sometimes .so compiled from multiple object files contains a few
12831283
// rudimentary sequences for address ranges [0x0, 0xsomething).
1284+
// Address ranges may also overlap when using ICF.
12841285
}
12851286

12861287
// Terminate the table with a final blank line to clearly delineate it from

0 commit comments

Comments
 (0)