[RewriteStatepointsForGC] Make base pointer inference deterministic
authorPhilip Reames <listmail@philipreames.com>
Wed, 9 Sep 2015 23:26:08 +0000 (23:26 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 9 Sep 2015 23:26:08 +0000 (23:26 +0000)
commitb4f6a50926a9b2c684594f1ec4366cae09a82976
tree949ca441df97aeaf7013982eaffd98da15028f97
parentd77a329d71c6c71c0788ca4578d99478cc82ca01
[RewriteStatepointsForGC] Make base pointer inference deterministic

Previously, the base pointer algorithm wasn't deterministic. The core fixed point was (of course), but we were inserting new nodes and optimizing them in an order which was unspecified and variable. We'd somewhat hacked around this for testing by sorting by value name, but that doesn't solve the general determinism problem.

Instead, we can use the order of traversal over the def/use graph to give us a single consistent ordering. Today, this is a DFS order, but the exact order doesn't mater provided it's deterministic for a given input.

(Q: It is safe to rely on a deterministic order of operands right?)

Note that this only fixes the determinism within a single inference step. The inference step is currently invoked many times in a non-deterministic order. That's a future change in the sequence. :)

Differential Revision: http://reviews.llvm.org/D12640

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247208 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp