diff options
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 2fe012d3865..e22182b99e1 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -31,7 +31,6 @@ #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" @@ -182,8 +181,8 @@ static ModRefInfo GetLocation(const Instruction *Inst, MemoryLocation &Loc, } /// Private helper for finding the local dependencies of a call site. -MemDepResult MemoryDependenceResults::getCallSiteDependencyFrom( - CallSite CS, bool isReadOnlyCall, BasicBlock::iterator ScanIt, +MemDepResult MemoryDependenceResults::getCallDependencyFrom( + CallBase *Call, bool isReadOnlyCall, BasicBlock::iterator ScanIt, BasicBlock *BB) { unsigned Limit = BlockScanLimit; @@ -205,21 +204,21 @@ MemDepResult MemoryDependenceResults::getCallSiteDependencyFrom( ModRefInfo MR = GetLocation(Inst, Loc, TLI); if (Loc.Ptr) { // A simple instruction. - if (isModOrRefSet(AA.getModRefInfo(CS, Loc))) + if (isModOrRefSet(AA.getModRefInfo(Call, Loc))) return MemDepResult::getClobber(Inst); continue; } - if (auto InstCS = CallSite(Inst)) { + if (auto *CallB = dyn_cast<CallBase>(Inst)) { // If these two calls do not interfere, look past it. - if (isNoModRef(AA.getModRefInfo(CS, InstCS))) { - // If the two calls are the same, return InstCS as a Def, so that - // CS can be found redundant and eliminated. + if (isNoModRef(AA.getModRefInfo(Call, CallB))) { + // If the two calls are the same, return Inst as a Def, so that + // Call can be found redundant and eliminated. if (isReadOnlyCall && !isModSet(MR) && - CS.getInstruction()->isIdenticalToWhenDefined(Inst)) + Call->isIdenticalToWhenDefined(CallB)) return MemDepResult::getDef(Inst); - // Otherwise if the two calls don't interact (e.g. InstCS is readnone) + // Otherwise if the two calls don't interact (e.g. CallB is readnone) // keep scanning. continue; } else @@ -750,11 +749,10 @@ MemDepResult MemoryDependenceResults::getDependency(Instruction *QueryInst) { LocalCache = getPointerDependencyFrom( MemLoc, isLoad, ScanPos->getIterator(), QueryParent, QueryInst); - } else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)) { - CallSite QueryCS(QueryInst); - bool isReadOnly = AA.onlyReadsMemory(QueryCS); - LocalCache = getCallSiteDependencyFrom( - QueryCS, isReadOnly, ScanPos->getIterator(), QueryParent); + } else if (auto *QueryCall = dyn_cast<CallBase>(QueryInst)) { + bool isReadOnly = AA.onlyReadsMemory(QueryCall); + LocalCache = getCallDependencyFrom(QueryCall, isReadOnly, + ScanPos->getIterator(), QueryParent); } else // Non-memory instruction. LocalCache = MemDepResult::getUnknown(); @@ -780,11 +778,11 @@ static void AssertSorted(MemoryDependenceResults::NonLocalDepInfo &Cache, #endif const MemoryDependenceResults::NonLocalDepInfo & -MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { - assert(getDependency(QueryCS.getInstruction()).isNonLocal() && +MemoryDependenceResults::getNonLocalCallDependency(CallBase *QueryCall) { + assert(getDependency(QueryCall).isNonLocal() && "getNonLocalCallDependency should only be used on calls with " "non-local deps!"); - PerInstNLInfo &CacheP = NonLocalDeps[QueryCS.getInstruction()]; + PerInstNLInfo &CacheP = NonLocalDeps[QueryCall]; NonLocalDepInfo &Cache = CacheP.first; // This is the set of blocks that need to be recomputed. In the cached case, @@ -814,14 +812,14 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { // << Cache.size() << " cached: " << *QueryInst; } else { // Seed DirtyBlocks with each of the preds of QueryInst's block. - BasicBlock *QueryBB = QueryCS.getInstruction()->getParent(); + BasicBlock *QueryBB = QueryCall->getParent(); for (BasicBlock *Pred : PredCache.get(QueryBB)) DirtyBlocks.push_back(Pred); ++NumUncacheNonLocal; } // isReadonlyCall - If this is a read-only call, we can be more aggressive. - bool isReadonlyCall = AA.onlyReadsMemory(QueryCS); + bool isReadonlyCall = AA.onlyReadsMemory(QueryCall); SmallPtrSet<BasicBlock *, 32> Visited; @@ -865,8 +863,8 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { if (Instruction *Inst = ExistingResult->getResult().getInst()) { ScanPos = Inst->getIterator(); // We're removing QueryInst's use of Inst. - RemoveFromReverseMap(ReverseNonLocalDeps, Inst, - QueryCS.getInstruction()); + RemoveFromReverseMap<Instruction *>(ReverseNonLocalDeps, Inst, + QueryCall); } } @@ -874,8 +872,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { MemDepResult Dep; if (ScanPos != DirtyBB->begin()) { - Dep = - getCallSiteDependencyFrom(QueryCS, isReadonlyCall, ScanPos, DirtyBB); + Dep = getCallDependencyFrom(QueryCall, isReadonlyCall, ScanPos, DirtyBB); } else if (DirtyBB != &DirtyBB->getParent()->getEntryBlock()) { // No dependence found. If this is the entry block of the function, it is // a clobber, otherwise it is unknown. @@ -897,7 +894,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { // Keep the ReverseNonLocalDeps map up to date so we can efficiently // update this when we remove instructions. if (Instruction *Inst = Dep.getInst()) - ReverseNonLocalDeps[Inst].insert(QueryCS.getInstruction()); + ReverseNonLocalDeps[Inst].insert(QueryCall); } else { // If the block *is* completely transparent to the load, we need to check |