[Flang] Add support to use LTO specific pipelines
authorNadeem, Usman <mnadeem@quicinc.com>
Wed, 1 Feb 2023 23:09:23 +0000 (15:09 -0800)
committerNadeem, Usman <mnadeem@quicinc.com>
Thu, 9 Mar 2023 21:27:43 +0000 (13:27 -0800)
commit0fdfb65e2624aa151cb07a9c842331f7af9a21ca
treec18e354998634bc4c2f3352929c938b76a81b36a
parent8be84e1e31126a60b585a53a2943d0a6eafe4be2
[Flang] Add support to use LTO specific pipelines

Thin and full LTO modes use different pre-link pipelines compared to
regular compilation. This patch adds support for calling those pipelines.

This patch closely mimics Clang's implementation with the exception that I
changed the codegen option name from `PrepareForLTO` to `PrepareForFullLTO`
to be more precise.

With this patch:
  - Compilation for full LTO should be as we expect (except possibly
  missing optimizations enabled by module summaries which we do not
  produce yet).
  - thinLTO uses the correct prelink pipeline but will use the postlink
  backend for fullLTO due to missing metadata and summary in the llvm
  module. I have added a warning regarding this: `flang-new: warning: the
  option '-flto=thin' is a work in progress`.

Differential Revision: https://reviews.llvm.org/D142420

Change-Id: I6b94b775b5b8e93340e520c5cd4bf60834b2e209
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/CodeGenOptions.def
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/default-optimization-pipelines.f90
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/lto-bc.f90 [new file with mode: 0644]
flang/test/Driver/lto-flags.f90 [new file with mode: 0644]