diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-20 18:25:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-20 18:25:24 +0000 |
commit | f8485c643412dbff46fe87ea2867445169a5c28e (patch) | |
tree | 47df4c3a7138fa1f6051e38e3faf81613862b616 /lib/Transforms/Utils | |
parent | adbc0b5287bf36893cdcae2440d48b3cb3489e38 (diff) | |
download | external_llvm-f8485c643412dbff46fe87ea2867445169a5c28e.zip external_llvm-f8485c643412dbff46fe87ea2867445169a5c28e.tar.gz external_llvm-f8485c643412dbff46fe87ea2867445169a5c28e.tar.bz2 |
Start using the nicer terminator auto-insertion API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10111 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/BreakCriticalEdges.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerSwitch.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 10 |
5 files changed, 14 insertions, 19 deletions
diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index e8201cc..0b59710 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -106,8 +106,7 @@ bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." + DestBB->getName() + "_crit_edge"); // Create our unconditional branch... - BranchInst *BI = new BranchInst(DestBB); - NewBB->getInstList().push_back(BI); + new BranchInst(DestBB, 0, 0, NewBB); // Branch to the new block, breaking the edge... TI->setSuccessor(SuccNum, NewBB); diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 265d5c4..a0fc9bf 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -238,7 +238,7 @@ bool InlineFunction(CallSite CS) { // invoke site. Once this happens, we know that the unwind would cause // a control transfer to the invoke exception destination, so we can // transform it into a direct branch to the exception destination. - BranchInst *BI = new BranchInst(InvokeDest, UI); + new BranchInst(InvokeDest, UI); // Delete the unwind instruction! UI->getParent()->getInstList().pop_back(); diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index b999ed4..46f2beb 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -153,8 +153,7 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB, BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB); // The preheader first gets an unconditional branch to the loop header... - BranchInst *BI = new BranchInst(BB); - NewBB->getInstList().push_back(BI); + BranchInst *BI = new BranchInst(BB, 0, 0, NewBB); // For every PHI node in the block, insert a PHI node into NewBB where the // incoming values from the out of loop edges are moved to NewBB. We have two @@ -380,8 +379,7 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) { // Create and insert the new backedge block... BasicBlock *BEBlock = new BasicBlock(Header->getName()+".backedge", F); - Instruction *BETerminator = new BranchInst(Header); - BEBlock->getInstList().push_back(BETerminator); + BranchInst *BETerminator = new BranchInst(Header, 0, 0, BEBlock); // Move the new backedge block to right after the last backedge block. Function::iterator InsertPos = BackedgeBlocks.back(); ++InsertPos; diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 1d0e471..bec23ff 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -132,8 +132,7 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End, SetCondInst* Comp = new SetCondInst(Instruction::SetLT, Val, Pivot.first, "Pivot"); NewNode->getInstList().push_back(Comp); - BranchInst* Br = new BranchInst(LBranch, RBranch, Comp); - NewNode->getInstList().push_back(Br); + new BranchInst(LBranch, RBranch, Comp, NewNode); return NewNode; } @@ -158,8 +157,7 @@ BasicBlock* LowerSwitch::newLeafBlock(Case& Leaf, Value* Val, // Make the conditional branch... BasicBlock* Succ = Leaf.second; - Instruction* Br = new BranchInst(Succ, Default, Comp); - NewLeaf->getInstList().push_back(Br); + new BranchInst(Succ, Default, Comp, NewLeaf); // If there were any PHI nodes in this successor, rewrite one entry // from OrigBlock to come from NewLeaf. @@ -188,7 +186,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) { // If there is only the default destination, don't bother with the code below. if (SI->getNumOperands() == 2) { - CurBlock->getInstList().push_back(new BranchInst(SI->getDefaultDest())); + new BranchInst(SI->getDefaultDest(), 0, 0, CurBlock); delete SI; return; } @@ -198,7 +196,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) { BasicBlock* NewDefault = new BasicBlock("NewDefault"); F->getBasicBlockList().insert(Default, NewDefault); - NewDefault->getInstList().push_back(new BranchInst(Default)); + new BranchInst(Default, 0, 0, NewDefault); // If there is an entry in any PHI nodes for the default edge, make sure // to update them as well. @@ -221,7 +219,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) { OrigBlock, NewDefault); // Branch to our shiny new if-then stuff... - OrigBlock->getInstList().push_back(new BranchInst(SwitchBlock)); + new BranchInst(SwitchBlock, 0, 0, OrigBlock); // We are now done with the switch instruction, delete it. delete SI; diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 2591ffd..1816422 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -61,13 +61,13 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { UnwindBlock = UnwindingBlocks.front(); } else { UnwindBlock = new BasicBlock("UnifiedUnwindBlock", &F); - UnwindBlock->getInstList().push_back(new UnwindInst()); + new UnwindInst(UnwindBlock); for (std::vector<BasicBlock*>::iterator I = UnwindingBlocks.begin(), E = UnwindingBlocks.end(); I != E; ++I) { BasicBlock *BB = *I; BB->getInstList().pop_back(); // Remove the return insn - BB->getInstList().push_back(new BranchInst(UnwindBlock)); + new BranchInst(UnwindBlock, 0, 0, BB); } } @@ -91,10 +91,10 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { // If the function doesn't return void... add a PHI node to the block... PN = new PHINode(F.getReturnType(), "UnifiedRetVal"); NewRetBlock->getInstList().push_back(PN); - NewRetBlock->getInstList().push_back(new ReturnInst(PN)); + new ReturnInst(PN, NewRetBlock); } else { // If it returns void, just add a return void instruction to the block - NewRetBlock->getInstList().push_back(new ReturnInst()); + new ReturnInst(0, NewRetBlock); } // Loop over all of the blocks, replacing the return instruction with an @@ -109,7 +109,7 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { if (PN) PN->addIncoming(BB->getTerminator()->getOperand(0), BB); BB->getInstList().pop_back(); // Remove the return insn - BB->getInstList().push_back(new BranchInst(NewRetBlock)); + new BranchInst(NewRetBlock, 0, 0, BB); } ReturnBlock = NewRetBlock; return true; |