Skip to content

Commit 96839a4

Browse files
authored
[llvm-gsymutil] Ensure stable ordering of merged functions (#120796)
Previously, the test `llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml` [was disabled](https://github.com/llvm/llvm-project/pull/119957/files) due to failing on Linux. The issue is that the merged functions appear in a different order in the final produced `gSYM`. To ensure deterministic ordering of merged functions, we change the sorting of functions to use the `stable_sort` algorithm. Before merged functions, this was not an issue as the address is used as a comparator in the sorting algorithm so there was no chance of two functions testing as identical according to the comparator. Confirmed that test now passes locally with `-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON`.
1 parent adf0c81 commit 96839a4

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ void GsymCreator::prepareMergedFunctions(OutputAggregator &Out) {
200200
if (Funcs.size() < 2)
201201
return;
202202

203-
// Sort the function infos by address range first
204-
llvm::sort(Funcs);
203+
// Sort the function infos by address range first, preserving input order
204+
llvm::stable_sort(Funcs);
205205
std::vector<FunctionInfo> TopLevelFuncs;
206206

207207
// Add the first function info to the top level functions

llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# FIXME: Currently disabled as it fails on some Linux hosts
2-
# UNSUPPORTED: true
3-
4-
51
## Test that reconstructs a dSYM file from YAML and generates a gsym from it. The gsym has callsite info and merged functions.
62

73
# RUN: split-file %s %t

0 commit comments

Comments
 (0)