[lld] r355984 - Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 14:22:28 PDT 2019
Author: thegameg
Date: Tue Mar 12 14:22:27 2019
New Revision: 355984
URL: http://llvm.org/viewvc/llvm-project?rev=355984&view=rev
Log:
Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"
Currently we have -Rpass for filtering the remarks that are displayed as
diagnostics, but when using -fsave-optimization-record, there is no way
to filter the remarks while generating them.
This adds support for filtering remarks by passes using a regex.
Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline`
will only emit the remarks coming from the pass `inline`.
This adds:
* `-fsave-optimization-record` to the driver
* `-opt-record-passes` to cc1
* `-lto-pass-remarks-filter` to the LTOCodeGenerator
* `--opt-remarks-passes` to lld
* `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2
* `-opt-remarks-passes` to gold-plugin
Differential Revision: https://reviews.llvm.org/D59268
Original llvm-svn: 355964
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/LTO.cpp
lld/trunk/ELF/Options.td
lld/trunk/docs/ld.lld.1
lld/trunk/test/ELF/lto/opt-remarks.ll
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Mar 12 14:22:27 2019
@@ -99,6 +99,7 @@ struct Configuration {
llvm::StringRef MapFile;
llvm::StringRef OutputFile;
llvm::StringRef OptRemarksFilename;
+ llvm::StringRef OptRemarksPasses;
llvm::StringRef ProgName;
llvm::StringRef SoName;
llvm::StringRef Sysroot;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Mar 12 14:22:27 2019
@@ -818,6 +818,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->OFormatBinary = isOutputFormatBinary(Args);
Config->Omagic = Args.hasFlag(OPT_omagic, OPT_no_omagic, false);
Config->OptRemarksFilename = Args.getLastArgValue(OPT_opt_remarks_filename);
+ Config->OptRemarksPasses = Args.getLastArgValue(OPT_opt_remarks_passes);
Config->OptRemarksWithHotness = Args.hasArg(OPT_opt_remarks_with_hotness);
Config->Optimize = args::getInteger(Args, OPT_O, 1);
Config->OrphanHandling = getOrphanHandling(Args);
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue Mar 12 14:22:27 2019
@@ -97,6 +97,7 @@ static lto::Config createConfig() {
// Set up optimization remarks if we've been asked to.
C.RemarksFilename = Config->OptRemarksFilename;
+ C.RemarksPasses = Config->OptRemarksPasses;
C.RemarksWithHotness = Config->OptRemarksWithHotness;
C.SampleProfile = Config->LTOSampleProfile;
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Tue Mar 12 14:22:27 2019
@@ -454,6 +454,8 @@ def disable_verify: F<"disable-verify">;
defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
HelpText<"YAML output file for optimization remarks">;
+def opt_remarks_passes: Separate<["--"], "opt-remarks-passes">,
+ HelpText<"Regex for the passes that need to be serialized to the output file">;
def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
HelpText<"Include hotness information in the optimization remarks file">;
defm plugin_opt: Eq<"plugin-opt", "specifies LTO options for compatibility with GNU linkers">;
Modified: lld/trunk/docs/ld.lld.1
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/docs/ld.lld.1?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/docs/ld.lld.1 (original)
+++ lld/trunk/docs/ld.lld.1 Tue Mar 12 14:22:27 2019
@@ -329,6 +329,9 @@ Set the text and data sections to be rea
.It Fl -opt-remarks-filename Ar file
Write optimization remarks in YAML format to
.Ar file .
+.It Fl -opt-remarks-passes Ar pass-regex
+Filter optimization remarks by only allowing the passes matching
+.Ar pass-regex .
.It Fl -opt-remarks-with-hotness
Include hotness information in the optimization remarks file.
.It Fl -orphan-handling Ns = Ns Ar mode
Modified: lld/trunk/test/ELF/lto/opt-remarks.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/opt-remarks.ll?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/opt-remarks.ll (original)
+++ lld/trunk/test/ELF/lto/opt-remarks.ll Tue Mar 12 14:22:27 2019
@@ -8,6 +8,9 @@
; RUN: %t.o -o %t -shared
; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
; RUN: cat %t.hot.yaml | FileCheck %s -check-prefix=YAML-HOT
+; RUN: ld.lld --opt-remarks-filename %t1.yaml --opt-remarks-passes inline %t.o \
+; RUN: -o /dev/null -shared
+; RUN: cat %t1.yaml | FileCheck %s -check-prefix=YAML-PASSES
; Check that @tinkywinky is inlined after optimizations.
; CHECK-LABEL: define i32 @main
@@ -48,6 +51,8 @@
; YAML-HOT-NEXT: - String: ')'
; YAML-HOT-NEXT: ...
+; YAML-PASSES: Pass: inline
+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-scei-ps4"
More information about the llvm-commits
mailing list