summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-08-02 21:19:27 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-08-02 21:19:27 +0000
commit3e69c13c301acee99c8bde7e692777bf856a6362 (patch)
tree73217bfa6048a7be0f53b89f36111650c3d25207 /lib/Transforms/Utils
parent11066fb9374d80a1564d9bbcc93ccc2402fb1f97 (diff)
downloadllvm-3e69c13c301acee99c8bde7e692777bf856a6362.tar.gz
llvm-3e69c13c301acee99c8bde7e692777bf856a6362.tar.bz2
llvm-3e69c13c301acee99c8bde7e692777bf856a6362.tar.xz
Lifetime intrinsics on undef are dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/Local.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 2d43e3773e..60dc15d642 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -229,10 +229,10 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
// 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())
+ if (DDI->getAddress())
return false;
return true;
- }
+ }
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
if (DVI->getValue())
return false;
@@ -243,10 +243,16 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
// Special case intrinsics that "may have side effects" but can be deleted
// when dead.
- if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
// Safe to delete llvm.stacksave if dead.
if (II->getIntrinsicID() == Intrinsic::stacksave)
return true;
+
+ // Lifetime intrinsics are dead when their right-hand is undef.
+ if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
+ II->getIntrinsicID() == Intrinsic::lifetime_end)
+ return isa<UndefValue>(II->getArgOperand(1));
+ }
return false;
}