Skip to content

Commit c71ba78

Browse files
committed
Rename flag
1 parent 28e1eb2 commit c71ba78

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

clang/docs/UsersManual.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,6 +3035,38 @@ indexed format, regardeless whether it is produced by frontend or the IR pass.
30353035
overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
30363036
by the target, or ``single`` otherwise.
30373037

3038+
.. option:: -fprofile-generate-temporal
3039+
3040+
Enables the temporal profiling extension for IRPGO to improve startup time by
3041+
reducing ``.text`` section page faults. To do this, we instrument function
3042+
timestamps to measure when each function is called for the first time and use
3043+
this data to generate a function order to improve startup.
3044+
3045+
The profile is generated as normal.
3046+
3047+
.. code-block:: console
3048+
3049+
$ clang++ -O2 -fprofile-generate -fprofile-generate-temporal code.cc -o code
3050+
$ ./code
3051+
$ llvm-profdata merge -o code.profdata yyy/zzz
3052+
3053+
Using the resulting profile, we can either generate a function order to pass
3054+
to the linker.
3055+
3056+
.. code-block:: console
3057+
3058+
$ llvm-profdata order code.profdata -o code.orderfile
3059+
$ clang++ -O2 -Wl,--symbol-ordering-file=code.orderfile code.cc -o code
3060+
3061+
Or it can be passed to the linker directly.
3062+
3063+
.. code-block:: console
3064+
3065+
$ clang++ -O2 -Wl,--irpgo-profile=code.profdata,--bp-startup-sort=function code.cc -o code
3066+
3067+
For more information, please read the RFC:
3068+
https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068
3069+
30383070
Fine Tuning Profile Collection
30393071
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30403072

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,9 +1796,9 @@ def fprofile_generate_cold_function_coverage : Flag<["-"], "fprofile-generate-co
17961796
def fprofile_generate_cold_function_coverage_EQ : Joined<["-"], "fprofile-generate-cold-function-coverage=">,
17971797
Group<f_Group>, Visibility<[ClangOption, CLOption]>, MetaVarName<"<directory>">,
17981798
HelpText<"Generate instrumented code to collect coverage info for cold functions into <directory>/default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
1799-
def fprofile_generate_temporal_instrumentation : Flag<["-"], "fprofile-generate-temporal-instrumentation">,
1799+
def fprofile_generate_temporal : Flag<["-"], "fprofile-generate-temporal">,
18001800
Group<f_Group>, Visibility<[ClangOption, CLOption]>,
1801-
HelpText<"Generate instrumented code to collect temporal information. See this RFC for details: https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068">;
1801+
HelpText<"Generate instrumented code to collect temporal information">;
18021802
def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
18031803
Group<f_Group>, Visibility<[ClangOption, CLOption]>,
18041804
HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
@@ -1894,7 +1894,7 @@ defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
18941894
" pseudo probes for sample profiling">>;
18951895
def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
18961896
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
1897-
HelpText<"Generate instrumented code to collect order file into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var). Deprecated, please use -fprofile-generate-temporal-instrumentation">;
1897+
HelpText<"Generate instrumented code to collect order file into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var). Deprecated, please use -fprofile-generate-temporal">;
18981898
def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
18991899
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
19001900
HelpText<"Filename defining the list of functions/files to instrument. "

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
662662
CmdArgs.push_back("--pgo-function-entry-coverage");
663663
}
664664

665-
if (auto *A = Args.getLastArg(
666-
options::OPT_fprofile_generate_temporal_instrumentation)) {
665+
if (auto *A = Args.getLastArg(options::OPT_fprofile_generate_temporal)) {
667666
if (!PGOGenerateArg && !CSPGOGenerateArg)
668667
D.Diag(clang::diag::err_drv_argument_only_allowed_with)
669668
<< A->getSpelling() << "-fprofile-generate or -fcs-profile-generate";
@@ -8059,7 +8058,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
80598058
Args.getLastArg(options::OPT_forder_file_instrumentation)) {
80608059
D.Diag(diag::warn_drv_deprecated_arg)
80618060
<< A->getAsString(Args) << /*hasReplacement=*/true
8062-
<< "-fprofile-generate-temporal-instrumentation";
8061+
<< "-fprofile-generate-temporal";
80638062
CmdArgs.push_back("-forder-file-instrumentation");
80648063
// Enable order file instrumentation when ThinLTO is not on. When ThinLTO is
80658064
// on, we need to pass these flags as linker flags and that will be handled

clang/test/Driver/clang_f_opts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424
// CHECK-WARNING-DAG: optimization flag '-fno-devirtualize-speculatively' is not supported
425425
// CHECK-WARNING-DAG: the flag '-fslp-vectorize-aggressive' has been deprecated and will be ignored
426426
// CHECK-WARNING-DAG: the flag '-fno-slp-vectorize-aggressive' has been deprecated and will be ignored
427-
// CHECK-WARNING-DAG: argument '-forder-file-instrumentation' is deprecated, use '-fprofile-generate-temporal-instrumentation' instead
427+
// CHECK-WARNING-DAG: argument '-forder-file-instrumentation' is deprecated, use '-fprofile-generate-temporal' instead
428428

429429
// Test that we mute the warning on these
430430
// RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument \

clang/test/Driver/fprofile-generate-temporal-instrumentation.c

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang -### -c -fprofile-generate -fprofile-generate-temporal %s 2>&1 | FileCheck %s
2+
// RUN: %clang -### -c -fcs-profile-generate -fprofile-generate-temporal %s 2>&1 | FileCheck %s
3+
// RUN: not %clang -### -c -fprofile-generate-temporal %s 2>&1 | FileCheck %s --check-prefix=ERR
4+
5+
// CHECK: "-mllvm" "--pgo-temporal-instrumentation"
6+
7+
// ERR: '-fprofile-generate-temporal' only allowed with '-fprofile-generate or -fcs-profile-generate'

0 commit comments

Comments
 (0)