From c1431e6e84d84c644b4cc19caa3a1b69ada12545 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 18 Mar 2011 23:28:02 +0000 Subject: [PATCH] Consider debug info intrinsics pointing to null value as dead instructions. llvm-svn: 127922 --- llvm/lib/Transforms/Utils/Local.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index e54dfb3dc73f..19b999722dbc 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -211,7 +211,20 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) { bool llvm::isInstructionTriviallyDead(Instruction *I) { if (!I->use_empty() || isa(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(I)) { + if (DDI->getAddress()) + return false; + else + return true; + } else if (DbgValueInst *DVI = dyn_cast(I)) { + if (DVI->getValue()) + return false; + else + return true; + } + if (isa(I)) return false; if (!I->mayHaveSideEffects()) return true;