[clang] Pass-through remarks options to linker
authorWei Wang <apollo.mobility@gmail.com>
Wed, 28 Oct 2020 00:11:26 +0000 (17:11 -0700)
committerWei Wang <apollo.mobility@gmail.com>
Wed, 28 Oct 2020 00:23:32 +0000 (17:23 -0700)
commitc4868700c58078d0f4c71fab5af2bb73270d2d9f
treec41811d3df567ce0ef1a24ea18823f3125fc683a
parentbcb8a119df210753c5f1a3ac346d49597fef0f51
[clang] Pass-through remarks options to linker

Summary:
Propagate driver commandline remarks options to linker when LTO is enabled.

This gives novice user a convenient way to collect and filter remarks throughout
a typical toolchain invocation with sample profile and LTO using single switch
from the clang driver.

A typical use of this option from clang command-line:

* Using -Rpass* options to print remarks to screen:

  clang -fuse-ld=lld -flto=thin -fprofile-sample-use=foo_sample.txt
   -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline
   -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=100 -o foo foo.cpp

  Remarks will be dumped to screen from both pre-lto and lto
  compilation.

* Using serialized remarks options

  clang -fuse-ld=lld -flto=thin -fprofile-sample-use=foo_sample.txt
   -fsave-optimization-record
   -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=100 -o foo foo.cpp

  This will produce multiple yaml files containing optimization remarks:
  1. foo.opt.yaml : remarks from pre-lto
  2. foo.opt.ld.yaml.thin.1.yaml: remark during lto

  Differential Revision: https://reviews.llvm.org/D85810
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/opt-record.c