[Remarks] Extend -fsave-optimization-record to specify the format
Use -fsave-optimization-record=<format> to specify a different format
than the default, which is YAML.
For now, only YAML is supported.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@363573 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/ELF/Config.h b/ELF/Config.h
index ac5087c..3b30879 100644
--- a/ELF/Config.h
+++ b/ELF/Config.h
@@ -100,6 +100,7 @@
llvm::StringRef OutputFile;
llvm::StringRef OptRemarksFilename;
llvm::StringRef OptRemarksPasses;
+ llvm::StringRef OptRemarksFormat;
llvm::StringRef ProgName;
llvm::StringRef PrintSymbolOrder;
llvm::StringRef SoName;
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
index e4c1b79..008a6cd 100644
--- a/ELF/Driver.cpp
+++ b/ELF/Driver.cpp
@@ -857,6 +857,7 @@
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->OptRemarksFormat = Args.getLastArgValue(OPT_opt_remarks_format);
Config->Optimize = args::getInteger(Args, OPT_O, 1);
Config->OrphanHandling = getOrphanHandling(Args);
Config->OutputFile = Args.getLastArgValue(OPT_o);
diff --git a/ELF/LTO.cpp b/ELF/LTO.cpp
index eb0f75e..3612059 100644
--- a/ELF/LTO.cpp
+++ b/ELF/LTO.cpp
@@ -99,6 +99,7 @@
C.RemarksFilename = Config->OptRemarksFilename;
C.RemarksPasses = Config->OptRemarksPasses;
C.RemarksWithHotness = Config->OptRemarksWithHotness;
+ C.RemarksFormat = Config->OptRemarksFormat;
C.SampleProfile = Config->LTOSampleProfile;
C.UseNewPM = Config->LTONewPassManager;
diff --git a/ELF/Options.td b/ELF/Options.td
index 6c6222c..d45d9aa 100644
--- a/ELF/Options.td
+++ b/ELF/Options.td
@@ -485,6 +485,8 @@
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">;
+def opt_remarks_format: Separate<["--"], "opt-remarks-format">,
+ HelpText<"The format used for serializing remarks (default: YAML)">;
defm plugin_opt: Eq<"plugin-opt", "specifies LTO options for compatibility with GNU linkers">;
def save_temps: F<"save-temps">;
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
diff --git a/test/ELF/lto/opt-remarks.ll b/test/ELF/lto/opt-remarks.ll
index cce886c..013e28e 100644
--- a/test/ELF/lto/opt-remarks.ll
+++ b/test/ELF/lto/opt-remarks.ll
@@ -11,6 +11,9 @@
; 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
+; RUN: ld.lld --opt-remarks-filename %t1.yaml --opt-remarks-format yaml %t.o \
+; RUN: -o /dev/null -shared
+; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
; Check that @tinkywinky is inlined after optimizations.
; CHECK-LABEL: define i32 @main