[llvm] r316949 - [GVNHoist] Fix non-deterministic sort order of PHIs for identical instructions

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 12:42:41 PDT 2017


Author: mgrang
Date: Mon Oct 30 12:42:41 2017
New Revision: 316949

URL: http://llvm.org/viewvc/llvm-project?rev=316949&view=rev
Log:
[GVNHoist] Fix non-deterministic sort order of PHIs for identical instructions

Summary: This fixes failure in Transforms/GVNHoist/hoist.ll uncovered by D39245.

Reviewers: hiraditya, spop, dberlin

Reviewed By: dberlin

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D39410

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=316949&r1=316948&r2=316949&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Mon Oct 30 12:42:41 2017
@@ -703,7 +703,7 @@ private:
       // Vector of PHIs contains PHIs for different instructions.
       // Sort the args according to their VNs, such that identical
       // instructions are together.
-      std::sort(CHIs.begin(), CHIs.end(), cmpVN);
+      std::stable_sort(CHIs.begin(), CHIs.end(), cmpVN);
       auto TI = BB->getTerminator();
       auto B = CHIs.begin();
       // [PreIt, PHIIt) form a range of CHIs which have identical VNs.




More information about the llvm-commits mailing list