X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FIPO%2FPruneEH.cpp;h=01816052569036882a41c9a21faa3c347aa7f42e;hb=280a6e607d8eb7401749a92db624a82de47da777;hp=ec0558e80a945b6db865e4e4817e27271f0cd380;hpb=3c4a26226f30f2e9a022d155586e660af38aba1f;p=oota-llvm.git diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index ec0558e80a9..01816052569 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -25,14 +25,12 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" -#include "llvm/ParamAttrsList.h" #include #include using namespace llvm; STATISTIC(NumRemoved, "Number of invokes removed"); STATISTIC(NumUnreach, "Number of noreturn calls optimized"); -STATISTIC(NumBBUnwind, "Number of unwind_to removed from blocks"); namespace { struct VISIBILITY_HIDDEN PruneEH : public CallGraphSCCPass { @@ -131,9 +129,8 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { if (!SCCMightReturn) NewAttributes |= ParamAttr::NoReturn; - const ParamAttrsList *PAL = SCC[i]->getFunction()->getParamAttrs(); - PAL = ParamAttrsList::includeAttrs(PAL, 0, NewAttributes); - SCC[i]->getFunction()->setParamAttrs(PAL); + const PAListPtr &PAL = SCC[i]->getFunction()->getParamAttrs(); + SCC[i]->getFunction()->setParamAttrs(PAL.addAttr(0, NewAttributes)); } for (unsigned i = 0, e = SCC.size(); i != e; ++i) { @@ -154,14 +151,12 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { bool PruneEH::SimplifyFunction(Function *F) { bool MadeChange = false; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { - bool couldUnwind = false; - if (InvokeInst *II = dyn_cast(BB->getTerminator())) if (II->doesNotThrow()) { SmallVector Args(II->op_begin()+3, II->op_end()); // Insert a call instruction before the invoke. - CallInst *Call = new CallInst(II->getCalledValue(), - Args.begin(), Args.end(), "", II); + CallInst *Call = CallInst::Create(II->getCalledValue(), + Args.begin(), Args.end(), "", II); Call->takeName(II); Call->setCallingConv(II->getCallingConv()); Call->setParamAttrs(II->getParamAttrs()); @@ -174,7 +169,7 @@ bool PruneEH::SimplifyFunction(Function *F) { // Insert a branch to the normal destination right before the // invoke. - new BranchInst(II->getNormalDest(), II); + BranchInst::Create(II->getNormalDest(), II); // Finally, delete the invoke instruction! BB->getInstList().pop_back(); @@ -185,12 +180,10 @@ bool PruneEH::SimplifyFunction(Function *F) { ++NumRemoved; MadeChange = true; - } else { - couldUnwind = true; } for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) - if (CallInst *CI = dyn_cast(I++)) { + if (CallInst *CI = dyn_cast(I++)) if (CI->doesNotReturn() && !isa(I)) { // This call calls a function that cannot return. Insert an // unreachable instruction after it and simplify the code. Do this @@ -206,19 +199,9 @@ bool PruneEH::SimplifyFunction(Function *F) { MadeChange = true; ++NumUnreach; break; - } else if (!CI->doesNotThrow()) { - couldUnwind = true; } - } - - // Strip 'unwindTo' off of BBs that have no calls/invokes without nounwind. - if (!couldUnwind && BB->getUnwindDest()) { - MadeChange = true; - ++NumBBUnwind; - BB->getUnwindDest()->removePredecessor(BB, false, true); - BB->setUnwindDest(NULL); - } } + return MadeChange; }