From: Philip Pfaffe Date: Sun, 3 Feb 2019 12:25:41 +0000 (+0000) Subject: [DA][NewPM] Handle transitive dependencies in the new-pm version of DA X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4795197268330b7e0f01ec3a9d7c52d78d170e2;p=llvm [DA][NewPM] Handle transitive dependencies in the new-pm version of DA Summary: The analysis result of DA caches pointers to AA, SCEV, and LI, but it never checks for their invalidation. Fix that. Reviewers: chandlerc, dmgreen, bogner Reviewed By: dmgreen Subscribers: hiraditya, bollu, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D56381 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352986 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/DependenceAnalysis.h b/include/llvm/Analysis/DependenceAnalysis.h index 537d718bcc9..997013a5fc8 100644 --- a/include/llvm/Analysis/DependenceAnalysis.h +++ b/include/llvm/Analysis/DependenceAnalysis.h @@ -274,6 +274,10 @@ template class ArrayRef; 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. diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp index 9b02df49ca1..8337b9b96ea 100644 --- a/lib/Analysis/DependenceAnalysis.cpp +++ b/lib/Analysis/DependenceAnalysis.cpp @@ -3368,6 +3368,19 @@ static void dumpSmallBitVector(SmallBitVector &BV) { } #endif +bool DependenceInfo::invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &Inv) { + // Check if the analysis itself has been invalidated. + auto PAC = PA.getChecker(); + if (!PAC.preserved() && !PAC.preservedSet>()) + return true; + + // Check transitive dependencies. + return Inv.invalidate(F, PA) || + Inv.invalidate(F, PA) || + Inv.invalidate(F, PA); +} + // depends - // Returns NULL if there is no dependence. // Otherwise, return a Dependence with as many details as possible. diff --git a/test/Analysis/DependenceAnalysis/new-pm-invalidation.ll b/test/Analysis/DependenceAnalysis/new-pm-invalidation.ll new file mode 100644 index 00000000000..c6af10b19c5 --- /dev/null +++ b/test/Analysis/DependenceAnalysis/new-pm-invalidation.ll @@ -0,0 +1,16 @@ +; RUN: opt < %s -passes='require,invalidate,print' \ +; RUN: -disable-output -debug-pass-manager 2>&1 | FileCheck %s + +; CHECK: Running analysis: DependenceAnalysis on test_no_noalias +; CHECK: Running analysis: ScalarEvolutionAnalysis on test_no_noalias +; CHECK: Invalidating analysis: ScalarEvolutionAnalysis on test_no_noalias +; CHECK: Invalidating analysis: DependenceAnalysis on test_no_noalias +; CHECK: Running analysis: DependenceAnalysis on test_no_noalias +; CHECK: da analyze - none! +; CHECK: da analyze - confused! +; CHECK: da analyze - none! +define void @test_no_noalias(i32* %A, i32* %B) { + store i32 1, i32* %A + store i32 2, i32* %B + ret void +}