#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 <cassert>
-#include <cstdint>
-#include <utility>
-#include <vector>
namespace llvm {
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 {
// A map from instructions to their non-local dependencies.
using NonLocalDepMapType = DenseMap<Instruction *, PerInstNLInfo>;
- NonLocalDepMapType NonLocalDeps;
+ NonLocalDepMapType NonLocalDepsMap;
// A reverse mapping from dependencies to the dependees. This is
// used when removing instructions to keep the cache coherent.
DenseMap<BasicBlock *, Value *> &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;
};
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,
/// 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) {
// 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()) {
}
/// 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.
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);
}
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.
// 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.
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;
// 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));
}
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)