[llvm-commits] [llvm] r41456 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Owen Anderson
resistor at mac.com
Sun Aug 26 14:14:48 PDT 2007
Author: resistor
Date: Sun Aug 26 16:14:47 2007
New Revision: 41456
URL: http://llvm.org/viewvc/llvm-project?rev=41456&view=rev
Log:
Don't DSe volatile stores.
Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=41456&r1=41455&r2=41456&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Aug 26 16:14:47 2007
@@ -111,9 +111,12 @@
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 @@
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 @@
// 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;
More information about the llvm-commits
mailing list