Add a const.
[oota-llvm.git] / lib / Analysis / AliasAnalysis.cpp
index 16131cbc11d068e2c8b77e78eeb7eac58c935335..1f2528fa560f24614ecb298b0f15c114f92c7223 100644 (file)
@@ -195,31 +195,31 @@ AliasAnalysis::getModRefBehavior(const Function *F) {
 
 AliasAnalysis::ModRefResult
 AliasAnalysis::getModRefInfo(const LoadInst *L, const Value *P, unsigned Size) {
+  // Be conservative in the face of volatile.
+  if (L->isVolatile())
+    return ModRef;
+
   // 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
 AliasAnalysis::getModRefInfo(const StoreInst *S, const Value *P, unsigned Size) {
-  // If the stored address cannot alias the pointer in question, then the
-  // pointer cannot be modified by the store.
-  if (!alias(S->getOperand(1),
-             getTypeStoreSize(S->getOperand(0)->getType()), P, Size))
-    return NoModRef;
-
   // Be conservative in the face of volatile.
   if (S->isVolatile())
     return ModRef;
 
+  // If the store address cannot alias the pointer in question, then the
+  // specified memory cannot be modified by the store.
+  if (!alias(S->getOperand(1),
+             getTypeStoreSize(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.
   if (pointsToConstantMemory(P))
@@ -229,6 +229,23 @@ AliasAnalysis::getModRefInfo(const StoreInst *S, const Value *P, unsigned Size)
   return Mod;
 }
 
+AliasAnalysis::ModRefResult
+AliasAnalysis::getModRefInfo(const VAArgInst *V, const Value *P, unsigned Size) {
+  // If the va_arg address cannot alias the pointer in question, then the
+  // specified memory cannot be accessed by the va_arg.
+  if (!alias(V->getOperand(0), UnknownSize, P, Size))
+    return NoModRef;
+
+  // If the pointer is a pointer to constant memory, then it could not have been
+  // modified by this va_arg.
+  if (pointsToConstantMemory(P))
+    return NoModRef;
+
+  // Otherwise, a va_arg reads and writes.
+  return ModRef;
+}
+
+
 AliasAnalysis::ModRefBehavior
 AliasAnalysis::getIntrinsicModRefBehavior(unsigned iid) {
 #define GET_INTRINSIC_MODREF_BEHAVIOR