[llvm] r359055 - Revert [AliasAnalysis] AAResults preserves AAManager.
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 23 17:28:29 PDT 2019
Author: asbirlea
Date: Tue Apr 23 17:28:29 2019
New Revision: 359055
URL: http://llvm.org/viewvc/llvm-project?rev=359055&view=rev
Log:
Revert [AliasAnalysis] AAResults preserves AAManager.
Triggers use-after-free.
Modified:
llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/test/Analysis/MemoryDependenceAnalysis/invalidation.ll
llvm/trunk/test/Other/new-pass-manager.ll
llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
Modified: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasAnalysis.h?rev=359055&r1=359054&r2=359055&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h Tue Apr 23 17:28:29 2019
@@ -1096,12 +1096,6 @@ bool isIdentifiedFunctionLocal(const Val
/// This manager effectively wraps the AnalysisManager for registering alias
/// analyses. When you register your alias analysis with this manager, it will
/// ensure the analysis itself is registered with its AnalysisManager.
-///
-/// The result of this analysis is only invalidated if one of the particular
-/// aggregated AA results end up being invalidated. This removes the need to
-/// explicitly preserve the results of `AAManager`. Note that analyses should no
-/// longer be registered once the `AAManager` is run.
-
class AAManager : public AnalysisInfoMixin<AAManager> {
public:
using Result = AAResults;
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=359055&r1=359054&r2=359055&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Tue Apr 23 17:28:29 2019
@@ -79,10 +79,12 @@ AAResults::~AAResults() {
bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv) {
- // AAResults preserves the AAManager by default, due to the stateless nature
- // of AliasAnalysis. There is no need to check whether it has been preserved
- // explicitly. However, we still need to check if any of the dependencies end
- // up being invalidated, and invalidate ourselves in that case.
+ // Check if the AA manager itself has been invalidated.
+ auto PAC = PA.getChecker<AAManager>();
+ if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>())
+ return true; // The manager needs to be blown away, clear everything.
+
+ // Check all of the dependencies registered.
for (AnalysisKey *ID : AADeps)
if (Inv.invalidate(ID, F, PA))
return true;
Modified: llvm/trunk/test/Analysis/MemoryDependenceAnalysis/invalidation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/MemoryDependenceAnalysis/invalidation.ll?rev=359055&r1=359054&r2=359055&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/MemoryDependenceAnalysis/invalidation.ll (original)
+++ llvm/trunk/test/Analysis/MemoryDependenceAnalysis/invalidation.ll Tue Apr 23 17:28:29 2019
@@ -1,16 +1,17 @@
; Test that memdep gets invalidated when the analyses it depends on are
; invalidated.
;
-; Check AA. AA is stateless, there's nothing to invalidate.
+; Check AA specifically.
; RUN: opt -disable-output -debug-pass-manager -aa-pipeline='basic-aa' %s 2>&1 \
; RUN: -passes='require<memdep>,invalidate<aa>,gvn' \
; RUN: | FileCheck %s --check-prefix=CHECK-AA-INVALIDATE
; CHECK-AA-INVALIDATE: Running pass: RequireAnalysisPass
; CHECK-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
; CHECK-AA-INVALIDATE: Running pass: InvalidateAnalysisPass
-; CHECK-NOT-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
+; CHECK-AA-INVALIDATE: Invalidating analysis: AAManager
+; CHECK-AA-INVALIDATE: Invalidating analysis: MemoryDependenceAnalysis
; CHECK-AA-INVALIDATE: Running pass: GVN
-; CHECK-NOT-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
+; CHECK-AA-INVALIDATE: Running analysis: MemoryDependenceAnalysis
;
; Check domtree specifically.
; RUN: opt -disable-output -debug-pass-manager %s 2>&1 \
Modified: llvm/trunk/test/Other/new-pass-manager.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/new-pass-manager.ll?rev=359055&r1=359054&r2=359055&view=diff
==============================================================================
--- llvm/trunk/test/Other/new-pass-manager.ll (original)
+++ llvm/trunk/test/Other/new-pass-manager.ll Tue Apr 23 17:28:29 2019
@@ -355,11 +355,13 @@
; CHECK-AA-MODULE-INVALIDATE: Running analysis: AAManager
; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Function pass manager run
; CHECK-AA-MODULE-INVALIDATE: Running pass: InvalidateAnalysisPass
+; CHECK-AA-MODULE-INVALIDATE: Invalidating analysis: AAManager
; CHECK-AA-MODULE-INVALIDATE: Invalidating analysis: GlobalsAA
; CHECK-AA-MODULE-INVALIDATE: Running pass: RequireAnalysisPass
; CHECK-AA-MODULE-INVALIDATE: Running analysis: GlobalsAA
; CHECK-AA-MODULE-INVALIDATE: Starting llvm::Function pass manager run
; CHECK-AA-MODULE-INVALIDATE: Running pass: AAEvaluator
+; CHECK-AA-MODULE-INVALIDATE: Running analysis: AAManager
; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Function pass manager run
; CHECK-AA-MODULE-INVALIDATE: Finished llvm::Module pass manager run
Modified: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp?rev=359055&r1=359054&r2=359055&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp (original)
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp Tue Apr 23 17:28:29 2019
@@ -572,6 +572,7 @@ TEST_F(LoopPassManagerTest, Invalidation
// invalidation and running.
EXPECT_CALL(MFPHandle, run(HasName("f"), _))
.WillOnce(Return(getLoopPassPreservedAnalyses()));
+ EXPECT_CALL(MLAHandle, invalidate(_, _, _)).Times(3);
EXPECT_CALL(MLAHandle, run(HasName("loop.0.0"), _, _));
EXPECT_CALL(MLAHandle, run(HasName("loop.0.1"), _, _));
EXPECT_CALL(MLAHandle, run(HasName("loop.0"), _, _));
More information about the llvm-commits
mailing list