diff options
author | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2023-03-16 02:00:47 +0100 |
---|---|---|
committer | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2023-03-17 09:33:16 +0100 |
commit | 81d6310da1fc54f0ca0de6fa13246d6071edb0cf (patch) | |
tree | edd9a5e8fe4af4251f7b9eba4755b178a6a1a66f /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | fed4e7d0d2a45b1e49998054379af94d1ba43edd (diff) | |
download | llvm-81d6310da1fc54f0ca0de6fa13246d6071edb0cf.zip llvm-81d6310da1fc54f0ca0de6fa13246d6071edb0cf.tar.gz llvm-81d6310da1fc54f0ca0de6fa13246d6071edb0cf.tar.bz2 |
[LAA] Fix transitive analysis invalidation bug by implementing LoopAccessInfoManager::invalidate
The default invalidate method for analysis results is just looking
at the preserved state of the pass itself. It does not consider if
the analysis has an internal state that depend on other analyses.
Thus, we need to implement LoopAccessInfoManager::invalidate in order
to catch if LoopAccessAnalysis needs to be invalidated due to
transitive analyses such as AAManager is being invalidated. Otherwise
we might end up having references to an AAManager that is stale.
Fixes https://github.com/llvm/llvm-project/issues/61324
Differential Revision: https://reviews.llvm.org/D146206
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 9e11056..aee14ed 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -2704,6 +2704,24 @@ void LoopAccessLegacyAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } +bool LoopAccessInfoManager::invalidate( + Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &Inv) { + // Check whether our analysis is preserved. + auto PAC = PA.getChecker<LoopAccessAnalysis>(); + if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>()) + // If not, give up now. + return true; + + // Check whether the analyses we depend on became invalid for any reason. + // Skip checking TargetLibraryAnalysis as it is immutable and can't become + // invalid. + return Inv.invalidate<AAManager>(F, PA) || + Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) || + Inv.invalidate<LoopAnalysis>(F, PA) || + Inv.invalidate<DominatorTreeAnalysis>(F, PA); +} + LoopAccessInfoManager LoopAccessAnalysis::run(Function &F, FunctionAnalysisManager &AM) { return LoopAccessInfoManager( |