Consider debug info intrinsics pointing to null value as dead instructions.

llvm-svn: 127922
This commit is contained in:
Devang Patel 2011-03-18 23:28:02 +00:00
parent 1ec7b33079
commit c1431e6e84
1 changed files with 14 additions and 1 deletions

View File

@ -211,7 +211,20 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
bool llvm::isInstructionTriviallyDead(Instruction *I) {
if (!I->use_empty() || isa<TerminatorInst>(I)) return false;
// We don't want debug info removed by anything this general.
// We don't want debug info removed by anything this general, unless
// debug info is empty.
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
if (DDI->getAddress())
return false;
else
return true;
} else if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
if (DVI->getValue())
return false;
else
return true;
}
if (isa<DbgInfoIntrinsic>(I)) return false;
if (!I->mayHaveSideEffects()) return true;