aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-03 23:43:43 +0000
committerChris Lattner <sabre@nondot.org>2005-10-03 23:43:43 +0000
commit7a66e686fe1406ea704e71e18cf99d4745d0b43d (patch)
treea13fb38e78973030a68b458dab95589c83860106 /lib/Transforms/Utils/SimplifyCFG.cpp
parent457029c244475dd6fb0f4eea1ade2436a2c1fe3c (diff)
Clean up the code a bit. Use isInstructionTriviallyDead to be more aggressive
and more correct than use_empty(). This fixes PR635 and SimplifyCFG/2005-10-02-InvokeSimplify.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23616 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index ba6ce17087..6b5914365b 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1284,12 +1284,16 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
FalseValue, "retval", BI);
else
NewRetVal = TrueValue;
+
+ DEBUG(std::cerr << "\nCHANGING BRANCH TO TWO RETURNS INTO SELECT:"
+ << "\n " << *BI << "Select = " << *NewRetVal
+ << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: "<< *FalseSucc);
new ReturnInst(NewRetVal, BI);
- BI->getParent()->getInstList().erase(BI);
- if (BrCond->use_empty())
- if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
- BrCondI->getParent()->getInstList().erase(BrCondI);
+ BI->eraseFromParent();
+ if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
+ if (isInstructionTriviallyDead(BrCondI))
+ BrCondI->eraseFromParent();
return true;
}
}