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,17 +20,9 @@ #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 { @@ -38,13 +30,8 @@ class AssumptionCache; class BatchAAResults; 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 { @@ -344,7 +331,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. @@ -501,13 +488,13 @@ 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, BatchAAResults &BatchAA); - 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 @@ -717,7 +717,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, @@ -902,7 +902,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, BatchAAResults &BatchAA) { @@ -1228,9 +1228,8 @@ // 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, - Cache, NumSortedEntries, - BatchAA); + MemDepResult Dep = getNonLocalInfoForBlock( + QueryInst, Loc, isLoad, BB, Cache, NumSortedEntries, BatchAA); // If we got a Def or Clobber, add this to the list of results. if (!Dep.isNonLocal()) { @@ -1452,7 +1451,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. @@ -1501,9 +1500,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); } @@ -1515,13 +1514,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. @@ -1541,8 +1540,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. @@ -1605,7 +1604,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; @@ -1677,7 +1676,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)); } @@ -1698,7 +1697,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)