[RewriteStatepointsForGC] Reduce the number of new instructions for base pointers
authorPhilip Reames <listmail@philipreames.com>
Thu, 27 Aug 2015 01:02:28 +0000 (01:02 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 27 Aug 2015 01:02:28 +0000 (01:02 +0000)
commit33043ab31723fd090e84e08bdbd80fe1abf6b860
tree471af34c78da6b2b9d67325a31c4e42752f36640
parent8faf2a455ae8cd9a360ef95c341672450e113cdf
[RewriteStatepointsForGC] Reduce the number of new instructions for base pointers

When computing base pointers, we introduce new instructions to propagate the base of existing instructions which might not be bases. However, the algorithm doesn't make any effort to recognize when the new instruction to be inserted is the same as an existing one already in the IR. Since this is happening immediately before rewriting, we don't really have a chance to fix it after the pass runs without teaching loop passes about statepoints.

I'm really not thrilled with this patch. I've rewritten it 4 different ways now, but this is the best I've come up with. The case where the new instruction is just the original base defining value could be merged into the existing algorithm with some complexity. The problem is that we might have something like an extractelement from a phi of two vectors. It may be trivially obvious that the base of the 0th element is an existing instruction, but I can't see how to make the algorithm itself figure that out. Thus, I resort to the call to SimplifyInstruction instead.

Note that we can only adjust the instructions we've inserted ourselves. The live sets are still being tracked in side structures at this point in the code. We can't easily muck with instructions which might be in them. Long term, I'm really thinking we need to materialize the live pointer sets explicitly in the IR somehow rather than using side structures to track them.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246133 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll
test/Transforms/RewriteStatepointsForGC/base-pointers.ll
test/Transforms/RewriteStatepointsForGC/base-vector.ll
test/Transforms/RewriteStatepointsForGC/live-vector.ll