Add a pass for inserting safepoints into (nearly) arbitrary IR
authorPhilip Reames <listmail@philipreames.com>
Wed, 4 Feb 2015 00:37:33 +0000 (00:37 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 4 Feb 2015 00:37:33 +0000 (00:37 +0000)
commit47cc673e1f20c7662e41ababf4cb98050720cf5c
treef1c6179f2adfeabfc4c31615cbd3f96ac31aa659
parent96a36017f769c759f226a4b710d6e4f907ea0ef0
Add a pass for inserting safepoints into (nearly) arbitrary IR

This pass is responsible for figuring out where to place call safepoints and safepoint polls. It doesn't actually make the relocations explicit; that's the job of the RewriteStatepointsForGC pass (http://reviews.llvm.org/D6975).

Note that this code is not yet finalized.  Its moving in tree for incremental development, but further cleanup is needed and will happen over the next few days.  It is not yet part of the standard pass order.

Planned changes in the near future:
 - I plan on restructuring the statepoint rewrite to use the functions add to the IRBuilder a while back.
 - In the current pass, the function "gc.safepoint_poll" is treated specially but is not an intrinsic. I plan to make identifying the poll function a property of the GCStrategy at some point in the near future.
 - As follow on patches, I will be separating a collection of test cases we have out of tree and submitting them upstream.
 - It's not explicit in the code, but these two patches are introducing a new state for a statepoint which looks a lot like a patchpoint. There's no a transient form which doesn't yet have the relocations explicitly represented, but does prevent reordering of memory operations. Once this is in, I need to update actually make this explicit by reserving the 'unused' argument of the statepoint as a flag, updating the docs, and making the code explicitly check for such a thing. This wasn't really planned, but once I split the two passes - which was done for other reasons - the intermediate state fell out. Just reminds us once again that we need to merge statepoints and patchpoints at some point in the not that distant future.

Future directions planned:
 - Identifying more cases where a backedge safepoint isn't required to ensure timely execution of a safepoint poll.
 - Tweaking the insertion process to generate easier to optimize IR. (For example, investigating making SplitBackedge) the default.
 - Adding opt-in flags for a GCStrategy to use this pass. Once done, add this pass to the actual pass ordering.

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

llvm-svn: 228090
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp [new file with mode: 0644]
llvm/lib/Transforms/Scalar/Scalar.cpp