[llvm-commits] [llvm] r110120 - /llvm/trunk/lib/Analysis/AliasAnalysis.cpp

Dan Gohman gohman at apple.com
Tue Aug 3 10:27:43 PDT 2010


Author: djg
Date: Tue Aug  3 12:27:43 2010
New Revision: 110120

URL: http://llvm.org/viewvc/llvm-project?rev=110120&view=rev
Log:
Make AliasAnalysis::getModRefInfo conservative in the face of volatility.

Modified:
    llvm/trunk/lib/Analysis/AliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=110120&r1=110119&r2=110120&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Tue Aug  3 12:27:43 2010
@@ -78,8 +78,17 @@
 
 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 @@
              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





More information about the llvm-commits mailing list