diff --git a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h --- a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -20,30 +20,17 @@ #include "llvm/ADT/PointerSumType.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Analysis/MemoryLocation.h" -#include "llvm/IR/BasicBlock.h" -#include "llvm/IR/Metadata.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/PredIteratorCache.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/Pass.h" -#include "llvm/Support/ErrorHandling.h" -#include -#include -#include -#include namespace llvm { class AAResults; class AssumptionCache; class DominatorTree; -class Function; -class Instruction; -class LoadInst; class PHITransAddr; -class TargetLibraryInfo; class PhiValues; -class Value; /// A memory dependence query can return one of three different answers. class MemDepResult { @@ -343,7 +330,7 @@ // A map from instructions to their non-local dependencies. using NonLocalDepMapType = DenseMap; - NonLocalDepMapType NonLocalDeps; + NonLocalDepMapType NonLocalDepsMap; // A reverse mapping from dependencies to the dependees. This is // used when removing instructions to keep the cache coherent. @@ -465,9 +452,6 @@ /// with the same queried instruction. MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB); - /// Release memory in caches. - void releaseMemory(); - private: MemDepResult getCallDependencyFrom(CallBase *Call, bool isReadOnlyCall, BasicBlock::iterator ScanIt, @@ -480,12 +464,12 @@ DenseMap &Visited, bool SkipFirstBlock = false, bool IsIncomplete = false); - MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst, + MemDepResult getNonLocalInfoForBlock(Instruction *QueryInst, const MemoryLocation &Loc, bool isLoad, BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries); - void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P); + void removeCachedNonLocalPointerDependencies(ValueIsLoadPair P); void verifyRemoved(Instruction *Inst) const; }; diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/llvm/include/llvm/Transforms/Scalar/GVN.h @@ -21,7 +21,6 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/InstructionPrecedenceTracking.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/PassManager.h" @@ -47,8 +46,11 @@ class IntrinsicInst; class LoadInst; class LoopInfo; +class MemDepResult; +class MemoryDependenceResults; class MemorySSA; class MemorySSAUpdater; +class NonLocalDepResult; class OptimizationRemarkEmitter; class PHINode; class TargetLibraryInfo; diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -713,7 +713,7 @@ assert(getDependency(QueryCall).isNonLocal() && "getNonLocalCallDependency should only be used on calls with " "non-local deps!"); - PerInstNLInfo &CacheP = NonLocalDeps[QueryCall]; + PerInstNLInfo &CacheP = NonLocalDepsMap[QueryCall]; NonLocalDepInfo &Cache = CacheP.first; // This is the set of blocks that need to be recomputed. In the cached case, @@ -898,7 +898,7 @@ /// info if available). /// /// If we do a lookup, add the result to the cache. -MemDepResult MemoryDependenceResults::GetNonLocalInfoForBlock( +MemDepResult MemoryDependenceResults::getNonLocalInfoForBlock( Instruction *QueryInst, const MemoryLocation &Loc, bool isLoad, BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries) { @@ -1222,7 +1222,7 @@ // Get the dependency info for Pointer in BB. If we have cached // information, we will use it, otherwise we compute it. LLVM_DEBUG(AssertSorted(*Cache, NumSortedEntries)); - MemDepResult Dep = GetNonLocalInfoForBlock(QueryInst, Loc, isLoad, BB, + MemDepResult Dep = getNonLocalInfoForBlock(QueryInst, Loc, isLoad, BB, Cache, NumSortedEntries); // If we got a Def or Clobber, add this to the list of results. @@ -1445,7 +1445,7 @@ } /// If P exists in CachedNonLocalPointerInfo or NonLocalDefsCache, remove it. -void MemoryDependenceResults::RemoveCachedNonLocalPointerDependencies( +void MemoryDependenceResults::removeCachedNonLocalPointerDependencies( ValueIsLoadPair P) { // Most of the time this cache is empty. @@ -1494,9 +1494,9 @@ if (!Ptr->getType()->isPointerTy()) return; // Flush store info for the pointer. - RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false)); + removeCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false)); // Flush load info for the pointer. - RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true)); + removeCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true)); // Invalidate phis that use the pointer. PV.invalidateValue(Ptr); } @@ -1508,13 +1508,13 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) { // Walk through the Non-local dependencies, removing this one as the value // for any cached queries. - NonLocalDepMapType::iterator NLDI = NonLocalDeps.find(RemInst); - if (NLDI != NonLocalDeps.end()) { + NonLocalDepMapType::iterator NLDI = NonLocalDepsMap.find(RemInst); + if (NLDI != NonLocalDepsMap.end()) { NonLocalDepInfo &BlockMap = NLDI->second.first; for (auto &Entry : BlockMap) if (Instruction *Inst = Entry.getResult().getInst()) RemoveFromReverseMap(ReverseNonLocalDeps, Inst, RemInst); - NonLocalDeps.erase(NLDI); + NonLocalDepsMap.erase(NLDI); } // If we have a cached local dependence query for this instruction, remove it. @@ -1534,8 +1534,8 @@ // If the instruction is a pointer, remove it from both the load info and the // store info. if (RemInst->getType()->isPointerTy()) { - RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false)); - RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true)); + removeCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false)); + removeCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true)); } else { // Otherwise, if the instructions is in the map directly, it must be a load. // Remove it. @@ -1598,7 +1598,7 @@ for (Instruction *I : ReverseDepIt->second) { assert(I != RemInst && "Already removed NonLocalDep info for RemInst"); - PerInstNLInfo &INLD = NonLocalDeps[I]; + PerInstNLInfo &INLD = NonLocalDepsMap[I]; // The information is now dirty! INLD.second = true; @@ -1670,7 +1670,7 @@ // Invalidate phis that use the removed instruction. PV.invalidateValue(RemInst); - assert(!NonLocalDeps.count(RemInst) && "RemInst got reinserted?"); + assert(!NonLocalDepsMap.count(RemInst) && "RemInst got reinserted?"); LLVM_DEBUG(verifyRemoved(RemInst)); } @@ -1691,7 +1691,7 @@ assert(Entry.getResult().getInst() != D && "Inst occurs as NLPD value"); } - for (const auto &DepKV : NonLocalDeps) { + for (const auto &DepKV : NonLocalDepsMap) { assert(DepKV.first != D && "Inst occurs in data structures"); const PerInstNLInfo &INLD = DepKV.second; for (const auto &Entry : INLD.first)