Don't DSe volatile stores.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41456 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2007-08-26 21:14:47 +00:00
parent e6c1742914
commit 5dfcf4318a

View File

@@ -111,9 +111,12 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
continue; continue;
Value* pointer = 0; Value* pointer = 0;
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
pointer = S->getPointerOperand(); if (!S->isVolatile())
else pointer = S->getPointerOperand();
else
continue;
} else
pointer = cast<FreeInst>(BBI)->getPointerOperand(); pointer = cast<FreeInst>(BBI)->getPointerOperand();
StoreInst*& last = lastStore[pointer]; StoreInst*& last = lastStore[pointer];
@@ -194,6 +197,8 @@ bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dep,
StoreInst* dependency = dyn_cast<StoreInst>(dep); StoreInst* dependency = dyn_cast<StoreInst>(dep);
if (!dependency) if (!dependency)
return false; return false;
else if (dependency->isVolatile())
return false;
Value* depPointer = dependency->getPointerOperand(); Value* depPointer = dependency->getPointerOperand();
const Type* depType = dependency->getOperand(0)->getType(); 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 we find a store whose pointer is dead...
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) { if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
Value* pointerOperand = S->getPointerOperand(); if (!S->isVolatile()) {
// See through pointer-to-pointer bitcasts Value* pointerOperand = S->getPointerOperand();
TranslatePointerBitCasts(pointerOperand); // See through pointer-to-pointer bitcasts
TranslatePointerBitCasts(pointerOperand);
if (deadPointers.count(pointerOperand)){ if (deadPointers.count(pointerOperand)){
// Remove it! // Remove it!
MD.removeInstruction(S); MD.removeInstruction(S);
// DCE instructions only used to calculate that store // DCE instructions only used to calculate that store
if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0))) if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
possiblyDead.insert(D); possiblyDead.insert(D);
if (Instruction* D = dyn_cast<Instruction>(S->getOperand(1))) if (Instruction* D = dyn_cast<Instruction>(S->getOperand(1)))
possiblyDead.insert(D); possiblyDead.insert(D);
BBI++; BBI++;
S->eraseFromParent(); S->eraseFromParent();
NumFastStores++; NumFastStores++;
MadeChange = true; MadeChange = true;
}
} }
continue; continue;