aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-21 16:52:05 +0000
committerChris Lattner <sabre@nondot.org>2003-11-21 16:52:05 +0000
commit108e4ab159b59a616b0868e396dc7ddc1fb48616 (patch)
treefa6892850c59a118e0538ff21d0beb01f2d5ce0b /lib/Transforms/Utils
parent2436eda94ac811d338a03c50ef82b66e37ddd56f (diff)
downloadexternal_llvm-108e4ab159b59a616b0868e396dc7ddc1fb48616.zip
external_llvm-108e4ab159b59a616b0868e396dc7ddc1fb48616.tar.gz
external_llvm-108e4ab159b59a616b0868e396dc7ddc1fb48616.tar.bz2
Minor cleanups and simplifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/BreakCriticalEdges.cpp2
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp4
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp6
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp14
4 files changed, 10 insertions, 16 deletions
diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp
index 0b59710..1175b10 100644
--- a/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -106,7 +106,7 @@ bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." +
DestBB->getName() + "_crit_edge");
// Create our unconditional branch...
- new BranchInst(DestBB, 0, 0, NewBB);
+ new BranchInst(DestBB, NewBB);
// Branch to the new block, breaking the edge...
TI->setSuccessor(SuccNum, NewBB);
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index 46f2beb..60e35d5 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -153,7 +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, 0, 0, NewBB);
+ BranchInst *BI = new BranchInst(BB, 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
@@ -379,7 +379,7 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
// Create and insert the new backedge block...
BasicBlock *BEBlock = new BasicBlock(Header->getName()+".backedge", F);
- BranchInst *BETerminator = new BranchInst(Header, 0, 0, BEBlock);
+ BranchInst *BETerminator = new BranchInst(Header, 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 bec23ff..24e48d4 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -186,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) {
- new BranchInst(SI->getDefaultDest(), 0, 0, CurBlock);
+ new BranchInst(SI->getDefaultDest(), CurBlock);
delete SI;
return;
}
@@ -196,7 +196,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
BasicBlock* NewDefault = new BasicBlock("NewDefault");
F->getBasicBlockList().insert(Default, NewDefault);
- new BranchInst(Default, 0, 0, NewDefault);
+ new BranchInst(Default, NewDefault);
// If there is an entry in any PHI nodes for the default edge, make sure
// to update them as well.
@@ -219,7 +219,7 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
OrigBlock, NewDefault);
// Branch to our shiny new if-then stuff...
- new BranchInst(SwitchBlock, 0, 0, OrigBlock);
+ new BranchInst(SwitchBlock, 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 1816422..064bba5 100644
--- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -21,13 +21,12 @@
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
#include "llvm/Type.h"
-
-namespace llvm {
+using namespace llvm;
static RegisterOpt<UnifyFunctionExitNodes>
X("mergereturn", "Unify function exit nodes");
-Pass *createUnifyFunctionExitNodesPass() {
+Pass *llvm::createUnifyFunctionExitNodesPass() {
return new UnifyFunctionExitNodes();
}
@@ -91,11 +90,8 @@ 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);
- new ReturnInst(PN, NewRetBlock);
- } else {
- // If it returns void, just add a return void instruction to the block
- new ReturnInst(0, NewRetBlock);
}
+ new ReturnInst(PN, NewRetBlock);
// Loop over all of the blocks, replacing the return instruction with an
// unconditional branch.
@@ -109,10 +105,8 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
if (PN) PN->addIncoming(BB->getTerminator()->getOperand(0), BB);
BB->getInstList().pop_back(); // Remove the return insn
- new BranchInst(NewRetBlock, 0, 0, BB);
+ new BranchInst(NewRetBlock, BB);
}
ReturnBlock = NewRetBlock;
return true;
}
-
-} // End llvm namespace