From 99890a225f80495468174becb876a560f4383cea Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Aug 2011 21:19:27 +0000 Subject: Lifetime intrinsics on undef are dead. llvm-svn: 136722 --- llvm/lib/Transforms/Utils/Local.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Utils/Local.cpp') diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 2d43e3773ef..60dc15d6425 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/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(I)) { - if (DDI->getAddress()) + if (DDI->getAddress()) return false; return true; - } + } if (DbgValueInst *DVI = dyn_cast(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(I)) + if (IntrinsicInst *II = dyn_cast(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(II->getArgOperand(1)); + } return false; } -- cgit v1.2.3