Skip to content

Commit 3bd7cbb

Browse files
committed
[Remarks][Docs] Enhance documentation for opt-remarks driver options
Add better documentation about the naming scheme, add a few more explicit descriptions and make the sphinx look better.
1 parent 68009c2 commit 3bd7cbb

File tree

3 files changed

+57
-18
lines changed

3 files changed

+57
-18
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,9 +1699,14 @@ Emit OpenMP code only for SIMD-based constructs.
16991699

17001700
.. option:: -foperator-arrow-depth=<arg>
17011701

1702-
.. option:: -foptimization-record-file=<arg>
1702+
.. option:: -foptimization-record-file=<file>
17031703

1704-
Specify the output name of the file containing the optimization remarks. Implies -fsave-optimization-record. On Darwin platforms, this cannot be used with multiple -arch <arch> options.
1704+
Implies -fsave-optimization-record. On Darwin platforms, this
1705+
cannot be used with multiple -arch <arch> options.
1706+
1707+
.. option:: -foptimization-record-passes=<regex>
1708+
1709+
Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)
17051710

17061711
.. option:: -foptimize-sibling-calls, -fno-optimize-sibling-calls
17071712

@@ -1834,6 +1839,12 @@ Turn on loop reroller
18341839

18351840
Generate a YAML optimization record file
18361841

1842+
.. program:: clang1
1843+
.. option:: -fsave-optimization-record=<format>
1844+
.. program:: clang
1845+
1846+
Generate an optimization record file in a specific format.
1847+
18371848
.. option:: -fseh-exceptions
18381849

18391850
Use SEH style exceptions

clang/docs/UsersManual.rst

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,10 @@ output format of the diagnostics that it generates.
324324

325325
.. _opt_fsave-optimization-record:
326326

327-
.. option:: -fsave-optimization-record[=<format>]
327+
.. option:: -f[no-]save-optimization-record[=<format>]
328328

329-
Write optimization remarks to a separate file.
329+
Enable optimization remarks during compilation and write them to a separate
330+
file.
330331

331332
This option, which defaults to off, controls whether Clang writes
332333
optimization reports to a separate file. By recording diagnostics in a file,
@@ -345,20 +346,45 @@ output format of the diagnostics that it generates.
345346
``-fsave-optimization-record=bitstream``: A binary format based on LLVM
346347
Bitstream.
347348

349+
The output file is controlled by :ref:`-foptimization-record-file <opt_foptimization-record-file>`.
350+
351+
In the absence of an explicit output file, the file is chosen using the
352+
following scheme:
353+
354+
``<base>.opt.<format>``
355+
356+
where ``<base>`` is based on the output file of the compilation (whether
357+
it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
358+
In other cases, it's based on the input file's stem. For example:
359+
360+
* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
361+
``out.opt.yaml``
362+
363+
* ``clang -fsave-optimization-record in.c -o out`` will generate
364+
``in.opt.yaml``
365+
366+
Compiling for multiple architectures will use the following scheme:
367+
368+
``<base>-<arch>.opt.<format>``
369+
370+
Note that this is only allowed on Darwin platforms and is incompatible with
371+
passing multiple ``-arch <arch>`` options.
372+
373+
When targeting (Thin)LTO, the base is derived from the output filename, and
374+
the extension is not dropped.
375+
376+
When targeting ThinLTO, the following scheme is used:
377+
378+
``<base>.opt.<format>.thin.<num>.<format>``
379+
348380
.. _opt_foptimization-record-file:
349381

350382
**-foptimization-record-file**
351-
Control the file to which optimization reports are written.
352-
353-
When optimization reports are being output (see
354-
:ref:`-fsave-optimization-record <opt_fsave-optimization-record>`), this
355-
option controls the file to which those reports are written.
383+
Control the file to which optimization reports are written. This implies
384+
:ref:`-fsave-optimization-record <opt_fsave-optimization-record>`.
356385

357-
If this option is not used, optimization records are output to a file named
358-
after the primary file being compiled. If that's "foo.c", for example,
359-
optimization records are output to "foo.opt.yaml". If a specific
360-
serialization format is specified, the file will be named
361-
"foo.opt.<format>".
386+
On Darwin platforms, this is incompatible with passing multiple
387+
``-arch <arch>`` options.
362388

363389
.. _opt_foptimization-record-passes:
364390

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,16 +1800,18 @@ def foperator_arrow_depth_EQ : Joined<["-"], "foperator-arrow-depth=">,
18001800
def fsave_optimization_record : Flag<["-"], "fsave-optimization-record">,
18011801
Group<f_Group>, HelpText<"Generate a YAML optimization record file">;
18021802
def fsave_optimization_record_EQ : Joined<["-"], "fsave-optimization-record=">,
1803-
Group<f_Group>, HelpText<"Generate an optimization record file in a specific format (default: YAML)">;
1803+
Group<f_Group>, HelpText<"Generate an optimization record file in a specific format">,
1804+
MetaVarName<"<format>">;
18041805
def fno_save_optimization_record : Flag<["-"], "fno-save-optimization-record">,
18051806
Group<f_Group>, Flags<[NoArgumentUnused]>;
18061807
def foptimization_record_file_EQ : Joined<["-"], "foptimization-record-file=">,
18071808
Group<f_Group>,
1808-
HelpText<"Specify the file name of any generated YAML optimization record">;
1809+
HelpText<"Specify the output name of the file containing the optimization remarks. Implies -fsave-optimization-record. On Darwin platforms, this cannot be used with multiple -arch <arch> options.">,
1810+
MetaVarName<"<file>">;
18091811
def foptimization_record_passes_EQ : Joined<["-"], "foptimization-record-passes=">,
18101812
Group<f_Group>,
1811-
HelpText<"Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)">;
1812-
1813+
HelpText<"Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)">,
1814+
MetaVarName<"<regex>">;
18131815

18141816
def ftest_coverage : Flag<["-"], "ftest-coverage">, Group<f_Group>;
18151817
def fvectorize : Flag<["-"], "fvectorize">, Group<f_Group>,

0 commit comments

Comments
 (0)