diff options
author | Victor Kingi <victor.kingi@arm.com> | 2023-07-27 21:57:54 +0000 |
---|---|---|
committer | Kiran Chandramohan <kiran.chandramohan@arm.com> | 2023-07-28 09:26:40 +0000 |
commit | f04ccadf35441b2e13b3ab30edeef251818fa9c7 (patch) | |
tree | c15a7479bf5428416ab7ef681a019d8a7b50fcf5 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 1478d4dc8dc44c109bff1bbe0486cc40674a0ee2 (diff) | |
download | llvm-f04ccadf35441b2e13b3ab30edeef251818fa9c7.zip llvm-f04ccadf35441b2e13b3ab30edeef251818fa9c7.tar.gz llvm-f04ccadf35441b2e13b3ab30edeef251818fa9c7.tar.bz2 |
[Flang] Add support for fsave-optimization-record
Add support for generating and saving the optimization record.
Optimization record lists the optimizations performed by LLVM.
This patch enables the flag in Flang. Clang handles this functionality
using the BackendConsumer which Flang doesn't have, hence, was
implemented in CodeGenAction::executeAction
FlangOption added to all variants of fsave-optimization-record in
clang/include/clang/Driver/Options.td . Clang handles it the
same way.
opt_record_file, opt_record_passes and opt_record_format flags
in Options.td were moved out of the group [CC1Option, NoDriverOption]
to allow flang -fc1 support.
The renderRemarksOptions and willEmitRemarks functions in
clang/lib/Driver/ToolChains/Flang.cpp follow same syntax as clang.
In flang/lib/Frontend/CompilerInvocation.cpp we update the field
OptRecordFile with the provided optimization file value. Clang
doesn't do this as it processes the Options.td, mapping the
OptRecordFile earlier on.
Reviewed By: awarzynski, tblah
Differential Revision: https://reviews.llvm.org/D155452
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index b1f0d27..90b93b2 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -163,13 +163,12 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, opts.DebugPassManager = 1; if (args.hasFlag(clang::driver::options::OPT_fstack_arrays, - clang::driver::options::OPT_fno_stack_arrays, false)) { + clang::driver::options::OPT_fno_stack_arrays, false)) opts.StackArrays = 1; - } + if (args.hasFlag(clang::driver::options::OPT_floop_versioning, - clang::driver::options::OPT_fno_loop_versioning, false)) { + clang::driver::options::OPT_fno_loop_versioning, false)) opts.LoopVersioning = 1; - } for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ)) opts.LLVMPassPlugins.push_back(a->getValue()); @@ -190,6 +189,19 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, opts.PrepareForThinLTO = true; } + // -f[no-]save-optimization-record[=<format>] + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_opt_record_file)) + opts.OptRecordFile = a->getValue(); + + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_opt_record_format)) + opts.OptRecordFormat = a->getValue(); + + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_opt_record_passes)) + opts.OptRecordPasses = a->getValue(); + if (auto *a = args.getLastArg(clang::driver::options::OPT_save_temps_EQ)) opts.SaveTempsDir = a->getValue(); |