From: Arthur Eubanks Date: Tue, 27 Apr 2021 15:56:11 +0000 (-0700) Subject: [NewPM] Invalidate AAManager after populating GlobalsAA X-Git-Tag: llvmorg-14-init~7734 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2df3426fd15e41880c2da1484b560cd9c5f1f842;p=platform%2Fupstream%2Fllvm.git [NewPM] Invalidate AAManager after populating GlobalsAA GlobalsAA is only created at the beginning of the inliner pipeline. If an AAManager is cached from previous passes, it won't get rebuilt to include the newly created GlobalsAA. Reviewed By: mtrofin Differential Revision: https://reviews.llvm.org/D101379 --- diff --git a/clang/test/Driver/debug-pass-structure.c b/clang/test/Driver/debug-pass-structure.c index 04ddce8..2f25010 100644 --- a/clang/test/Driver/debug-pass-structure.c +++ b/clang/test/Driver/debug-pass-structure.c @@ -20,6 +20,7 @@ // NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module] // NEWPM-NEXT: GlobalsAA analysis on [module] // NEWPM-NEXT: CallGraphAnalysis analysis on [module] +// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module] // NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module] // NEWPM-NEXT: ProfileSummaryAnalysis analysis on [module] // NEWPM-NEXT: ModuleToPostOrderCGSCCPassAdaptor on [module] diff --git a/llvm/include/llvm/Transforms/IPO/Inliner.h b/llvm/include/llvm/Transforms/IPO/Inliner.h index 21ff869..ce961bc 100644 --- a/llvm/include/llvm/Transforms/IPO/Inliner.h +++ b/llvm/include/llvm/Transforms/IPO/Inliner.h @@ -131,9 +131,9 @@ public: /// before run is called, as part of pass pipeline building. CGSCCPassManager &getPM() { return PM; } - /// Allow adding module-level analyses benefiting the contained CGSCC passes. - template void addRequiredModuleAnalysis() { - MPM.addPass(RequireAnalysisPass()); + /// Allow adding module-level passes benefiting the contained CGSCC passes. + template void addModulePass(T Pass) { + MPM.addPass(std::move(Pass)); } private: diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 8a694cd..e033860 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -977,11 +977,15 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level, // Require the GlobalsAA analysis for the module so we can query it within // the CGSCC pipeline. - MIWP.addRequiredModuleAnalysis(); + MIWP.addModulePass(RequireAnalysisPass()); + // Invalidate AAManager so it can be recreated and pick up the newly available + // GlobalsAA. + MIWP.addModulePass( + createModuleToFunctionPassAdaptor(InvalidateAnalysisPass())); // Require the ProfileSummaryAnalysis for the module so we can query it within // the inliner pass. - MIWP.addRequiredModuleAnalysis(); + MIWP.addModulePass(RequireAnalysisPass()); // Now begin the main postorder CGSCC pipeline. // FIXME: The current CGSCC pipeline has its origins in the legacy pass diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll index 7e7f265..6192b87 100644 --- a/llvm/test/Other/new-pm-defaults.ll +++ b/llvm/test/Other/new-pm-defaults.ll @@ -114,6 +114,8 @@ ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA ; CHECK-O-NEXT: Running analysis: CallGraphAnalysis +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager +; CHECK-O-NEXT: Invalidating analysis: AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy @@ -125,6 +127,7 @@ ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass +; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass ; CHECK-O2-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) ; CHECK-O3-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) diff --git a/llvm/test/Other/new-pm-thinlto-defaults.ll b/llvm/test/Other/new-pm-thinlto-defaults.ll index d720193..0d580d3 100644 --- a/llvm/test/Other/new-pm-thinlto-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-defaults.ll @@ -98,6 +98,8 @@ ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA ; CHECK-O-NEXT: Running analysis: CallGraphAnalysis +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager +; CHECK-O-NEXT: Invalidating analysis: AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-PRELINK-O-NEXT: Running analysis: ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy @@ -109,6 +111,7 @@ ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass +; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass ; CHECK-O2-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) ; CHECK-O3-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) diff --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll index 45bdfcc..ddbfd44 100644 --- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll @@ -73,6 +73,8 @@ ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA ; CHECK-O-NEXT: Running analysis: CallGraphAnalysis +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager +; CHECK-O-NEXT: Invalidating analysis: AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis @@ -83,6 +85,7 @@ ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass +; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass ; CHECK-O2-NEXT: Running pass: OpenMPOptCGSCCPass ; CHECK-O3-NEXT: Running pass: OpenMPOptCGSCCPass diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll index dabc8ff..f882298 100644 --- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll @@ -82,6 +82,8 @@ ; CHECK-O-NEXT: Starting {{.*}}Module pass manager run. ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager +; CHECK-O-NEXT: Invalidating analysis: AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis @@ -92,6 +94,7 @@ ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass +; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass ; CHECK-O2-NEXT: Running pass: OpenMPOptCGSCCPass ; CHECK-O3-NEXT: Running pass: OpenMPOptCGSCCPass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll index 2b99f89..46b2714 100644 --- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll @@ -98,6 +98,7 @@ ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA ; CHECK-O-NEXT: Running analysis: CallGraphAnalysis +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll index 0a6fe86..4e5683d 100644 --- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll @@ -77,6 +77,8 @@ ; CHECK-O-NEXT: Starting {{.*}}Module pass manager run. ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Running analysis: GlobalsAA +; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager +; CHECK-O-NEXT: Invalidating analysis: AAManager ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis @@ -87,6 +89,7 @@ ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: InlinerPass ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass +; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass ; CHECK-O2-NEXT: Running pass: OpenMPOptCGSCCPass ; CHECK-O3-NEXT: Running pass: OpenMPOptCGSCCPass diff --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll index 29c33c3..6802d58 100644 --- a/llvm/test/Other/opt-O3-pipeline.ll +++ b/llvm/test/Other/opt-O3-pipeline.ll @@ -380,6 +380,8 @@ ; NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module] ; NEWPM-NEXT: GlobalsAA analysis on [module] ; NEWPM-NEXT: CallGraphAnalysis analysis on [module] +; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module] +; NEWPM-NEXT: InvalidateAnalysisPass<{{.*}}> on f ; NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module] ; NEWPM-NEXT: ProfileSummaryAnalysis analysis on [module] ; NEWPM-NEXT: ModuleToPostOrderCGSCCPassAdaptor on [module] @@ -392,6 +394,7 @@ ; NEWPM-NEXT: InlinerPass on (f) ; NEWPM-NEXT: InlinerPass on (f) ; NEWPM-NEXT: PostOrderFunctionAttrsPass on (f) +; NEWPM-NEXT: AAManager analysis on f ; NEWPM-NEXT: ArgumentPromotionPass on (f) ; NEWPM-NEXT: OpenMPOptCGSCCPass on (f) ; NEWPM-NEXT: CGSCCToFunctionPassAdaptor on (f)