-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[flang] Move AddAliasTags pass after BoxedProcedurePass. #156780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Move AddAliasTags after BoxedProcedurePass to be able to compute the size of Fortran variables by converting their types to LLVM types and applying DL size/alignment computations. This is one of the approaches to unblock llvm#156558. This change does not affect performance in my testing.
@llvm/pr-subscribers-flang-driver @llvm/pr-subscribers-flang-fir-hlfir Author: Slava Zakharin (vzakhari) ChangesMove AddAliasTags after BoxedProcedurePass to be able to compute This change does not affect performance in my testing. Full diff: https://github.com/llvm/llvm-project/pull/156780.diff 3 Files Affected:
diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp
index 6cc3290ff5cc2..7c2777baebef1 100644
--- a/flang/lib/Optimizer/Passes/Pipelines.cpp
+++ b/flang/lib/Optimizer/Passes/Pipelines.cpp
@@ -217,9 +217,6 @@ void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm,
pm.addPass(fir::createSimplifyFIROperations(
{/*preferInlineImplementation=*/pc.OptLevel.isOptimizingForSpeed()}));
- if (pc.AliasAnalysis && !disableFirAliasTags && !useOldAliasTags)
- pm.addPass(fir::createAddAliasTags());
-
addNestedPassToAllTopLevelOperations<PassConstructor>(
pm, fir::createStackReclaim);
// convert control flow to CFG form
@@ -345,6 +342,9 @@ void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
MLIRToLLVMPassPipelineConfig config,
llvm::StringRef inputFilename) {
fir::addBoxedProcedurePass(pm);
+ if (config.OptLevel.isOptimizingForSpeed() && config.AliasAnalysis &&
+ !disableFirAliasTags && !useOldAliasTags)
+ pm.addPass(fir::createAddAliasTags());
addNestedPassToAllTopLevelOperations<PassConstructor>(
pm, fir::createAbstractResultOpt);
addPassToGPUModuleOperations<PassConstructor>(pm,
diff --git a/flang/test/Driver/mlir-pass-pipeline.f90 b/flang/test/Driver/mlir-pass-pipeline.f90
index 0bcd055a84b87..e85a7728fc9af 100644
--- a/flang/test/Driver/mlir-pass-pipeline.f90
+++ b/flang/test/Driver/mlir-pass-pipeline.f90
@@ -109,7 +109,6 @@
! O2-NEXT: OptimizeArrayRepacking
! ALL-NEXT: LowerRepackArraysPass
! ALL-NEXT: SimplifyFIROperations
-! O2-NEXT: AddAliasTags
! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
! ALL-NEXT: 'fir.global' Pipeline
@@ -134,6 +133,7 @@
! O2-NEXT: 'func.func' Pipeline
! O2-NEXT: SetRuntimeCallAttributes
! ALL-NEXT: BoxedProcedurePass
+! O2-NEXT: AddAliasTags
! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'gpu.module', 'omp.declare_reduction', 'omp.private']
! ALL-NEXT: 'fir.global' Pipeline
diff --git a/flang/test/Fir/basic-program.fir b/flang/test/Fir/basic-program.fir
index c9fe53bf093a1..0a31397efb332 100644
--- a/flang/test/Fir/basic-program.fir
+++ b/flang/test/Fir/basic-program.fir
@@ -107,7 +107,6 @@ func.func @_QQmain() {
// PASSES-NEXT: OptimizeArrayRepacking
// PASSES-NEXT: LowerRepackArraysPass
// PASSES-NEXT: SimplifyFIROperations
-// PASSES-NEXT: AddAliasTags
// PASSES-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
// PASSES-NEXT: 'fir.global' Pipeline
@@ -132,6 +131,7 @@ func.func @_QQmain() {
// PASSES-NEXT: 'func.func' Pipeline
// PASSES-NEXT: SetRuntimeCallAttributes
// PASSES-NEXT: BoxedProcedurePass
+// PASSES-NEXT: AddAliasTags
// PASSES-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'gpu.module', 'omp.declare_reduction', 'omp.private']
// PASSES-NEXT: 'fir.global' Pipeline
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
I am thinking we should have a document to describe the FIR pipeline order and list the constraints so that we do not forget about them (not asking you to create it here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/30120 Here is the relevant piece of the build log for the reference
|
Move AddAliasTags after BoxedProcedurePass to be able to compute
the size of Fortran variables by converting their types to LLVM
types and applying DL size/alignment computations.
This is one of the approaches to unblock #156558.
This change does not affect performance in my testing.