diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-05 22:41:43 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-05 22:41:43 +0000 |
commit | 0a205a459884ec745df1c529396dd921f029dafd (patch) | |
tree | 905109491ef6c2ea3d99d01fc48af9c2c633e645 /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | db882950f3bcf7f710843610e917988daeafffc2 (diff) |
More LLVMContext-ification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 58d4d5a344..2aeb0bb1ce 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -16,6 +16,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/Type.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" @@ -1274,6 +1275,8 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { /// FoldTwoEntryPHINode - Given a BB that starts with the specified two-entry /// PHI node, see if we can eliminate it. static bool FoldTwoEntryPHINode(PHINode *PN) { + LLVMContext* Context = PN->getParent()->getContext(); + // Ok, this is a two entry PHI node. Check to see if this is a simple "if // statement", which has a very simple dominance structure. Basically, we // are trying to find the condition that is being branched on, which @@ -1311,7 +1314,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN) { if (PN->getIncomingValue(0) != PN) PN->replaceAllUsesWith(PN->getIncomingValue(0)); else - PN->replaceAllUsesWith(UndefValue::get(PN->getType())); + PN->replaceAllUsesWith(Context->getUndef(PN->getType())); } else if (!DominatesMergePoint(PN->getIncomingValue(0), BB, &AggressiveInsts) || !DominatesMergePoint(PN->getIncomingValue(1), BB, @@ -1605,6 +1608,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) { static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) { assert(PBI->isConditional() && BI->isConditional()); BasicBlock *BB = BI->getParent(); + LLVMContext* Context = BB->getContext(); // If this block ends with a branch instruction, and if there is a // predecessor that ends on a branch of the same condition, make @@ -1616,7 +1620,7 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) { if (BB->getSinglePredecessor()) { // Turn this into a branch on constant. bool CondIsTrue = PBI->getSuccessor(0) == BB; - BI->setCondition(ConstantInt::get(Type::Int1Ty, CondIsTrue)); + BI->setCondition(Context->getConstantInt(Type::Int1Ty, CondIsTrue)); return true; // Nuke the branch on constant. } @@ -1636,7 +1640,7 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) { PBI->getCondition() == BI->getCondition() && PBI->getSuccessor(0) != PBI->getSuccessor(1)) { bool CondIsTrue = PBI->getSuccessor(0) == BB; - NewPN->addIncoming(ConstantInt::get(Type::Int1Ty, + NewPN->addIncoming(Context->getConstantInt(Type::Int1Ty, CondIsTrue), *PI); } else { NewPN->addIncoming(BI->getCondition(), *PI); |