r363573 - [Remarks] Extend -fsave-optimization-record to specify the format
Francis Visoiu Mistrih via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 09:06:00 PDT 2019
Author: thegameg
Date: Mon Jun 17 09:06:00 2019
New Revision: 363573
URL: http://llvm.org/viewvc/llvm-project?rev=363573&view=rev
Log:
[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.
Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/opt-record-MIR.c
cfe/trunk/test/CodeGen/opt-record.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c
Modified: cfe/trunk/docs/UsersManual.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jun 17 09:06:00 2019
@@ -324,13 +324,21 @@ output format of the diagnostics that it
.. _opt_fsave-optimization-record:
-**-fsave-optimization-record**
- Write optimization remarks to a YAML file.
+.. option:: -fsave-optimization-record[=<format>]
+
+ Write optimization remarks to a separate file.
This option, which defaults to off, controls whether Clang writes
- optimization reports to a YAML file. By recording diagnostics in a file,
- using a structured YAML format, users can parse or sort the remarks in a
- convenient way.
+ optimization reports to a separate file. By recording diagnostics in a file,
+ users can parse or sort the remarks in a convenient way.
+
+ By default, the serialization format is YAML.
+
+ The supported serialization formats are:
+
+ - .. _opt_fsave_optimization_record_yaml:
+
+ ``-fsave-optimization-record=yaml``: A structured YAML format.
.. _opt_foptimization-record-file:
Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Mon Jun 17 09:06:00 2019
@@ -246,6 +246,9 @@ public:
/// records.
std::string OptRecordPasses;
+ /// The format used for serializing remarks (default: YAML)
+ std::string OptRecordFormat;
+
/// The name of the partition that symbols are assigned to, specified with
/// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
std::string SymbolPartition;
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jun 17 09:06:00 2019
@@ -230,6 +230,8 @@ def err_drv_emit_llvm_link : Error<
"-emit-llvm cannot be used when linking">;
def err_drv_optimization_remark_pattern : Error<
"in pattern '%1': %0">;
+def err_drv_optimization_remark_format : Error<
+ "unknown remark serializer format: '%0'">;
def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, please use [no]simd instead">;
def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
def err_drv_omp_host_ir_file_not_found : Error<
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun 17 09:06:00 2019
@@ -636,6 +636,8 @@ def opt_record_file : Separate<["-"], "o
HelpText<"File name to use for YAML optimization record output">;
def opt_record_passes : Separate<["-"], "opt-record-passes">,
HelpText<"Only record remark information for passes whose names match the given regular expression">;
+def opt_record_format : Separate<["-"], "opt-record-format">,
+ HelpText<"The format used for serializing remarks (default: YAML)">;
def print_stats : Flag<["-"], "print-stats">,
HelpText<"Print performance metrics and statistics">;
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jun 17 09:06:00 2019
@@ -1717,6 +1717,8 @@ def foperator_arrow_depth_EQ : Joined<["
def fsave_optimization_record : Flag<["-"], "fsave-optimization-record">,
Group<f_Group>, HelpText<"Generate a YAML optimization record file">;
+def fsave_optimization_record_EQ : Joined<["-"], "fsave-optimization-record=">,
+ Group<f_Group>, HelpText<"Generate an optimization record file in a specific format (default: YAML)">;
def fno_save_optimization_record : Flag<["-"], "fno-save-optimization-record">,
Group<f_Group>, Flags<[NoArgumentUnused]>;
def foptimization_record_file_EQ : Joined<["-"], "foptimization-record-file=">,
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jun 17 09:06:00 2019
@@ -1428,6 +1428,7 @@ static void runThinLTOBackend(ModuleSumm
Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
Conf.RemarksFilename = CGOpts.OptRecordFile;
Conf.RemarksPasses = CGOpts.OptRecordPasses;
+ Conf.RemarksFormat = CGOpts.OptRecordFormat;
Conf.SplitDwarfFile = CGOpts.SplitDwarfFile;
Conf.SplitDwarfOutput = CGOpts.SplitDwarfOutput;
switch (Action) {
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Jun 17 09:06:00 2019
@@ -266,6 +266,7 @@ namespace clang {
Expected<std::unique_ptr<llvm::ToolOutputFile>> OptRecordFileOrErr =
setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
CodeGenOpts.OptRecordPasses,
+ CodeGenOpts.OptRecordFormat,
CodeGenOpts.DiagnosticsWithHotness,
CodeGenOpts.DiagnosticsHotnessThreshold);
@@ -279,6 +280,10 @@ namespace clang {
[&](const RemarkSetupPatternError &E) {
Diags.Report(diag::err_drv_optimization_remark_pattern)
<< E.message() << CodeGenOpts.OptRecordPasses;
+ },
+ [&](const RemarkSetupFormatError &E) {
+ Diags.Report(diag::err_drv_optimization_remark_format)
+ << CodeGenOpts.OptRecordFormat;
});
return;
}
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jun 17 09:06:00 2019
@@ -5079,6 +5079,8 @@ void Clang::ConstructJob(Compilation &C,
if (Args.hasFlag(options::OPT_fsave_optimization_record,
options::OPT_foptimization_record_file_EQ,
options::OPT_fno_save_optimization_record, false) ||
+ Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
+ options::OPT_fno_save_optimization_record, false) ||
Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
options::OPT_fno_save_optimization_record, false)) {
CmdArgs.push_back("-opt-record-file");
@@ -5119,6 +5121,12 @@ void Clang::ConstructJob(Compilation &C,
CmdArgs.push_back("-opt-record-passes");
CmdArgs.push_back(A->getValue());
}
+
+ if (const Arg *A =
+ Args.getLastArg(options::OPT_fsave_optimization_record_EQ)) {
+ CmdArgs.push_back("-opt-record-format");
+ CmdArgs.push_back(A->getValue());
+ }
}
bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,
Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Jun 17 09:06:00 2019
@@ -462,6 +462,7 @@ void darwin::Linker::ConstructJob(Compil
// For LTO, pass the name of the optimization record file and other
// opt-remarks flags.
if (Args.hasFlag(options::OPT_fsave_optimization_record,
+ options::OPT_fsave_optimization_record_EQ,
options::OPT_fno_save_optimization_record, false)) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-lto-pass-remarks-output");
@@ -492,6 +493,14 @@ void darwin::Linker::ConstructJob(Compil
std::string("-lto-pass-remarks-filter=") + A->getValue();
CmdArgs.push_back(Args.MakeArgString(Passes));
}
+
+ if (const Arg *A =
+ Args.getLastArg(options::OPT_fsave_optimization_record_EQ)) {
+ CmdArgs.push_back("-mllvm");
+ std::string Format =
+ std::string("-lto-pass-remarks-format=") + A->getValue();
+ CmdArgs.push_back(Args.MakeArgString(Format));
+ }
}
// Propagate the -moutline flag to the linker in LTO.
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jun 17 09:06:00 2019
@@ -1237,6 +1237,11 @@ static bool ParseCodeGenArgs(CodeGenOpti
NeedLocTracking = true;
}
+ if (Arg *A = Args.getLastArg(OPT_opt_record_format)) {
+ Opts.OptRecordFormat = A->getValue();
+ NeedLocTracking = true;
+ }
+
if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
Opts.OptimizationRemarkPattern =
GenerateOptimizationRemarkRegex(Diags, Args, A);
Modified: cfe/trunk/test/CodeGen/opt-record-MIR.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/opt-record-MIR.c?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/opt-record-MIR.c (original)
+++ cfe/trunk/test/CodeGen/opt-record-MIR.c Mon Jun 17 09:06:00 2019
@@ -5,6 +5,8 @@
// RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
// RUN: %clang_cc1 -triple arm64-apple-ios -S -o /dev/null %s -O2 -dwarf-column-info -opt-record-file %t.yaml -opt-record-passes asm-printer
// RUN: cat %t.yaml | FileCheck -check-prefix=PASSES %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -S -o /dev/null %s -O2 -dwarf-column-info -opt-record-file %t.yaml -opt-record-format yaml
+// RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
void bar(float);
Modified: cfe/trunk/test/CodeGen/opt-record.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/opt-record.c?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/opt-record.c (original)
+++ cfe/trunk/test/CodeGen/opt-record.c Mon Jun 17 09:06:00 2019
@@ -6,6 +6,9 @@
// RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-passes inline -emit-obj
// RUN: cat %t.yaml | FileCheck -check-prefix=CHECK-PASSES %s
// RUN: not %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-passes "(foo" -emit-obj 2>&1 | FileCheck -check-prefix=CHECK-PATTERN-ERROR %s
+// RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-format yaml -emit-obj
+// RUN: cat %t.yaml | FileCheck %s
+// RUN: not %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-format "unknown-format" -emit-obj 2>&1 | FileCheck -check-prefix=CHECK-FORMAT-ERROR %s
// REQUIRES: x86-registered-target
void bar();
@@ -37,3 +40,5 @@ void Test(int *res, int *c, int *d, int
// CHECK-PASSES-NOT: loop-vectorize
// CHECK-PATTERN-ERROR: error: in pattern '(foo': parentheses not balanced
+
+// CHECK-FORMAT-ERROR: error: unknown remark serializer format: 'unknown-format'
Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Mon Jun 17 09:06:00 2019
@@ -330,6 +330,10 @@
// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -foptimization-record-passes=inline -### -o foo/bar.out 2> %t.log
// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_PASSES %s < %t.log
// PASS_REMARKS_WITH_PASSES: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-filter=inline"
+//
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record=some-format -### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_FORMAT %s < %t.log
+// PASS_REMARKS_WITH_FORMAT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-format=some-format"
// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
Modified: cfe/trunk/test/Driver/opt-record.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opt-record.c?rev=363573&r1=363572&r2=363573&view=diff
==============================================================================
--- cfe/trunk/test/Driver/opt-record.c (original)
+++ cfe/trunk/test/Driver/opt-record.c Mon Jun 17 09:06:00 2019
@@ -15,6 +15,9 @@
// RUN: %clang -### -S -o FOO -fsave-optimization-record -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-PASSES
// RUN: %clang -### -S -o FOO -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-PASSES
// RUN: %clang -### -S -o FOO -foptimization-record-passes=inline -fno-save-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-FOPT-DISABLE-PASSES
+// RUN: %clang -### -S -o FOO -fsave-optimization-record -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
+// RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
+// RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format -fno-save-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-FOPT-DISABLE-FORMAT
//
// CHECK: "-cc1"
// CHECK: "-opt-record-file" "FOO.opt.yaml"
@@ -32,3 +35,8 @@
// CHECK-EQ-PASSES: "-opt-record-passes" "inline"
// CHECK-FOPT-DISABLE-PASSES-NOT: "-fno-save-optimization-record"
+
+// CHECK-EQ-FORMAT: "-cc1"
+// CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
+
+// CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"
More information about the cfe-commits
mailing list