Skip to content

Commit

Permalink
[GVNHoist] Fix non-deterministic sort order of PHIs for identical ins…
Browse files Browse the repository at this point in the history
…tructions

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

llvm-svn: 316949
  • Loading branch information
Mandeep Singh Grang committed Oct 30, 2017
1 parent 3c128cb commit f83268b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/GVNHoist.cpp
Expand Up @@ -703,7 +703,7 @@ class GVNHoist {
// 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.
Expand Down

0 comments on commit f83268b

Please sign in to comment.