llvm.org GIT mirror llvm / c8d498d
[AliasAnalysis] AAResults preserves AAManager. Summary: AAResults should not invalidate AAManager. Update tests. Reviewers: chandlerc Subscribers: mehdi_amini, jlebar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60914 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359014 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 4 months ago
5 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
10951095 /// This manager effectively wraps the AnalysisManager for registering alias
10961096 /// analyses. When you register your alias analysis with this manager, it will
10971097 /// ensure the analysis itself is registered with its AnalysisManager.
1098 ///
1099 /// The result of this analysis is only invalidated if one of the particular
1100 /// aggregated AA results end up being invalidated. This removes the need to
1101 /// explicitly preserve the results of `AAManager`. Note that analyses should no
1102 /// longer be registered once the `AAManager` is run.
1103
10981104 class AAManager : public AnalysisInfoMixin {
10991105 public:
11001106 using Result = AAResults;
7878
7979 bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA,
8080 FunctionAnalysisManager::Invalidator &Inv) {
81 // Check if the AA manager itself has been invalidated.
82 auto PAC = PA.getChecker();
83 if (!PAC.preserved() && !PAC.preservedSet>())
84 return true; // The manager needs to be blown away, clear everything.
85
86 // Check all of the dependencies registered.
81 // AAResults preserves the AAManager by default, due to the stateless nature
82 // of AliasAnalysis. There is no need to check whether it has been preserved
83 // explicitly. However, we still need to check if any of the dependencies end
84 // up being invalidated, and invalidate ourselves in that case.
8785 for (AnalysisKey *ID : AADeps)
8886 if (Inv.invalidate(ID, F, PA))
8987 return true;
0 ; Test that memdep gets invalidated when the analyses it depends on are
11 ; invalidated.
22 ;
3 ; Check AA specifically.
3 ; Check AA. AA is stateless, there's nothing to invalidate.
44 ; RUN: opt -disable-output -debug-pass-manager -aa-pipeline='basic-aa' %s 2>&1 \
55 ; RUN: -passes='require,invalidate,gvn' \
66 ; RUN: | FileCheck %s --check-prefix=CHECK-AA-INVALIDATE
77 ; CHECK-AA-INVALIDATE: Running pass: RequireAnalysisPass
88 ; CHECK-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
99 ; CHECK-AA-INVALIDATE: Running pass: InvalidateAnalysisPass
10 ; CHECK-AA-INVALIDATE: Invalidating analysis: AAManager
11 ; CHECK-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
10 ; CHECK-NOT-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
1211 ; CHECK-AA-INVALIDATE: Running pass: GVN
13 ; CHECK-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
12 ; CHECK-NOT-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
1413 ;
1514 ; Check domtree specifically.
1615 ; RUN: opt -disable-output -debug-pass-manager %s 2>&1 \
354354 ; CHECK-AA-MODULE-INVALIDATE: Running analysis: AAManager
355355 ; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Function pass manager run
356356 ; CHECK-AA-MODULE-INVALIDATE: Running pass: InvalidateAnalysisPass
357 ; CHECK-AA-MODULE-INVALIDATE: Invalidating analysis: AAManager
358357 ; CHECK-AA-MODULE-INVALIDATE: Invalidating analysis: GlobalsAA
359358 ; CHECK-AA-MODULE-INVALIDATE: Running pass: RequireAnalysisPass
360359 ; CHECK-AA-MODULE-INVALIDATE: Running analysis: GlobalsAA
361360 ; CHECK-AA-MODULE-INVALIDATE: Starting llvm::Function pass manager run
362361 ; CHECK-AA-MODULE-INVALIDATE: Running pass: AAEvaluator
363 ; CHECK-AA-MODULE-INVALIDATE: Running analysis: AAManager
364362 ; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Function pass manager run
365363 ; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Module pass manager run
366364
571571 // invalidation and running.
572572 EXPECT_CALL(MFPHandle, run(HasName("f"), _))
573573 .WillOnce(Return(getLoopPassPreservedAnalyses()));
574 EXPECT_CALL(MLAHandle, invalidate(_, _, _)).Times(3);
575574 EXPECT_CALL(MLAHandle, run(HasName("loop.0.0"), _, _));
576575 EXPECT_CALL(MLAHandle, run(HasName("loop.0.1"), _, _));
577576 EXPECT_CALL(MLAHandle, run(HasName("loop.0"), _, _));