aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
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/UnifyFunctionExitNodes.cpp
parent2436eda94ac811d338a03c50ef82b66e37ddd56f (diff)
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/UnifyFunctionExitNodes.cpp')
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index 18164220f8..064bba5ddd 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