Deinline a couple of methods. Improve comment.
[oota-llvm.git] / include / llvm / Analysis / AliasAnalysis.h
index f115894bc5aa9c2bb3c9dd11a9d46738b4fbb9df..ef31e1fdc45a4b90a1c5409cc61a12b0a31beafb 100644 (file)
@@ -1,4 +1,11 @@
 //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file defines the generic AliasAnalysis interface, which is used as the
 // common interface used by all clients of alias analysis information, and
 #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
 
 #include "llvm/Support/CallSite.h"
+#include "llvm/Pass.h"    // Need this for IncludeFile
+
+namespace llvm {
+
 class LoadInst;
 class StoreInst;
 class TargetData;
-class AnalysisUsage;
-class Pass;
 
 class AliasAnalysis {
   const TargetData *TD;
@@ -52,6 +61,7 @@ public:
   /// getTargetData - Every alias analysis implementation depends on the size of
   /// data items in the current Target.  This provides a uniform way to handle
   /// it.
+  ///
   const TargetData &getTargetData() const { return *TD; }
 
   //===--------------------------------------------------------------------===//
@@ -84,6 +94,34 @@ 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; }
+
+  /// doesNotAccessMemory - If the specified function is known to never read or
+  /// write memory, return true.  If the function only reads from known-constant
+  /// memory, it is also legal to return true.
+  ///
+  /// Many optimizations (such as CSE and LICM) can be performed on calls to it,
+  /// without worrying about aliasing properties, and many functions have this
+  /// property (e.g. 'sin' and 'cos').
+  ///
+  /// This property corresponds to the GCC 'const' attribute.
+  ///
+  virtual bool doesNotAccessMemory(Function *F) { return false; }
+
+  /// onlyReadsMemory - If the specified function is known to only read from
+  /// non-volatile memory (or not access memory at all), return true.
+  ///
+  /// This property allows many common optimizations to be performed in the
+  /// absence of interfering store instructions, such as CSE of strlen calls.
+  ///
+  /// This property corresponds to the GCC 'pure' attribute.
+  ///
+  virtual bool onlyReadsMemory(Function *F) { return doesNotAccessMemory(F); }
+
 
   //===--------------------------------------------------------------------===//
   /// Simple mod/ref information...
@@ -102,9 +140,7 @@ public:
   /// a particular call site modifies or reads the memory specified by the
   /// pointer.
   ///
-  virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) {
-    return ModRef;
-  }
+  virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
 
   /// getModRefInfo - Return information about whether two call sites may refer
   /// to the same set of memory locations.  This function returns NoModRef if
@@ -112,17 +148,15 @@ public:
   /// some of the same memory, Mod if they both write to some of the same
   /// memory, and ModRef if they read and write to the same memory.
   ///
-  virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
-    return ModRef;
-  }
+  virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
 
   /// Convenience functions...
   ModRefResult getModRefInfo(LoadInst *L, Value *P, unsigned Size);
-  ModRefResult getModRefInfo(StoreInst*S, Value *P, unsigned Size);
-  ModRefResult getModRefInfo(CallInst  *C, Value *P, unsigned Size) {
+  ModRefResult getModRefInfo(StoreInst *S, Value *P, unsigned Size);
+  ModRefResult getModRefInfo(CallInst *C, Value *P, unsigned Size) {
     return getModRefInfo(CallSite(C), P, Size);
   }
-  ModRefResult getModRefInfo(InvokeInst*I, Value *P, unsigned Size) {
+  ModRefResult getModRefInfo(InvokeInst *I, Value *P, unsigned Size) {
     return getModRefInfo(CallSite(I), P, Size);
   }
   ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) {
@@ -149,4 +183,14 @@ public:
                                  const Value *Ptr, unsigned Size);
 };
 
+// Because of the way .a files work, we must force the BasicAA implementation to
+// be pulled in if the AliasAnalysis header is included.  Otherwise we run
+// the risk of AliasAnalysis being used, but the default implementation not
+// being linked into the tool that uses it.
+//
+extern void BasicAAStub();
+static IncludeFile HDR_INCLUDE_BASICAA_CPP((void*)&BasicAAStub);
+
+} // End llvm namespace
+
 #endif