X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FUtils%2FUnifyFunctionExitNodes.cpp;h=3c522b53ab03e1300210a2ba8dcd12256eb0140b;hb=dee430d26e14a3d7c8d86688d49ac8b116aa044f;hp=d5a7040f39d55b5621bce933356acbce123ccead;hpb=228b14b71eaf7c2990d25b8be56ca7250f605a8b;p=oota-llvm.git diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index d5a7040f39d..3c522b53ab0 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -49,8 +49,8 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { if (F.getReturnType() != Type::VoidTy) { // If the function doesn't return void... add a PHI node to the block... - PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal", - NewRetBlock->end()); + PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal"); + NewRetBlock->getInstList().push_back(PN); // Add an incoming element to the PHI node for every return instruction that // is merging into this new block... @@ -59,10 +59,10 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { PN->addIncoming((*I)->getTerminator()->getOperand(0), *I); // Add a return instruction to return the result of the PHI node... - new ReturnInst(PN, NewRetBlock->end()); + NewRetBlock->getInstList().push_back(new ReturnInst(PN)); } else { // If it returns void, just add a return void instruction to the block - new ReturnInst(0, NewRetBlock->end()); + NewRetBlock->getInstList().push_back(new ReturnInst()); } // Loop over all of the blocks, replacing the return instruction with an @@ -71,7 +71,7 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { for (vector::iterator I = ReturningBlocks.begin(), E = ReturningBlocks.end(); I != E; ++I) { (*I)->getInstList().pop_back(); // Remove the return insn - new BranchInst(NewRetBlock, (*I)->end()); + (*I)->getInstList().push_back(new BranchInst(NewRetBlock)); } ExitNode = NewRetBlock; return true;