mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[MemDep] Use BatchAA in more places (NFCI)
Previously, we already used BatchAA for individual simple pointer dependency queries. This extends BatchAA usage for the non-local case, so that only one BatchAA instance is used for all blocks, instead of one instance per block. Use of BatchAA is safe as IR cannot be modified during a MemDep query.
This commit is contained in:
parent
59c3841e00
commit
139205b421
@ -36,6 +36,7 @@ namespace llvm {
|
||||
|
||||
class AAResults;
|
||||
class AssumptionCache;
|
||||
class BatchAAResults;
|
||||
class DominatorTree;
|
||||
class Function;
|
||||
class Instruction;
|
||||
@ -456,10 +457,18 @@ public:
|
||||
Instruction *QueryInst = nullptr,
|
||||
unsigned *Limit = nullptr);
|
||||
|
||||
MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad,
|
||||
BasicBlock::iterator ScanIt,
|
||||
BasicBlock *BB,
|
||||
Instruction *QueryInst,
|
||||
unsigned *Limit,
|
||||
BatchAAResults &BatchAA);
|
||||
|
||||
MemDepResult
|
||||
getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad,
|
||||
BasicBlock::iterator ScanIt, BasicBlock *BB,
|
||||
Instruction *QueryInst, unsigned *Limit);
|
||||
Instruction *QueryInst, unsigned *Limit,
|
||||
BatchAAResults &BatchAA);
|
||||
|
||||
/// This analysis looks for other loads and stores with invariant.group
|
||||
/// metadata and the same pointer operand. Returns Unknown if it does not
|
||||
@ -495,7 +504,8 @@ private:
|
||||
MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst,
|
||||
const MemoryLocation &Loc, bool isLoad,
|
||||
BasicBlock *BB, NonLocalDepInfo *Cache,
|
||||
unsigned NumSortedEntries);
|
||||
unsigned NumSortedEntries,
|
||||
BatchAAResults &BatchAA);
|
||||
|
||||
void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);
|
||||
|
||||
|
@ -245,7 +245,8 @@ MemDepResult MemoryDependenceResults::getCallDependencyFrom(
|
||||
|
||||
MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
|
||||
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
|
||||
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
|
||||
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit,
|
||||
BatchAAResults &BatchAA) {
|
||||
MemDepResult InvariantGroupDependency = MemDepResult::getUnknown();
|
||||
if (QueryInst != nullptr) {
|
||||
if (auto *LI = dyn_cast<LoadInst>(QueryInst)) {
|
||||
@ -256,7 +257,7 @@ MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
|
||||
}
|
||||
}
|
||||
MemDepResult SimpleDep = getSimplePointerDependencyFrom(
|
||||
MemLoc, isLoad, ScanIt, BB, QueryInst, Limit);
|
||||
MemLoc, isLoad, ScanIt, BB, QueryInst, Limit, BatchAA);
|
||||
if (SimpleDep.isDef())
|
||||
return SimpleDep;
|
||||
// Non-local invariant group dependency indicates there is non local Def
|
||||
@ -270,6 +271,14 @@ MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
|
||||
return SimpleDep;
|
||||
}
|
||||
|
||||
MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
|
||||
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
|
||||
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
|
||||
BatchAAResults BatchAA(AA);
|
||||
return getPointerDependencyFrom(MemLoc, isLoad, ScanIt, BB, QueryInst, Limit,
|
||||
BatchAA);
|
||||
}
|
||||
|
||||
MemDepResult
|
||||
MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
|
||||
BasicBlock *BB) {
|
||||
@ -359,9 +368,8 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
|
||||
|
||||
MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
|
||||
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
|
||||
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
|
||||
// We can batch AA queries, because IR does not change during a MemDep query.
|
||||
BatchAAResults BatchAA(AA);
|
||||
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit,
|
||||
BatchAAResults &BatchAA) {
|
||||
bool isInvariantLoad = false;
|
||||
|
||||
unsigned DefaultLimit = getDefaultBlockScanLimit();
|
||||
@ -896,7 +904,8 @@ void MemoryDependenceResults::getNonLocalPointerDependency(
|
||||
/// If we do a lookup, add the result to the cache.
|
||||
MemDepResult MemoryDependenceResults::GetNonLocalInfoForBlock(
|
||||
Instruction *QueryInst, const MemoryLocation &Loc, bool isLoad,
|
||||
BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries) {
|
||||
BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries,
|
||||
BatchAAResults &BatchAA) {
|
||||
|
||||
bool isInvariantLoad = false;
|
||||
|
||||
@ -946,8 +955,8 @@ MemDepResult MemoryDependenceResults::GetNonLocalInfoForBlock(
|
||||
}
|
||||
|
||||
// Scan the block for the dependency.
|
||||
MemDepResult Dep =
|
||||
getPointerDependencyFrom(Loc, isLoad, ScanPos, BB, QueryInst);
|
||||
MemDepResult Dep = getPointerDependencyFrom(Loc, isLoad, ScanPos, BB,
|
||||
QueryInst, nullptr, BatchAA);
|
||||
|
||||
// Don't cache results for invariant load.
|
||||
if (isInvariantLoad)
|
||||
@ -1188,6 +1197,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
|
||||
bool GotWorklistLimit = false;
|
||||
LLVM_DEBUG(AssertSorted(*Cache));
|
||||
|
||||
BatchAAResults BatchAA(AA);
|
||||
while (!Worklist.empty()) {
|
||||
BasicBlock *BB = Worklist.pop_back_val();
|
||||
|
||||
@ -1219,7 +1229,8 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
|
||||
// information, we will use it, otherwise we compute it.
|
||||
LLVM_DEBUG(AssertSorted(*Cache, NumSortedEntries));
|
||||
MemDepResult Dep = GetNonLocalInfoForBlock(QueryInst, Loc, isLoad, BB,
|
||||
Cache, NumSortedEntries);
|
||||
Cache, NumSortedEntries,
|
||||
BatchAA);
|
||||
|
||||
// If we got a Def or Clobber, add this to the list of results.
|
||||
if (!Dep.isNonLocal()) {
|
||||
|
Loading…
Reference in New Issue
Block a user