Skip to content

Commit

Permalink
[Flang][Driver] Enable Rpass and other R family options.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
victorkingi authored and kiranchandramohan committed Aug 10, 2023
1 parent f3016c3 commit 6e13e3c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
33 changes: 20 additions & 13 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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 {

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions flang/test/Driver/driver-help-hidden.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Driver/driver-help.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions flang/test/Driver/frontend-forwarding.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"

0 comments on commit 6e13e3c

Please sign in to comment.