llvm.org GIT mirror llvm / 20b802a
Revert [AliasAnalysis] AAResults preserves AAManager. Triggers use-after-free. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359055 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
11041098 class AAManager : public AnalysisInfoMixin {
11051099 public:
11061100 using Result = AAResults;
7878
7979 bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA,
8080 FunctionAnalysisManager::Invalidator &Inv) {
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.
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.
8587 for (AnalysisKey *ID : AADeps)
8688 if (Inv.invalidate(ID, F, PA))
8789 return true;
0 ; Test that memdep gets invalidated when the analyses it depends on are
11 ; invalidated.
22 ;
3 ; Check AA. AA is stateless, there's nothing to invalidate.
3 ; Check AA specifically.
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-NOT-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
10 ; CHECK-AA-INVALIDATE: Invalidating analysis: AAManager
11 ; CHECK-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
1112 ; CHECK-AA-INVALIDATE: Running pass: GVN
12 ; CHECK-NOT-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
13 ; CHECK-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
1314 ;
1415 ; Check domtree specifically.
1516 ; 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
357358 ; CHECK-AA-MODULE-INVALIDATE: Invalidating analysis: GlobalsAA
358359 ; CHECK-AA-MODULE-INVALIDATE: Running pass: RequireAnalysisPass
359360 ; CHECK-AA-MODULE-INVALIDATE: Running analysis: GlobalsAA
360361 ; CHECK-AA-MODULE-INVALIDATE: Starting llvm::Function pass manager run
361362 ; CHECK-AA-MODULE-INVALIDATE: Running pass: AAEvaluator
363 ; CHECK-AA-MODULE-INVALIDATE: Running analysis: AAManager
362364 ; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Function pass manager run
363365 ; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Module pass manager run
364366
571571 // invalidation and running.
572572 EXPECT_CALL(MFPHandle, run(HasName("f"), _))
573573 .WillOnce(Return(getLoopPassPreservedAnalyses()));
574 EXPECT_CALL(MLAHandle, invalidate(_, _, _)).Times(3);
574575 EXPECT_CALL(MLAHandle, run(HasName("loop.0.0"), _, _));
575576 EXPECT_CALL(MLAHandle, run(HasName("loop.0.1"), _, _));
576577 EXPECT_CALL(MLAHandle, run(HasName("loop.0"), _, _));