aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/DeadStoreElimination.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-08-26 21:14:47 +0000
committerOwen Anderson <resistor@mac.com>2007-08-26 21:14:47 +0000
commit5dfcf4318ab10da62a86cdce94f90c0a0cd42ad1 (patch)
tree7ed011729b4ea1d90c3dd06a47f0b59c46c36d29 /lib/Transforms/Scalar/DeadStoreElimination.cpp
parente6c1742914149d44360fbf05a653041a672282af (diff)
downloadexternal_llvm-5dfcf4318ab10da62a86cdce94f90c0a0cd42ad1.zip
external_llvm-5dfcf4318ab10da62a86cdce94f90c0a0cd42ad1.tar.gz
external_llvm-5dfcf4318ab10da62a86cdce94f90c0a0cd42ad1.tar.bz2
Don't DSe volatile stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/DeadStoreElimination.cpp')
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 283fcbc..1e5381d 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -111,9 +111,12 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
continue;
Value* pointer = 0;
- if (StoreInst* S = dyn_cast<StoreInst>(BBI))
- pointer = S->getPointerOperand();
- else
+ if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
+ if (!S->isVolatile())
+ pointer = S->getPointerOperand();
+ else
+ continue;
+ } else
pointer = cast<FreeInst>(BBI)->getPointerOperand();
StoreInst*& last = lastStore[pointer];
@@ -194,6 +197,8 @@ bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dep,
StoreInst* dependency = dyn_cast<StoreInst>(dep);
if (!dependency)
return false;
+ else if (dependency->isVolatile())
+ return false;
Value* depPointer = dependency->getPointerOperand();
const Type* depType = dependency->getOperand(0)->getType();
@@ -253,24 +258,26 @@ bool DSE::handleEndBlock(BasicBlock& BB,
// If we find a store whose pointer is dead...
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
- Value* pointerOperand = S->getPointerOperand();
- // See through pointer-to-pointer bitcasts
- TranslatePointerBitCasts(pointerOperand);
+ if (!S->isVolatile()) {
+ Value* pointerOperand = S->getPointerOperand();
+ // See through pointer-to-pointer bitcasts
+ TranslatePointerBitCasts(pointerOperand);
- if (deadPointers.count(pointerOperand)){
- // Remove it!
- MD.removeInstruction(S);
+ if (deadPointers.count(pointerOperand)){
+ // Remove it!
+ MD.removeInstruction(S);
- // DCE instructions only used to calculate that store
- if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
- possiblyDead.insert(D);
- if (Instruction* D = dyn_cast<Instruction>(S->getOperand(1)))
- possiblyDead.insert(D);
+ // DCE instructions only used to calculate that store
+ if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
+ possiblyDead.insert(D);
+ if (Instruction* D = dyn_cast<Instruction>(S->getOperand(1)))
+ possiblyDead.insert(D);
- BBI++;
- S->eraseFromParent();
- NumFastStores++;
- MadeChange = true;
+ BBI++;
+ S->eraseFromParent();
+ NumFastStores++;
+ MadeChange = true;
+ }
}
continue;