From: Philip Reames Date: Tue, 12 May 2015 21:21:18 +0000 (+0000) Subject: [PlaceSafepoints] Switch to being a FunctionPass X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=fab55cf45f54ec0ca6ce53dbc633b66c58d6a0b3 [PlaceSafepoints] Switch to being a FunctionPass The pass doesn't actually modify the module outside of the function being processed. The only confusing piece is that it both inserts calls and then inlines the resulting calls. Given that, it definitely invalidates module level analysis results, but many FunctionPasses do that. Differential Revision: http://reviews.llvm.org/D9590 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237185 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 925ebda1317..ff9980b89c4 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -442,7 +442,7 @@ FunctionPass *createStraightLineStrengthReducePass(); // RewriteStatepointsForGC which can be run at an arbitrary point in the pass // order following this pass. // -ModulePass *createPlaceSafepointsPass(); +FunctionPass *createPlaceSafepointsPass(); //===----------------------------------------------------------------------===// // diff --git a/lib/Transforms/Scalar/PlaceSafepoints.cpp b/lib/Transforms/Scalar/PlaceSafepoints.cpp index 06b642c73c3..5c3f6131625 100644 --- a/lib/Transforms/Scalar/PlaceSafepoints.cpp +++ b/lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -166,20 +166,13 @@ static cl::opt NoCall("spp-no-call", cl::Hidden, cl::init(false)); static cl::opt NoBackedge("spp-no-backedge", cl::Hidden, cl::init(false)); namespace { -struct PlaceSafepoints : public ModulePass { +struct PlaceSafepoints : public FunctionPass { static char ID; // Pass identification, replacement for typeid - PlaceSafepoints() : ModulePass(ID) { + PlaceSafepoints() : FunctionPass(ID) { initializePlaceSafepointsPass(*PassRegistry::getPassRegistry()); } - bool runOnModule(Module &M) override { - bool modified = false; - for (Function &F : M) { - modified |= runOnFunction(F); - } - return modified; - } - bool runOnFunction(Function &F); + bool runOnFunction(Function &F) override; void getAnalysisUsage(AnalysisUsage &AU) const override { // We modify the graph wholesale (inlining, block insertion, etc). We @@ -755,7 +748,9 @@ bool PlaceSafepoints::runOnFunction(Function &F) { char PlaceBackedgeSafepointsImpl::ID = 0; char PlaceSafepoints::ID = 0; -ModulePass *llvm::createPlaceSafepointsPass() { return new PlaceSafepoints(); } +FunctionPass *llvm::createPlaceSafepointsPass() { + return new PlaceSafepoints(); +} INITIALIZE_PASS_BEGIN(PlaceBackedgeSafepointsImpl, "place-backedge-safepoints-impl",