diff options
Diffstat (limited to 'include/llvm/Analysis/AliasAnalysis.h')
-rw-r--r-- | include/llvm/Analysis/AliasAnalysis.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 763f372988112..ac9d21c590a46 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -68,7 +68,7 @@ protected: /// typically called by the run* methods of these subclasses. This may be /// called multiple times. /// - void InitializeAliasAnalysis(Pass *P); + void InitializeAliasAnalysis(Pass *P, const DataLayout *DL); /// getAnalysisUsage - All alias analysis implementations should invoke this /// directly (using AliasAnalysis::getAnalysisUsage(AU)). @@ -84,11 +84,6 @@ public: /// know the sizes of the potential memory references. static uint64_t const UnknownSize = ~UINT64_C(0); - /// getDataLayout - Return a pointer to the current DataLayout object, or - /// null if no DataLayout object is available. - /// - const DataLayout *getDataLayout() const { return DL; } - /// getTargetLibraryInfo - Return a pointer to the current TargetLibraryInfo /// object, or null if no TargetLibraryInfo object is available. /// @@ -139,6 +134,10 @@ public: Copy.AATags = AAMDNodes(); return Copy; } + + bool operator==(const AliasAnalysis::Location &Other) const { + return Ptr == Other.Ptr && Size == Other.Size && AATags == Other.AATags; + } }; /// getLocation - Fill in Loc with information about the memory reference by @@ -150,6 +149,19 @@ public: Location getLocation(const AtomicRMWInst *RMWI); static Location getLocationForSource(const MemTransferInst *MTI); static Location getLocationForDest(const MemIntrinsic *MI); + Location getLocation(const Instruction *Inst) { + if (auto *I = dyn_cast<LoadInst>(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast<StoreInst>(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast<VAArgInst>(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast<AtomicCmpXchgInst>(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast<AtomicRMWInst>(Inst)) + return getLocation(I); + llvm_unreachable("unsupported memory instruction"); + } /// Alias analysis result - Either we know for sure that it does not alias, we /// know for sure it must alias, or we don't know anything: The two pointers @@ -357,6 +369,24 @@ public: return (MRB & ModRef) && (MRB & ArgumentPointees); } + /// getModRefInfo - Return information about whether or not an + /// instruction may read or write memory (without regard to a + /// specific location) + ModRefResult getModRefInfo(const Instruction *I) { + if (auto CS = ImmutableCallSite(I)) { + auto MRB = getModRefBehavior(CS); + if (MRB & ModRef) + return ModRef; + else if (MRB & Ref) + return Ref; + else if (MRB & Mod) + return Mod; + return NoModRef; + } + + return getModRefInfo(I, Location()); + } + /// getModRefInfo - Return information about whether or not an instruction may /// read or write the specified memory location. An instruction /// that doesn't read or write memory may be trivially LICM'd for example. @@ -477,6 +507,10 @@ public: ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){ return getModRefInfo(I, Location(P, Size)); } + /// getModRefInfo - Return information about whether a call and an instruction + /// may refer to the same memory locations. + ModRefResult getModRefInfo(Instruction *I, + ImmutableCallSite Call); /// getModRefInfo - Return information about whether two call sites may refer /// to the same set of memory locations. See @@ -585,9 +619,7 @@ struct DenseMapInfo<AliasAnalysis::Location> { } static bool isEqual(const AliasAnalysis::Location &LHS, const AliasAnalysis::Location &RHS) { - return LHS.Ptr == RHS.Ptr && - LHS.Size == RHS.Size && - LHS.AATags == RHS.AATags; + return LHS == RHS; } }; |