[llvm] [SROA] Use stable sort for slices to avoid non-determinism (PR #91609)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 23:20:30 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());
----------------
nikic wrote:

Why did this switch to sorting the whole Slices? Isn't inplace_merge stable?

https://github.com/llvm/llvm-project/pull/91609


More information about the llvm-commits mailing list