diff options
author | Sean Silva <chisophugis@gmail.com> | 2016-07-02 19:12:56 +0000 |
---|---|---|
committer | Sean Silva <chisophugis@gmail.com> | 2016-07-02 19:12:56 +0000 |
commit | 0fb7774f91405e588389d36234d02f1c3f65b6cf (patch) | |
tree | 843c2af97d33eba9d691a8ce16c7d719fd8a666a /llvm/lib/Transforms/IPO/PruneEH.cpp | |
parent | e2133e7c32045b6ad2c933f694cd81b305cb0eb2 (diff) | |
download | bcm5719-llvm-0fb7774f91405e588389d36234d02f1c3f65b6cf.tar.gz bcm5719-llvm-0fb7774f91405e588389d36234d02f1c3f65b6cf.zip |
[PM] Some preparatory refactoring to minimize the diff of D21921
The main change here is just moving stuff to static functions.
llvm-svn: 274446
Diffstat (limited to 'llvm/lib/Transforms/IPO/PruneEH.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/PruneEH.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index df56d8ddd12..2aa3fa55cef 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -47,10 +47,10 @@ namespace { // runOnSCC - Analyze the SCC, performing the transformation if possible. bool runOnSCC(CallGraphSCC &SCC) override; - bool SimplifyFunction(Function *F); - void DeleteBasicBlock(BasicBlock *BB); }; } +static bool SimplifyFunction(Function *F, CallGraph &CG); +static void DeleteBasicBlock(BasicBlock *BB, CallGraph &CG); char PruneEH::ID = 0; INITIALIZE_PASS_BEGIN(PruneEH, "prune-eh", @@ -61,13 +61,8 @@ INITIALIZE_PASS_END(PruneEH, "prune-eh", Pass *llvm::createPruneEHPass() { return new PruneEH(); } - -bool PruneEH::runOnSCC(CallGraphSCC &SCC) { - if (skipSCC(SCC)) - return false; - +static bool runImpl(CallGraphSCC &SCC, CallGraph &CG) { SmallPtrSet<CallGraphNode *, 8> SCCNodes; - CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph(); bool MadeChange = false; // Fill SCCNodes with the elements of the SCC. Used for quickly @@ -79,7 +74,7 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) { // according to what we know. for (CallGraphNode *I : SCC) if (Function *F = I->getFunction()) - MadeChange |= SimplifyFunction(F); + MadeChange |= SimplifyFunction(F, CG); // Next, check to see if any callees might throw or if there are any external // functions in this SCC: if so, we cannot prune any functions in this SCC. @@ -177,17 +172,25 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) { // into call instructions with a branch. This makes the exception blocks // dead. if (Function *F = I->getFunction()) - MadeChange |= SimplifyFunction(F); + MadeChange |= SimplifyFunction(F, CG); } return MadeChange; } +bool PruneEH::runOnSCC(CallGraphSCC &SCC) { + if (skipSCC(SCC)) + return false; + CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph(); + return runImpl(SCC, CG); +} + + // SimplifyFunction - Given information about callees, simplify the specified // function if we have invokes to non-unwinding functions or code after calls to // no-return functions. -bool PruneEH::SimplifyFunction(Function *F) { +static bool SimplifyFunction(Function *F, CallGraph &CG) { bool MadeChange = false; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) @@ -197,7 +200,7 @@ bool PruneEH::SimplifyFunction(Function *F) { // If the unwind block is now dead, nuke it. if (pred_empty(UnwindBlock)) - DeleteBasicBlock(UnwindBlock); // Delete the new BB. + DeleteBasicBlock(UnwindBlock, CG); // Delete the new BB. ++NumRemoved; MadeChange = true; @@ -216,7 +219,7 @@ bool PruneEH::SimplifyFunction(Function *F) { BB->getInstList().pop_back(); new UnreachableInst(BB->getContext(), &*BB); - DeleteBasicBlock(New); // Delete the new BB. + DeleteBasicBlock(New, CG); // Delete the new BB. MadeChange = true; ++NumUnreach; break; @@ -229,9 +232,8 @@ bool PruneEH::SimplifyFunction(Function *F) { /// DeleteBasicBlock - remove the specified basic block from the program, /// updating the callgraph to reflect any now-obsolete edges due to calls that /// exist in the BB. -void PruneEH::DeleteBasicBlock(BasicBlock *BB) { +static void DeleteBasicBlock(BasicBlock *BB, CallGraph &CG) { assert(pred_empty(BB) && "BB is not dead!"); - CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph(); Instruction *TokenInst = nullptr; |