+ enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
+
+ /// getModRefInfo - Return information about whether or not an instruction may
+ /// read or write memory specified by the pointer operand. An instruction
+ /// that doesn't read or write memory may be trivially LICM'd for example.
+
+ /// getModRefInfo (for call sites) - Return whether information about whether
+ /// a particular call site modifies or reads the memory specified by the
+ /// pointer.
+ ///
+ virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) {
+ return ModRef;
+ }
+
+ /// getModRefInfo - Return information about whether two call sites may refer
+ /// to the same set of memory locations. This function returns NoModRef if
+ /// the two calls refer to disjoint memory locations, Ref if they both read
+ /// 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;
+ }
+
+ /// 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) {
+ return getModRefInfo(CallSite(C), P, Size);
+ }
+ ModRefResult getModRefInfo(InvokeInst*I, Value *P, unsigned Size) {
+ return getModRefInfo(CallSite(I), P, Size);
+ }
+ ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) {
+ switch (I->getOpcode()) {
+ case Instruction::Load: return getModRefInfo((LoadInst*)I, P, Size);
+ case Instruction::Store: return getModRefInfo((StoreInst*)I, P, Size);
+ case Instruction::Call: return getModRefInfo((CallInst*)I, P, Size);
+ case Instruction::Invoke: return getModRefInfo((InvokeInst*)I, P, Size);
+ default: return NoModRef;
+ }
+ }