diff options
-rw-r--r-- | lib/Analysis/AliasAnalysis.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index c881ec283a..373524b6c1 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -44,8 +44,15 @@ AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) { AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) { - return alias(S->getOperand(1), TD->getTypeSize(S->getOperand(0)->getType()), - P, Size) ? Mod : NoModRef; + // If the stored address cannot alias the pointer in question, then the + // pointer cannot be modified by the store. + if (!alias(S->getOperand(1), TD->getTypeSize(S->getOperand(0)->getType()), + P, Size)) + return NoModRef; + + // If the pointer is a pointer to constant memory, then it could not have been + // modified by this store. + return pointsToConstantMemory(P) ? NoModRef : Mod; } |