[Passes] Run GlobalsAA before LICM during LTO in new PM.

This patch adjusts the LTO pipeline in the new PM to run GlobalsAA
before LICM to match the legacy PM.

This fixes a regression where the new PM failed to vectorize loops that
require hoisting/sinking by LICM depending on GlobalsAA info.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D102345
This commit is contained in:
Florian Hahn 2021-05-13 12:53:05 +01:00
parent 797e580db9
commit 860b37526a
3 changed files with 15 additions and 7 deletions

View File

@ -1821,10 +1821,16 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
MPM.addPass(
createModuleToPostOrderCGSCCPassAdaptor(PostOrderFunctionAttrsPass()));
// FIXME: here we run IP alias analysis in the legacy PM.
// Require the GlobalsAA analysis for the module so we can query it within
// MainFPM.
MPM.addPass(RequireAnalysisPass<GlobalsAA, Module>());
// Invalidate AAManager so it can be recreated and pick up the newly available
// GlobalsAA.
MPM.addPass(
createModuleToFunctionPassAdaptor(InvalidateAnalysisPass<AAManager>()));
FunctionPassManager MainFPM;
MainFPM.addPass(createFunctionToLoopPassAdaptor(
LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap),
EnableMSSALoopDependency, /*UseBlockFrequencyInfo=*/true));

View File

@ -79,10 +79,15 @@
; CHECK-O23SZ-NEXT: Running pass: SROA on foo
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass on foo
; CHECK-O23SZ-NEXT: Running pass: PostOrderFunctionAttrsPass on (foo)
; CHECK-O23SZ-NEXT: Running pass: RequireAnalysisPass<llvm::GlobalsAA, llvm::Module> on [module]
; CHECK-O23SZ-NEXT: Running analysis: GlobalsAA on [module]
; CHECK-O23SZ-NEXT: Running pass: InvalidateAnalysisPass<llvm::AAManager> on foo
; CHECK-O23SZ-NEXT: Invalidating analysis: AAManager on foo
; CHECK-O23SZ-NEXT: Running pass: LoopSimplifyPass on foo
; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis on foo
; CHECK-O23SZ-NEXT: Running pass: LCSSAPass on foo
; CHECK-O23SZ-NEXT: Running analysis: MemorySSAAnalysis on foo
; CHECK-O23SZ-NEXT: Running analysis: AAManager on foo
; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis on foo
; CHECK-O23SZ-NEXT: Running analysis: InnerAnalysisManagerProxy
; CHECK-O23SZ-NEXT: Running pass: LICMPass on Loop

View File

@ -1,5 +1,5 @@
; RUN: opt -passes='lto<O3>' -S %s | FileCheck %s
; RUN: opt -std-link-opts -enable-new-pm=false -S %s | FileCheck --check-prefix=LEGACY %s
; RUN: opt -std-link-opts -enable-new-pm=false -S %s | FileCheck %s
target triple = "arm64e-apple-darwin"
@ -9,10 +9,7 @@ target triple = "arm64e-apple-darwin"
@D = external unnamed_addr global i32, align 4
; CHECK-LABEL: @fn
; CHECK-NOT: vector.body:
;
; LEGACY-LABEL: @fn
; LEGACY: vector.body:
; CHECK: vector.body:
;
define void @fn() {
entry: