[flang-commits] [flang] [flang][driver] apply mlir pass options immediately after lowering (PR #106099)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 27 01:32:54 PDT 2024
https://github.com/jeanPerier updated https://github.com/llvm/llvm-project/pull/106099
>From 2bc3a67871e9d49181c21b1fb1a84e98248ee582 Mon Sep 17 00:00:00 2001
From: Jean Perier <jperier at nvidia.com>
Date: Mon, 26 Aug 2024 09:18:34 -0700
Subject: [PATCH 1/3] [flang][driver] apply mlir pass option after lowering
---
flang/lib/Frontend/FrontendActions.cpp | 1 +
flang/test/Driver/mlir-debug-pass-pipeline.f90 | 3 +++
flang/test/Driver/mlir-pass-pipeline.f90 | 3 +++
3 files changed, 7 insertions(+)
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 5c86bd947ce73f..c9991ff18d1754 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -323,6 +323,7 @@ bool CodeGenAction::beginSourceFileAction() {
// run the default passes.
mlir::PassManager pm((*mlirModule)->getName(),
mlir::OpPassManager::Nesting::Implicit);
+ (void)mlir::applyPassManagerCLOptions(pm);
// Add OpenMP-related passes
// WARNING: These passes must be run immediately after the lowering to ensure
// that the FIR is correct with respect to OpenMP operations/attributes.
diff --git a/flang/test/Driver/mlir-debug-pass-pipeline.f90 b/flang/test/Driver/mlir-debug-pass-pipeline.f90
index a6316ee7c83123..e44f4e62a7148b 100644
--- a/flang/test/Driver/mlir-debug-pass-pipeline.f90
+++ b/flang/test/Driver/mlir-debug-pass-pipeline.f90
@@ -22,6 +22,9 @@
! DEBUG-ERR: error: invalid value 'invalid' in '-debug-info-kind=invalid'
! DEBUG-ERR-NOT: Pass statistics report
+! ALL: Pass statistics report
+! ALL: Fortran::lower::VerifierPass
+
! ALL: Pass statistics report
! ALL: Fortran::lower::VerifierPass
diff --git a/flang/test/Driver/mlir-pass-pipeline.f90 b/flang/test/Driver/mlir-pass-pipeline.f90
index 2f35f928e99cfc..6c2829d3cc5c57 100644
--- a/flang/test/Driver/mlir-pass-pipeline.f90
+++ b/flang/test/Driver/mlir-pass-pipeline.f90
@@ -9,6 +9,9 @@
end program
+! ALL: Pass statistics report
+! ALL: Fortran::lower::VerifierPass
+
! ALL: Pass statistics report
! ALL: Fortran::lower::VerifierPass
>From 43fa7a57d4ebedb14f716b94f62e5035370b39ee Mon Sep 17 00:00:00 2001
From: Jean Perier <jperier at nvidia.com>
Date: Tue, 27 Aug 2024 01:29:20 -0700
Subject: [PATCH 2/3] add mmlir vs no mmlir test
---
flang/test/Driver/mmlir-opts-vs-opts.f90 | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 flang/test/Driver/mmlir-opts-vs-opts.f90
diff --git a/flang/test/Driver/mmlir-opts-vs-opts.f90 b/flang/test/Driver/mmlir-opts-vs-opts.f90
new file mode 100644
index 00000000000000..4cd2062ac4ea4f
--- /dev/null
+++ b/flang/test/Driver/mmlir-opts-vs-opts.f90
@@ -0,0 +1,8 @@
+! Verify that mlir pass options are only accessible under `-mmlir`.
+
+!RUN: %flang_fc1 -emit-hlfir -mmlir --mlir-pass-statistics %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=MMLIR
+!RUN: not %flang_fc1 -emit-hlfir -mlir-pass-statistics %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=NOMMLIR
+
+!MMLIR: Pass statistics report
+!NOMMLIR: error: unknown argument: '-mlir-pass-statistics'
+end
>From 5dab471e2ccaecdc2fa44e89832628be7951f0ba Mon Sep 17 00:00:00 2001
From: Jean Perier <jperier at nvidia.com>
Date: Tue, 27 Aug 2024 01:32:37 -0700
Subject: [PATCH 3/3] be consistent between single and double dashes in added
test
---
flang/test/Driver/mmlir-opts-vs-opts.f90 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/test/Driver/mmlir-opts-vs-opts.f90 b/flang/test/Driver/mmlir-opts-vs-opts.f90
index 4cd2062ac4ea4f..8cd14e02c3fcc9 100644
--- a/flang/test/Driver/mmlir-opts-vs-opts.f90
+++ b/flang/test/Driver/mmlir-opts-vs-opts.f90
@@ -1,6 +1,6 @@
! Verify that mlir pass options are only accessible under `-mmlir`.
-!RUN: %flang_fc1 -emit-hlfir -mmlir --mlir-pass-statistics %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=MMLIR
+!RUN: %flang_fc1 -emit-hlfir -mmlir -mlir-pass-statistics %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=MMLIR
!RUN: not %flang_fc1 -emit-hlfir -mlir-pass-statistics %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=NOMMLIR
!MMLIR: Pass statistics report
More information about the flang-commits
mailing list