summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-03 17:27:43 +0000
committerDan Gohman <gohman@apple.com>2010-08-03 17:27:43 +0000
commit14a498a48677eb1eaddd8329330df073224f9575 (patch)
tree355cf241a06355f4c6bf338c224c88c0d262da11 /lib/Analysis/AliasAnalysis.cpp
parentbae696956b74680a7fedafb7fea70628d1ef14df (diff)
downloadllvm-14a498a48677eb1eaddd8329330df073224f9575.tar.gz
llvm-14a498a48677eb1eaddd8329330df073224f9575.tar.bz2
llvm-14a498a48677eb1eaddd8329330df073224f9575.tar.xz
Make AliasAnalysis::getModRefInfo conservative in the face of volatility.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--lib/Analysis/AliasAnalysis.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp
index 503fbbdab8..60ea2b4ba9 100644
--- a/lib/Analysis/AliasAnalysis.cpp
+++ b/lib/Analysis/AliasAnalysis.cpp
@@ -78,8 +78,17 @@ AliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
AliasAnalysis::ModRefResult
AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) {
- return alias(L->getOperand(0), getTypeStoreSize(L->getType()),
- P, Size) ? Ref : NoModRef;
+ // If the load address doesn't alias the given address, it doesn't read
+ // 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
@@ -90,9 +99,17 @@ AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) {
getTypeStoreSize(S->getOperand(0)->getType()), P, Size))
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
// modified by this store.
- return pointsToConstantMemory(P) ? NoModRef : Mod;
+ if (pointsToConstantMemory(P))
+ return NoModRef;
+
+ // Otherwise, a store just writes.
+ return Mod;
}
AliasAnalysis::ModRefBehavior