[NewGVN] Explain why sorting by pointer values doesn't introduce non-determinism.

Thanks to Eli for pointing out in a post-commit review comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2017-05-09 18:29:37 +00:00
parent 5600d46a6d
commit d65047601c

View File

@ -734,6 +734,10 @@ PHIExpression *NewGVN::createPHIExpression(Instruction *I, bool &HasBackedge,
// PHIs. LLVM doesn't seem to always guarantee this. While we need to fix
// this in LLVM at some point we don't want GVN to find wrong congruences.
// Therefore, here we sort uses in predecessor order.
// We're sorting the values by pointer. In theory this might be cause of
// non-determinism, but here we don't rely on the ordering for anything
// significant, e.g. we don't create new instructions based on it so we're
// fine.
SmallVector<const Use *, 4> PHIOperands;
for (const Use &U : PN->operands())
PHIOperands.push_back(&U);