[llvm] [SROA] Use stable sort for slices to avoid non-determinism (PR #91609)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 11:20:48 PDT 2024
================
@@ -627,11 +627,8 @@ class AllocaSlices {
/// everything so that the usual ordering properties of the alloca's slices
/// hold.
void insert(ArrayRef<Slice> NewSlices) {
- int OldSize = Slices.size();
Slices.append(NewSlices.begin(), NewSlices.end());
- auto SliceI = Slices.begin() + OldSize;
- llvm::sort(SliceI, Slices.end());
- std::inplace_merge(Slices.begin(), SliceI, Slices.end());
----------------
henke9600 wrote:
At first I tried to replace `llvm::sort` with `llvm::stable_sort` but that resulted in a bunch of template errors. Since this function seemed to be extremely cold, I went with this simplification instead. During a full build of clang+lld cross-compiling themselves, this function was only called 3 times in total.
Thinking about this again, I realise that I should probably have replaced `llvm::sort` with `std::stable_sort` (not `llvm::stable_sort`). Is that right?
https://github.com/llvm/llvm-project/pull/91609
More information about the llvm-commits
mailing list