aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-03-18 23:28:02 +0000
committerDevang Patel <dpatel@apple.com>2011-03-18 23:28:02 +0000
commit9c5822a966572ea78f4e818870d4229c7a855749 (patch)
treec21b3d71eca38f449b98610e1bae3810b0145f19 /lib/Transforms/Utils/Local.cpp
parent7b6747ed420ef32d5c12f62833c2b5ad1c46d604 (diff)
Consider debug info intrinsics pointing to null value as dead instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r--lib/Transforms/Utils/Local.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index e54dfb3dc7..19b999722d 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<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;