X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FAliasAnalysis.h;h=ef31e1fdc45a4b90a1c5409cc61a12b0a31beafb;hb=5cb66e24d42b40d087989199297c369b3f3b2766;hp=fb848ebd570c8a9a672097a378ce364a3e2ca473;hpb=dd298c8c6eb036baf35bf5a559c59d2afd2c7944;p=oota-llvm.git diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index fb848ebd570..ef31e1fdc45 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -100,6 +100,29 @@ public: /// 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... /// @@ -117,11 +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) { - // If P points to a constant memory location, the call definitely could not - // modify the memory location. - return pointsToConstantMemory(P) ? Ref : 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 @@ -129,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) {