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

llvm-svn: 23616
This commit is contained in:
Chris Lattner 2005-10-03 23:43:43 +00:00
parent 45773bd686
commit cd43592209

View File

@ -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;
}
}