diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index e54dfb3dc73..19b999722db 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/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;