[PATCH] D65806: [MemDep] allow customization of block-scan-limit of MemoryDependenceAnalysis instance

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 07:10:19 PDT 2019


fedor.sergeev created this revision.
fedor.sergeev added reviewers: chandlerc, asbirlea, philip.pfaffe.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
fedor.sergeev added a child revision: D65805: [PassManager] add setupAnalysis() to customize analyses registered in AnalysisManager.

Introducing non-global control for default block-scan-limit in MemDep analysis.
Useful when there are many compilations per initialized LLVM instance (e.g. JIT).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65806

Files:
  llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
  llvm/lib/Analysis/MemoryDependenceAnalysis.cpp


Index: llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -183,7 +183,7 @@
 MemDepResult MemoryDependenceResults::getCallDependencyFrom(
     CallBase *Call, bool isReadOnlyCall, BasicBlock::iterator ScanIt,
     BasicBlock *BB) {
-  unsigned Limit = BlockScanLimit;
+  unsigned Limit = getDefaultBlockScanLimit();
 
   // Walk backwards through the block, looking for dependencies.
   while (ScanIt != BB->begin()) {
@@ -443,7 +443,7 @@
     OrderedBasicBlock *OBB) {
   bool isInvariantLoad = false;
 
-  unsigned DefaultLimit = BlockScanLimit;
+  unsigned DefaultLimit = getDefaultBlockScanLimit();
   if (!Limit)
     Limit = &DefaultLimit;
 
@@ -1746,6 +1746,12 @@
 
 AnalysisKey MemoryDependenceAnalysis::Key;
 
+MemoryDependenceAnalysis::MemoryDependenceAnalysis() : DefaultBlockScanLimit(BlockScanLimit) { }
+
+void MemoryDependenceAnalysis::setDefaultBlockScanLimit(unsigned DefaultBlockScanLimit) {
+  this->DefaultBlockScanLimit = DefaultBlockScanLimit;
+}
+
 MemoryDependenceResults
 MemoryDependenceAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
   auto &AA = AM.getResult<AAManager>(F);
@@ -1753,7 +1759,7 @@
   auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
   auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
   auto &PV = AM.getResult<PhiValuesAnalysis>(F);
-  return MemoryDependenceResults(AA, AC, TLI, DT, PV);
+  return MemoryDependenceResults(AA, AC, TLI, DT, PV, DefaultBlockScanLimit);
 }
 
 char MemoryDependenceWrapperPass::ID = 0;
@@ -1807,7 +1813,7 @@
 }
 
 unsigned MemoryDependenceResults::getDefaultBlockScanLimit() const {
-  return BlockScanLimit;
+  return DefaultBlockScanLimit;
 }
 
 bool MemoryDependenceWrapperPass::runOnFunction(Function &F) {
@@ -1816,6 +1822,6 @@
   auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   auto &PV = getAnalysis<PhiValuesWrapperPass>().getResult();
-  MemDep.emplace(AA, AC, TLI, DT, PV);
+  MemDep.emplace(AA, AC, TLI, DT, PV, BlockScanLimit);
   return false;
 }
Index: llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
===================================================================
--- llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
+++ llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
@@ -362,11 +362,14 @@
   PhiValues &PV;
   PredIteratorCache PredCache;
 
+  unsigned DefaultBlockScanLimit;
+
 public:
   MemoryDependenceResults(AliasAnalysis &AA, AssumptionCache &AC,
                           const TargetLibraryInfo &TLI,
-                          DominatorTree &DT, PhiValues &PV)
-      : AA(AA), AC(AC), TLI(TLI), DT(DT), PV(PV) {}
+                          DominatorTree &DT, PhiValues &PV,
+			  unsigned DefaultBlockScanLimit)
+    : AA(AA), AC(AC), TLI(TLI), DT(DT), PV(PV), DefaultBlockScanLimit(DefaultBlockScanLimit) {}
 
   /// Handle invalidation in the new PM.
   bool invalidate(Function &F, const PreservedAnalyses &PA,
@@ -511,9 +514,15 @@
 
   static AnalysisKey Key;
 
+  unsigned DefaultBlockScanLimit;
+
 public:
   using Result = MemoryDependenceResults;
 
+  MemoryDependenceAnalysis();
+
+  void setDefaultBlockScanLimit(unsigned DefaultBlockScanLimit);
+
   MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM);
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65806.213603.patch
Type: text/x-patch
Size: 3436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190806/a0aef736/attachment.bin>


More information about the llvm-commits mailing list