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 | 2af517281d6c36313f7ff74337a84c4fac716dbb (patch) | |
tree | f6d420f010d81c3328601e8073f8a573831d4223 /llvm/lib/Transforms/Scalar | |
parent | 63a0ccff4496816a6774c1370237dd29c7062b09 (diff) | |
download | bcm5719-llvm-2af517281d6c36313f7ff74337a84c4fac716dbb.tar.gz bcm5719-llvm-2af517281d6c36313f7ff74337a84c4fac716dbb.zip |
Start using the nicer terminator auto-insertion API
llvm-svn: 10111
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ADCE.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplify.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LowerSwitch.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 10 |
4 files changed, 15 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 941cc2dc09c..5a5151e8b64 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -302,7 +302,7 @@ bool ADCE::doADCE() { // if (!AliveBlocks.count(&Func->front())) { BasicBlock *NewEntry = new BasicBlock(); - NewEntry->getInstList().push_back(new BranchInst(&Func->front())); + new BranchInst(&Func->front(), 0, 0, NewEntry); Func->getBasicBlockList().push_front(NewEntry); AliveBlocks.insert(NewEntry); // This block is always alive! LiveSet.insert(NewEntry->getTerminator()); // The branch is live @@ -432,8 +432,8 @@ bool ADCE::doADCE() { // Delete the old terminator instruction... BB->getInstList().pop_back(); const Type *RetTy = Func->getReturnType(); - BB->getInstList().push_back(new ReturnInst(RetTy != Type::VoidTy ? - Constant::getNullValue(RetTy) : 0)); + new ReturnInst(RetTy != Type::VoidTy ? + Constant::getNullValue(RetTy) : 0, BB); } } diff --git a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp index b999ed40cc9..46f2beb34b0 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/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/llvm/lib/Transforms/Scalar/LowerSwitch.cpp b/llvm/lib/Transforms/Scalar/LowerSwitch.cpp index 1d0e47145ac..bec23fffc85 100644 --- a/llvm/lib/Transforms/Scalar/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Scalar/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/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index dbe91a79407..87cd27d22be 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -33,7 +33,7 @@ #include "llvm/Pass.h" #include "Support/Statistic.h" -namespace llvm { +using namespace llvm; namespace { Statistic<> NumEliminated("tailcallelim", "Number of tail calls removed"); @@ -45,7 +45,9 @@ namespace { } // Public interface to the TailCallElimination pass -FunctionPass *createTailCallEliminationPass() { return new TailCallElim(); } +FunctionPass *llvm::createTailCallEliminationPass() { + return new TailCallElim(); +} bool TailCallElim::runOnFunction(Function &F) { @@ -74,7 +76,7 @@ bool TailCallElim::runOnFunction(Function &F) { // us to branch back to the old entry block. OldEntry = &F.getEntryBlock(); BasicBlock *NewEntry = new BasicBlock("tailrecurse", OldEntry); - NewEntry->getInstList().push_back(new BranchInst(OldEntry)); + new BranchInst(OldEntry, 0, 0, NewEntry); // Now that we have created a new block, which jumps to the entry // block, insert a PHI node for each argument of the function. @@ -107,5 +109,3 @@ bool TailCallElim::runOnFunction(Function &F) { return MadeChange; } - -} // End llvm namespace |