[all-commits] [llvm/llvm-project] 869385: [flang][driver] Add support for `-O{0|1|2|3}`
Andrzej WarzyĆski via All-commits
all-commits at lists.llvm.org
Mon Jun 27 03:09:18 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 869385b11c32032d02f5f24fcd21c694fb073850
https://github.com/llvm/llvm-project/commit/869385b11c32032d02f5f24fcd21c694fb073850
Author: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: 2022-06-27 (Mon, 27 Jun 2022)
Changed paths:
M clang/include/clang/Driver/Options.td
M clang/lib/Driver/ToolChains/Flang.cpp
A flang/include/flang/Frontend/CodeGenOptions.def
A flang/include/flang/Frontend/CodeGenOptions.h
M flang/include/flang/Frontend/CompilerInvocation.h
M flang/include/flang/Frontend/FrontendActions.h
M flang/lib/Frontend/CMakeLists.txt
A flang/lib/Frontend/CodeGenOptions.cpp
M flang/lib/Frontend/CompilerInvocation.cpp
M flang/lib/Frontend/FrontendActions.cpp
A flang/test/Driver/default-optimization-pipelines.f90
M flang/test/Driver/driver-help.f90
A flang/test/Driver/flang_f_opts.f90
Log Message:
-----------
[flang][driver] Add support for `-O{0|1|2|3}`
This patch adds support for most common optimisation compiler flags:
`-O{0|1|2|3}`. This is implemented in both the compiler and frontend
drivers. At this point, these options are only used to configure the
LLVM optimisation pipelines (aka middle-end). LLVM backend or MLIR/FIR
optimisations are not supported yet.
Previously, the middle-end pass manager was only required when
generating LLVM bitcode (i.e. for `flang-new -c -emit-llvm <file>` or
`flang-new -fc1 -emit-llvm-bc <file>`). With this change, it becomes
required for all frontend actions that are represented as
`CodeGenAction` and `CodeGenAction::executeAction` is refactored
accordingly (in the spirit of better code re-use).
Additionally, the `-fdebug-pass-manager` option is enabled to facilitate
testing. This flag can be used to configure the pass manager to print
the middle-end passes that are being run. Similar option exists in Clang
and the semantics in Flang are identical. This option translates to
extra configuration when setting up the pass manager. This is
implemented in `CodeGenAction::runOptimizationPipeline`.
This patch also adds some bolier plate code to manage code-gen options
("code-gen" refers to generating machine code in LLVM in this context).
This was extracted from Clang. In Clang, it simplifies defining code-gen
options and enables option marshalling. In Flang, option marshalling is
not yet supported (we might do at some point), but being able to
auto-generate some code with macros is beneficial. This will become
particularly apparent when we start adding more options (at least in
Clang, the list of code-gen options is rather long).
Differential Revision: https://reviews.llvm.org/D128043
More information about the All-commits
mailing list