[llvm] d9526e8 - [ConstraintElimination] Use stable_sort to sort worklist.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 10:22:44 PDT 2022


Author: Florian Hahn
Date: 2022-06-23T19:22:15+02:00
New Revision: d9526e8a52ca9d5371f32a9cdad8981d31613408

URL: https://github.com/llvm/llvm-project/commit/d9526e8a52ca9d5371f32a9cdad8981d31613408
DIFF: https://github.com/llvm/llvm-project/commit/d9526e8a52ca9d5371f32a9cdad8981d31613408.diff

LOG: [ConstraintElimination] Use stable_sort to sort worklist.

If there are multiple constraints in the same block, at the moment the
order they are processed may be different depending on the sort
implementation.

Use stable_sort to ensure consistent ordering.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 6508744e28c0..17433cfd0fd8 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -679,7 +679,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT) {
   // come before blocks and conditions dominated by them. If a block and a
   // condition have the same numbers, the condition comes before the block, as
   // it holds on entry to the block.
-  sort(S.WorkList, [](const ConstraintOrBlock &A, const ConstraintOrBlock &B) {
+  stable_sort(S.WorkList, [](const ConstraintOrBlock &A, const ConstraintOrBlock &B) {
     return std::tie(A.NumIn, A.IsBlock) < std::tie(B.NumIn, B.IsBlock);
   });
 


        


More information about the llvm-commits mailing list