From 6419f6461cfc8e741fb9b79971d961d1c07986f3 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Wed, 4 Oct 2017 22:02:27 +0000 Subject: [PATCH] Do not call Loop::getName on possibly dead loops This fixes PR34832. llvm-svn: 314938 --- lib/Analysis/LoopAnalysisManager.cpp | 6 ++++-- test/Other/loop-pm-invalidation.ll | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Analysis/LoopAnalysisManager.cpp b/lib/Analysis/LoopAnalysisManager.cpp index 84a891c3f4f..7647f85019d 100644 --- a/lib/Analysis/LoopAnalysisManager.cpp +++ b/lib/Analysis/LoopAnalysisManager.cpp @@ -56,8 +56,10 @@ bool LoopAnalysisManagerFunctionProxy::Result::invalidate( // analysis manager's cache. So we just walk the keys and forcibly clear // those results. Note that the order doesn't matter here as this will just // directly destroy the results without calling methods on them. - for (Loop *L : PreOrderLoops) - InnerAM->clear(*L, L->getName()); + for (Loop *L : PreOrderLoops) { + // NB! `L` may not be in a good enough state to run Loop::getName. + InnerAM->clear(*L, ""); + } // We also need to null out the inner AM so that when the object gets // destroyed as invalid we don't try to clear the inner AM again. At that diff --git a/test/Other/loop-pm-invalidation.ll b/test/Other/loop-pm-invalidation.ll index d2a0e23a720..9a4f74e1d00 100644 --- a/test/Other/loop-pm-invalidation.ll +++ b/test/Other/loop-pm-invalidation.ll @@ -57,7 +57,7 @@ define void @one_loop(i1* %ptr) { ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run. ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: l0.header +; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: ; CHECK-LOOP-INV-NEXT: Invalidating analysis: LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop @@ -84,7 +84,7 @@ define void @one_loop(i1* %ptr) { ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run. ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: l0.header +; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: ; CHECK-SCEV-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop ; CHECK-SCEV-INV-NEXT: Running pass: FunctionToLoopPassAdaptor<{{.*}}> on one_loop @@ -124,8 +124,8 @@ define void @nested_loops(i1* %ptr) { ; CHECK-LOOP-INV: Finished {{.*}}Loop pass manager run. ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: l.0.header -; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: l.0.0.header +; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: +; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: ; CHECK-LOOP-INV-NEXT: Invalidating analysis: LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop @@ -158,8 +158,8 @@ define void @nested_loops(i1* %ptr) { ; CHECK-SCEV-INV: Finished {{.*}}Loop pass manager run. ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: l.0.header -; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: l.0.0.header +; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: +; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: ; CHECK-SCEV-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop ; CHECK-SCEV-INV-NEXT: Running pass: FunctionToLoopPassAdaptor<{{.*}}> on nested_loops @@ -206,7 +206,7 @@ define void @dead_loop() { ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run. ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: l0.header +; CHECK-LOOP-INV-NEXT: Clearing all analysis results for: ; CHECK-LOOP-INV-NEXT: Invalidating analysis: LoopAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-LOOP-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop @@ -233,7 +233,7 @@ define void @dead_loop() { ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run. ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating all non-preserved analyses -; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: l0.header +; CHECK-SCEV-INV-NEXT: Clearing all analysis results for: ; CHECK-SCEV-INV-NEXT: Invalidating analysis: ScalarEvolutionAnalysis ; CHECK-SCEV-INV-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop ; CHECK-SCEV-INV-NEXT: Running pass: FunctionToLoopPassAdaptor<{{.*}}> on dead_loop