Fix bugs in previous checkins

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-09-10 23:31:28 +00:00
parent 08c2e4838d
commit 8606d9924b

View File

@ -49,8 +49,8 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
if (F.getReturnType() != Type::VoidTy) { if (F.getReturnType() != Type::VoidTy) {
// If the function doesn't return void... add a PHI node to the block... // If the function doesn't return void... add a PHI node to the block...
PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal", PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal");
NewRetBlock->end()); NewRetBlock->getInstList().push_back(PN);
// Add an incoming element to the PHI node for every return instruction that // Add an incoming element to the PHI node for every return instruction that
// is merging into this new block... // is merging into this new block...
@ -59,7 +59,7 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
PN->addIncoming((*I)->getTerminator()->getOperand(0), *I); PN->addIncoming((*I)->getTerminator()->getOperand(0), *I);
// Add a return instruction to return the result of the PHI node... // 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 { } else {
// If it returns void, just add a return void instruction to the block // If it returns void, just add a return void instruction to the block
new ReturnInst(0, NewRetBlock->end()); new ReturnInst(0, NewRetBlock->end());
@ -71,7 +71,7 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
for (vector<BasicBlock*>::iterator I = ReturningBlocks.begin(), for (vector<BasicBlock*>::iterator I = ReturningBlocks.begin(),
E = ReturningBlocks.end(); I != E; ++I) { E = ReturningBlocks.end(); I != E; ++I) {
(*I)->getInstList().pop_back(); // Remove the return insn (*I)->getInstList().pop_back(); // Remove the return insn
new BranchInst(NewRetBlock, (*I)->end()); (*I)->getInstList().push_back(new BranchInst(NewRetBlock));
} }
ExitNode = NewRetBlock; ExitNode = NewRetBlock;
return true; return true;