[PATCH] D56381: [DA][NewPM] Handle transitive dependencies in the new-pm version of DA

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 7 03:17:18 PST 2019


philip.pfaffe created this revision.
philip.pfaffe added reviewers: chandlerc, dmgreen, bogner.
Herald added subscribers: javed.absar, bollu, hiraditya.

The analysis result of DA caches pointers to AA, SCEV, and LI, but it
never checks for their invalidation. Fix that.


https://reviews.llvm.org/D56381

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


Index: llvm/lib/Analysis/DependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/DependenceAnalysis.cpp
+++ llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3362,6 +3362,19 @@
 }
 #endif
 
+bool DependenceInfo::invalidate(Function &F, const PreservedAnalyses &PA,
+                                FunctionAnalysisManager::Invalidator &Inv) {
+  // Check if the analysis itself has been invalidated.
+  auto PAC = PA.getChecker<DependenceAnalysis>();
+  if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>())
+    return true;
+
+  // Check transitive dependencies.
+  return Inv.invalidate<AAManager>(F, PA) ||
+         Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) ||
+         Inv.invalidate<LoopAnalysis>(F, PA);
+}
+
 // depends -
 // Returns NULL if there is no dependence.
 // Otherwise, return a Dependence with as many details as possible.
Index: llvm/include/llvm/Analysis/DependenceAnalysis.h
===================================================================
--- llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -275,6 +275,10 @@
                    LoopInfo *LI)
         : AA(AA), SE(SE), LI(LI), F(F) {}
 
+    /// Handle transitive invalidation when the cached analysis results go away.
+    bool invalidate(Function &F, const PreservedAnalyses &PA,
+                    FunctionAnalysisManager::Invalidator &Inv);
+
     /// depends - Tests for a dependence between the Src and Dst instructions.
     /// Returns NULL if no dependence; otherwise, returns a Dependence (or a
     /// FullDependence) with as much information as can be gleaned.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56381.180449.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190107/0f862477/attachment.bin>


More information about the llvm-commits mailing list