diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-11-30 19:12:10 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-11-30 19:12:10 +0000 |
| commit | b63ba73b1b97e717e04eb8be5f7afc7b2f5ef1ea (patch) | |
| tree | 5708ffcd5c76db5d8fb2c6d5aa2a50ad3858a157 /llvm/lib/Transforms | |
| parent | 8b166186857ff33ccc281848880f5da33bd08706 (diff) | |
| download | bcm5719-llvm-b63ba73b1b97e717e04eb8be5f7afc7b2f5ef1ea.tar.gz bcm5719-llvm-b63ba73b1b97e717e04eb8be5f7afc7b2f5ef1ea.zip | |
enhance isRemovable to refuse to delete volatile mem transfers
now that DSE hacks on them. This fixes a regression I introduced,
by generalizing DSE to hack on transfers.
llvm-svn: 120445
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index cb4d482a634..d05f57f0d02 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -152,12 +152,27 @@ getLocForWrite(Instruction *Inst, AliasAnalysis &AA) { /// isRemovable - If the value of this instruction and the memory it writes to /// is unused, may we delete this instruction? static bool isRemovable(Instruction *I) { - assert(hasMemoryWrite(I)); - if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) - return II->getIntrinsicID() != Intrinsic::lifetime_end; + // Don't remove volatile stores. if (StoreInst *SI = dyn_cast<StoreInst>(I)) return !SI->isVolatile(); - return true; + + IntrinsicInst *II = cast<IntrinsicInst>(I); + switch (II->getIntrinsicID()) { + default: assert(0 && "doesn't pass 'hasMemoryWrite' predicate"); + case Intrinsic::lifetime_end: + // Never remove dead lifetime_end's, e.g. because it is followed by a + // free. + return false; + case Intrinsic::init_trampoline: + // Always safe to remove init_trampoline. + return true; + + case Intrinsic::memset: + case Intrinsic::memmove: + case Intrinsic::memcpy: + // Don't remove volatile memory intrinsics. + return !cast<MemIntrinsic>(II)->isVolatile(); + } } /// getPointerOperand - Return the pointer that is being written to. |

