[llvm] c4fb2a1 - [MemDep] Use BatchAA in more places (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 14 14:04:40 PDT 2021
Author: Nikita Popov
Date: 2021-05-14T22:54:40+02:00
New Revision: c4fb2a1fc2d8009cd67e69c8db0db7120389a757
URL: https://github.com/llvm/llvm-project/commit/c4fb2a1fc2d8009cd67e69c8db0db7120389a757
DIFF: https://github.com/llvm/llvm-project/commit/c4fb2a1fc2d8009cd67e69c8db0db7120389a757.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
index b33e50d9576d..ee91fa1c4136 100644
--- a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
@@ -36,6 +36,7 @@ namespace llvm {
class AAResults;
class AssumptionCache;
+class BatchAAResults;
class DominatorTree;
class Function;
class Instruction;
@@ -456,10 +457,18 @@ class MemoryDependenceResults {
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 @@ class MemoryDependenceResults {
MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst,
const MemoryLocation &Loc, bool isLoad,
BasicBlock *BB, NonLocalDepInfo *Cache,
- unsigned NumSortedEntries);
+ unsigned NumSortedEntries,
+ BatchAAResults &BatchAA);
void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 5f46db204fba..312f67e6f83d 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -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()) {
More information about the llvm-commits
mailing list