Add a new pointsToConstantMemory method to the AliasAnalysis interface
authorChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2004 22:15:41 +0000 (22:15 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2004 22:15:41 +0000 (22:15 +0000)
which can be implemented to improve the quality of mod-ref information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11020 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/AliasAnalysis.h

index b0e9b23ab18b81ccd1c7f885bcea06bd15521b58..9b5d8ff037f2efa812c33d6a8410b0b6ce1084d9 100644 (file)
@@ -95,6 +95,11 @@ public:
   ///
   virtual void getMustAliases(Value *P, std::vector<Value*> &RetVals) {}
 
+  /// pointsToConstantMemory - If the specified pointer is known to point into
+  /// constant global memory, return true.  This allows disambiguation of store
+  /// instructions from constant pointers.
+  ///
+  virtual bool pointsToConstantMemory(const Value *P) { return false; }
 
   //===--------------------------------------------------------------------===//
   /// Simple mod/ref information...
@@ -114,7 +119,9 @@ public:
   /// pointer.
   ///
   virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) {
-    return ModRef;
+    // If P points to a constant memory location, the call definitely could not
+    // modify the memory location.
+    return pointsToConstantMemory(P) ? Ref : ModRef;
   }
 
   /// getModRefInfo - Return information about whether two call sites may refer