[PATCH] D102345: [Passes] Run GlobalsAA before LICM during LTO in new PM, use MSSA.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 11:36:55 PDT 2021
fhahn created this revision.
fhahn added reviewers: asbirlea, spatel, aeubanks, nikic, lebedev.ri, dmgreen.
Herald added subscribers: steven_wu, george.burgess.iv, hiraditya, inglorion.
fhahn requested review of this revision.
Herald added a project: LLVM.
This patch adjusts the LTO pipeline in the new PM to run GlobalsAA
before LICM and use MemorySSA for 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102345
Files:
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll
Index: llvm/test/Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll
===================================================================
--- llvm/test/Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll
+++ llvm/test/Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll
@@ -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 @@
@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:
Index: llvm/test/Other/new-pm-lto-defaults.ll
===================================================================
--- llvm/test/Other/new-pm-lto-defaults.ll
+++ llvm/test/Other/new-pm-lto-defaults.ll
@@ -79,9 +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
@@ -89,7 +95,6 @@
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis on foo
; CHECK-O23SZ-NEXT: Running analysis: PhiValuesAnalysis on foo
; CHECK-O23SZ-NEXT: Running pass: MemCpyOptPass on foo
-; CHECK-O23SZ-NEXT: Running analysis: MemorySSAAnalysis on foo
; CHECK-O23SZ-NEXT: Running pass: DSEPass on foo
; CHECK-O23SZ-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass on foo
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1821,12 +1821,19 @@
MPM.addPass(
createModuleToPostOrderCGSCCPassAdaptor(PostOrderFunctionAttrsPass()));
- // FIXME: here we run IP alias analysis in the legacy PM.
- FunctionPassManager MainFPM;
+ // 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)));
+ LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap),
+ EnableMSSALoopDependency, /*UseBlockFrequencyInfo=*/true));
if (RunNewGVN)
MainFPM.addPass(NewGVNPass());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102345.344886.patch
Type: text/x-patch
Size: 3554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210512/145e4b90/attachment.bin>
More information about the llvm-commits
mailing list