Make AliasAnalysis::getModRefInfo conservative in the face of volatility.

llvm-svn: 110120
This commit is contained in:
Dan Gohman 2010-08-03 17:27:43 +00:00
parent 0c18757c9d
commit 52f9d7d617
1 changed files with 20 additions and 3 deletions

View File

@ -78,8 +78,17 @@ AliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
AliasAnalysis::ModRefResult AliasAnalysis::ModRefResult
AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) { AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) {
return alias(L->getOperand(0), getTypeStoreSize(L->getType()), // If the load address doesn't alias the given address, it doesn't read
P, Size) ? Ref : NoModRef; // or write the specified memory.
if (!alias(L->getOperand(0), getTypeStoreSize(L->getType()), P, Size))
return NoModRef;
// Be conservative in the face of volatile.
if (L->isVolatile())
return ModRef;
// Otherwise, a load just reads.
return Ref;
} }
AliasAnalysis::ModRefResult AliasAnalysis::ModRefResult
@ -90,9 +99,17 @@ AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) {
getTypeStoreSize(S->getOperand(0)->getType()), P, Size)) getTypeStoreSize(S->getOperand(0)->getType()), P, Size))
return NoModRef; return NoModRef;
// Be conservative in the face of volatile.
if (S->isVolatile())
return ModRef;
// If the pointer is a pointer to constant memory, then it could not have been // If the pointer is a pointer to constant memory, then it could not have been
// modified by this store. // modified by this store.
return pointsToConstantMemory(P) ? NoModRef : Mod; if (pointsToConstantMemory(P))
return NoModRef;
// Otherwise, a store just writes.
return Mod;
} }
AliasAnalysis::ModRefBehavior AliasAnalysis::ModRefBehavior