[clang] 6e13e3c - [Flang][Driver] Enable Rpass and other R family options.
Kiran Chandramohan via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 04:38:02 PDT 2023
Author: Victor Kingi
Date: 2023-08-10T12:37:28+01:00
New Revision: 6e13e3c3e5e29ec0757370e354ed5e62147e47c7
URL: https://github.com/llvm/llvm-project/commit/6e13e3c3e5e29ec0757370e354ed5e62147e47c7
DIFF: https://github.com/llvm/llvm-project/commit/6e13e3c3e5e29ec0757370e354ed5e62147e47c7.diff
LOG: [Flang][Driver] Enable Rpass and other R family options.
This patch allows propagation of the R family of options to the backend where a separate patch will implement the optimization
remark printing.
This patch was created to address the comment about splitting into smaller patches in https://reviews.llvm.org/D156320.
Reviewed By: awarzynski, tblah, kiranchandramohan
Differential Revision: https://reviews.llvm.org/D157410
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/frontend-forwarding.f90
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1166dd28b8331c..bf2163ed7d9754 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -816,19 +816,6 @@ def : Flag<["-"], "fno-ident">, Group<f_Group>, Alias<Qn>,
def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[NoXarchOption, CoreOption]>,
HelpText<"Don't emit warning for unused driver arguments">;
def Q : Flag<["-"], "Q">, IgnoredGCCCompat;
-def Rpass_EQ : Joined<["-"], "Rpass=">, Group<R_value_Group>, Flags<[CC1Option]>,
- HelpText<"Report transformations performed by optimization passes whose "
- "name matches the given POSIX regular expression">;
-def Rpass_missed_EQ : Joined<["-"], "Rpass-missed=">, Group<R_value_Group>,
- Flags<[CC1Option]>,
- HelpText<"Report missed transformations by optimization passes whose "
- "name matches the given POSIX regular expression">;
-def Rpass_analysis_EQ : Joined<["-"], "Rpass-analysis=">, Group<R_value_Group>,
- Flags<[CC1Option]>,
- HelpText<"Report transformation analysis from optimization passes whose "
- "name matches the given POSIX regular expression">;
-def R_Joined : Joined<["-"], "R">, Group<R_Group>, Flags<[CC1Option, CoreOption]>,
- MetaVarName<"<remark>">, HelpText<"Enable the specified remark">;
def S : Flag<["-"], "S">, Flags<[NoXarchOption,CC1Option,FlangOption,FC1Option]>, Group<Action_Group>,
HelpText<"Only run preprocess and compilation steps">;
def T : JoinedOrSeparate<["-"], "T">, Group<T_Group>,
@@ -2888,6 +2875,26 @@ def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">;
} // let Group = f_Group
} // let Flags = [CC1Option, FC1Option, NoArgumentUnused]
+//===----------------------------------------------------------------------===//
+// Optimisation remark options
+//===----------------------------------------------------------------------===//
+
+let Flags = [CC1Option, FC1Option, FlangOption] in {
+
+def Rpass_EQ : Joined<["-"], "Rpass=">, Group<R_value_Group>,
+ HelpText<"Report transformations performed by optimization passes whose "
+ "name matches the given POSIX regular expression">;
+def Rpass_missed_EQ : Joined<["-"], "Rpass-missed=">, Group<R_value_Group>,
+ HelpText<"Report missed transformations by optimization passes whose "
+ "name matches the given POSIX regular expression">;
+def Rpass_analysis_EQ : Joined<["-"], "Rpass-analysis=">, Group<R_value_Group>,
+ HelpText<"Report transformation analysis from optimization passes whose "
+ "name matches the given POSIX regular expression">;
+def R_Joined : Joined<["-"], "R">, Group<R_Group>, Flags<[CoreOption]>,
+ MetaVarName<"<remark>">, HelpText<"Enable the specified remark">;
+
+} // let Flags = [CC1Option, FC1Option, FlangOption]
+
let Flags = [CC1Option, FC1Option, NoArgumentUnused, HelpHidden] in {
let Group = f_Group in {
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index d0ab58bf4a8559..11c9d90c701f0c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -518,6 +518,9 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
// Add Codegen options
addCodegenOptions(Args, CmdArgs);
+ // Add R Group options
+ Args.AddAllArgs(CmdArgs, options::OPT_R_Group);
+
// Remarks can be enabled with any of the `-f.*optimization-record.*` flags.
if (willEmitRemarks(Args))
renderRemarksOptions(Args, CmdArgs, Input);
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index 2522a0aee457e1..2c70b870ef0a45 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -95,6 +95,10 @@
! CHECK-NEXT: -print-effective-triple Print the effective target triple
! CHECK-NEXT: -print-target-triple Print the normalized target triple
! CHECK-NEXT: -P Disable linemarker output in -E mode
+! CHECK-NEXT: -Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -R<remark> Enable the specified remark
! CHECK-NEXT: -save-temps=<value> Save intermediate compilation results.
! CHECK-NEXT: -save-temps Save intermediate compilation results
! CHECK-NEXT: -std=<value> Language standard to compile for
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index c6144e71f9f6ba..dc9db6be89fe55 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -91,6 +91,10 @@
! HELP-NEXT: -print-effective-triple Print the effective target triple
! HELP-NEXT: -print-target-triple Print the normalized target triple
! HELP-NEXT: -P Disable linemarker output in -E mode
+! HELP-NEXT: -Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -R<remark> Enable the specified remark
! HELP-NEXT: -save-temps=<value> Save intermediate compilation results.
! HELP-NEXT: -save-temps Save intermediate compilation results
! HELP-NEXT: -std=<value> Language standard to compile for
@@ -214,6 +218,10 @@
! HELP-FC1-NEXT: -pic-level <value> Value for __PIC__
! HELP-FC1-NEXT: -plugin <name> Use the named plugin action instead of the default action (use "help" to list available options)
! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
+! HELP-FC1-NEXT: -Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -R<remark> Enable the specified remark
! HELP-FC1-NEXT: -save-temps=<value> Save intermediate compilation results.
! HELP-FC1-NEXT: -save-temps Save intermediate compilation results
! HELP-FC1-NEXT: -std=<value> Language standard to compile for
diff --git a/flang/test/Driver/frontend-forwarding.f90 b/flang/test/Driver/frontend-forwarding.f90
index b57eb3ae33e0a7..520f4898feb0a6 100644
--- a/flang/test/Driver/frontend-forwarding.f90
+++ b/flang/test/Driver/frontend-forwarding.f90
@@ -22,6 +22,13 @@
! RUN: -fppc-native-vector-element-order \
! RUN: -mllvm -print-before-all \
! RUN: -save-temps=obj \
+! RUN: -Rpass \
+! RUN: -Rpass-missed \
+! RUN: -Rpass-analysis \
+! RUN: -Rno-pass \
+! RUN: -Reverything \
+! RUN: -Rno-everything \
+! RUN: -Rpass=inline \
! RUN: -P \
! RUN: | FileCheck %s
@@ -44,5 +51,12 @@
! CHECK: "-flang-experimental-hlfir"
! CHECK: "-fno-ppc-native-vector-element-order"
! CHECK: "-fppc-native-vector-element-order"
+! CHECK: "-Rpass"
+! CHECK: "-Rpass-missed"
+! CHECK: "-Rpass-analysis"
+! CHECK: "-Rno-pass"
+! CHECK: "-Reverything"
+! CHECK: "-Rno-everything"
+! CHECK: "-Rpass=inline"
! CHECK: "-mllvm" "-print-before-all"
! CHECK: "-save-temps=obj"
More information about the cfe-commits
mailing list