diff options
author | Devang Patel <dpatel@apple.com> | 2011-05-18 18:43:31 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-05-18 18:43:31 +0000 |
commit | 2c2ea226b797fb52cd60f887c8c5d4c43e784ba5 (patch) | |
tree | 880d892401c037254f7dde97281d9d5753154e2b /llvm/lib/Transforms | |
parent | 767f6930bca8f25c97cdf7b5861c8a06e75875a5 (diff) | |
download | bcm5719-llvm-2c2ea226b797fb52cd60f887c8c5d4c43e784ba5.tar.gz bcm5719-llvm-2c2ea226b797fb52cd60f887c8c5d4c43e784ba5.zip |
Use IRBuilder while simplifying terminator.
llvm-svn: 131552
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index bdcb4830936..0e57dc31458 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1835,16 +1835,19 @@ static bool SimplifyTerminatorOnSelect(TerminatorInst *OldTerm, Value *Cond, Succ->removePredecessor(OldTerm->getParent()); } + IRBuilder<> Builder(OldTerm); + Builder.SetCurrentDebugLocation(OldTerm->getDebugLoc()); + // Insert an appropriate new terminator. if ((KeepEdge1 == 0) && (KeepEdge2 == 0)) { if (TrueBB == FalseBB) // We were only looking for one successor, and it was present. // Create an unconditional branch to it. - BranchInst::Create(TrueBB, OldTerm); + Builder.CreateBr(TrueBB); else // We found both of the successors we were looking for. // Create a conditional branch sharing the condition of the select. - BranchInst::Create(TrueBB, FalseBB, Cond, OldTerm); + Builder.CreateCondBr(Cond, TrueBB, FalseBB); } else if (KeepEdge1 && (KeepEdge2 || TrueBB == FalseBB)) { // Neither of the selected blocks were successors, so this // terminator must be unreachable. @@ -1855,10 +1858,10 @@ static bool SimplifyTerminatorOnSelect(TerminatorInst *OldTerm, Value *Cond, // the edge to the one that wasn't must be unreachable. if (KeepEdge1 == 0) // Only TrueBB was found. - BranchInst::Create(TrueBB, OldTerm); + Builder.CreateBr(TrueBB); else // Only FalseBB was found. - BranchInst::Create(FalseBB, OldTerm); + Builder.CreateBr(FalseBB); } EraseTerminatorInstAndDCECond(OldTerm); |