diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-03 21:48:53 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-03 21:48:53 +0000 |
commit | 79fca6fea87be7221843031870bbf2c9ae1fc555 (patch) | |
tree | 54e9443ce805156c7af23377014de5e5526c8d35 /include | |
parent | d1fb583128c6682bb8a7c74eafa810a9270cc8df (diff) |
Thread const correctness through a bunch of AliasAnalysis interfaces and
eliminate several const_casts.
Make CallSite implicitly convertible to ImmutableCallSite.
Rename the getModRefBehavior for intrinsic IDs to
getIntrinsicModRefBehavior to avoid overload ambiguity with CallSite,
which happens to be implicitly convertible to bool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/AliasAnalysis.h | 53 | ||||
-rw-r--r-- | include/llvm/Analysis/LibCallAliasAnalysis.h | 11 | ||||
-rw-r--r-- | include/llvm/Analysis/LibCallSemantics.h | 5 | ||||
-rw-r--r-- | include/llvm/Support/CallSite.h | 21 |
4 files changed, 50 insertions, 40 deletions
diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index fbfdda5349..178049f554 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -178,17 +178,17 @@ public: }; /// getModRefBehavior - Return the behavior when calling the given call site. - virtual ModRefBehavior getModRefBehavior(CallSite CS, + virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS, std::vector<PointerAccessInfo> *Info = 0); /// getModRefBehavior - Return the behavior when calling the given function. /// For use when the call site is not known. - virtual ModRefBehavior getModRefBehavior(Function *F, + virtual ModRefBehavior getModRefBehavior(const Function *F, std::vector<PointerAccessInfo> *Info = 0); - /// getModRefBehavior - Return the modref behavior of the intrinsic with the - /// given id. - static ModRefBehavior getModRefBehavior(unsigned iid); + /// getIntrinsicModRefBehavior - Return the modref behavior of the intrinsic + /// with the given id. + static ModRefBehavior getIntrinsicModRefBehavior(unsigned iid); /// doesNotAccessMemory - If the specified call is known to never read or /// write memory, return true. If the call only reads from known-constant @@ -201,14 +201,14 @@ public: /// /// This property corresponds to the GCC 'const' attribute. /// - bool doesNotAccessMemory(CallSite CS) { + bool doesNotAccessMemory(ImmutableCallSite CS) { return getModRefBehavior(CS) == DoesNotAccessMemory; } /// doesNotAccessMemory - If the specified function is known to never read or /// write memory, return true. For use when the call site is not known. /// - bool doesNotAccessMemory(Function *F) { + bool doesNotAccessMemory(const Function *F) { return getModRefBehavior(F) == DoesNotAccessMemory; } @@ -221,7 +221,7 @@ public: /// /// This property corresponds to the GCC 'pure' attribute. /// - bool onlyReadsMemory(CallSite CS) { + bool onlyReadsMemory(ImmutableCallSite CS) { ModRefBehavior MRB = getModRefBehavior(CS); return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory; } @@ -230,7 +230,7 @@ public: /// non-volatile memory (or not access memory at all), return true. For use /// when the call site is not known. /// - bool onlyReadsMemory(Function *F) { + bool onlyReadsMemory(const Function *F) { ModRefBehavior MRB = getModRefBehavior(F); return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory; } @@ -244,7 +244,8 @@ public: /// a particular call site modifies or reads the memory specified by the /// pointer. /// - virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + virtual ModRefResult getModRefInfo(ImmutableCallSite CS, + const 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 @@ -252,28 +253,32 @@ public: /// written by CS2, Mod if CS1 writes to memory read or written by CS2, or /// ModRef if CS1 might read or write memory accessed by CS2. /// - virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); + virtual ModRefResult getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2); public: /// 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(const LoadInst *L, const Value *P, unsigned Size); + ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size); + ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) { + return getModRefInfo(ImmutableCallSite(C), P, Size); } - ModRefResult getModRefInfo(InvokeInst *I, Value *P, unsigned Size) { - return getModRefInfo(CallSite(I), P, Size); + ModRefResult getModRefInfo(const InvokeInst *I, + const Value *P, unsigned Size) { + return getModRefInfo(ImmutableCallSite(I), P, Size); } - ModRefResult getModRefInfo(VAArgInst* I, Value* P, unsigned Size) { + ModRefResult getModRefInfo(const VAArgInst* I, + const Value* P, unsigned Size) { return AliasAnalysis::ModRef; } - ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) { + ModRefResult getModRefInfo(const Instruction *I, + const Value *P, unsigned Size) { switch (I->getOpcode()) { - case Instruction::VAArg: return getModRefInfo((VAArgInst*)I, P, Size); - 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); + case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, P,Size); + case Instruction::Load: return getModRefInfo((const LoadInst*)I, P, Size); + case Instruction::Store: return getModRefInfo((const StoreInst*)I, P,Size); + case Instruction::Call: return getModRefInfo((const CallInst*)I, P, Size); + case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,P,Size); default: return NoModRef; } } diff --git a/include/llvm/Analysis/LibCallAliasAnalysis.h b/include/llvm/Analysis/LibCallAliasAnalysis.h index c256230fc5..37abb77dc2 100644 --- a/include/llvm/Analysis/LibCallAliasAnalysis.h +++ b/include/llvm/Analysis/LibCallAliasAnalysis.h @@ -35,11 +35,13 @@ namespace llvm { } ~LibCallAliasAnalysis(); - ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + ModRefResult getModRefInfo(ImmutableCallSite CS, + const Value *P, unsigned Size); - ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) { + ModRefResult getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { // TODO: Could compare two direct calls against each other if we cared to. - return AliasAnalysis::getModRefInfo(CS1,CS2); + return AliasAnalysis::getModRefInfo(CS1, CS2); } virtual void getAnalysisUsage(AnalysisUsage &AU) const; @@ -61,7 +63,8 @@ namespace llvm { private: ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, - CallSite CS, Value *P, unsigned Size); + ImmutableCallSite CS, + const Value *P, unsigned Size); }; } // End of llvm namespace diff --git a/include/llvm/Analysis/LibCallSemantics.h b/include/llvm/Analysis/LibCallSemantics.h index 74e8401a1f..31d7cc56ce 100644 --- a/include/llvm/Analysis/LibCallSemantics.h +++ b/include/llvm/Analysis/LibCallSemantics.h @@ -47,7 +47,8 @@ namespace llvm { enum LocResult { Yes, No, Unknown }; - LocResult (*isLocation)(CallSite CS, const Value *Ptr, unsigned Size); + LocResult (*isLocation)(ImmutableCallSite CS, + const Value *Ptr, unsigned Size); }; /// LibCallFunctionInfo - Each record in the array of FunctionInfo structs @@ -142,7 +143,7 @@ namespace llvm { /// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to /// the specified function if we have it. If not, return null. - const LibCallFunctionInfo *getFunctionInfo(Function *F) const; + const LibCallFunctionInfo *getFunctionInfo(const Function *F) const; //===------------------------------------------------------------------===// diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index d66e3cb6e4..5c6632bdf3 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -271,16 +271,6 @@ private: } }; -/// ImmutableCallSite - establish a view to a call site for examination -class ImmutableCallSite : public CallSiteBase<> { - typedef CallSiteBase<> Base; -public: - ImmutableCallSite(const Value* V) : Base(V) {} - ImmutableCallSite(const CallInst *CI) : Base(CI) {} - ImmutableCallSite(const InvokeInst *II) : Base(II) {} - ImmutableCallSite(const Instruction *II) : Base(II) {} -}; - class CallSite : public CallSiteBase<Function, Value, User, Instruction, CallInst, InvokeInst, User::op_iterator> { typedef CallSiteBase<Function, Value, User, Instruction, @@ -313,6 +303,17 @@ private: User::op_iterator getCallee() const; }; +/// ImmutableCallSite - establish a view to a call site for examination +class ImmutableCallSite : public CallSiteBase<> { + typedef CallSiteBase<> Base; +public: + ImmutableCallSite(const Value* V) : Base(V) {} + ImmutableCallSite(const CallInst *CI) : Base(CI) {} + ImmutableCallSite(const InvokeInst *II) : Base(II) {} + ImmutableCallSite(const Instruction *II) : Base(II) {} + ImmutableCallSite(CallSite CS) : Base(CS.getInstruction()) {} +}; + } // End llvm namespace #endif |