Skip to content

Commit 28e1eb2

Browse files
committed
[InstrProf] Add frontent temporal profiling flag
1 parent 878a574 commit 28e1eb2

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,6 +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">,
1800+
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">;
17991802
def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
18001803
Group<f_Group>, Visibility<[ClangOption, CLOption]>,
18011804
HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
@@ -1891,7 +1894,7 @@ defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
18911894
" pseudo probes for sample profiling">>;
18921895
def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
18931896
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
1894-
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 temporal profiling.">;
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">;
18951898
def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
18961899
Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
18971900
HelpText<"Filename defining the list of functions/files to instrument. "

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,15 @@ 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)) {
667+
if (!PGOGenerateArg && !CSPGOGenerateArg)
668+
D.Diag(clang::diag::err_drv_argument_only_allowed_with)
669+
<< A->getSpelling() << "-fprofile-generate or -fcs-profile-generate";
670+
CmdArgs.push_back("-mllvm");
671+
CmdArgs.push_back("--pgo-temporal-instrumentation");
672+
}
673+
665674
Arg *PGOGenArg = nullptr;
666675
if (PGOGenerateArg) {
667676
assert(!CSPGOGenerateArg);
@@ -8050,7 +8059,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
80508059
Args.getLastArg(options::OPT_forder_file_instrumentation)) {
80518060
D.Diag(diag::warn_drv_deprecated_arg)
80528061
<< A->getAsString(Args) << /*hasReplacement=*/true
8053-
<< "-mllvm -pgo-temporal-instrumentation";
8062+
<< "-fprofile-generate-temporal-instrumentation";
80548063
CmdArgs.push_back("-forder-file-instrumentation");
80558064
// Enable order file instrumentation when ThinLTO is not on. When ThinLTO is
80568065
// 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 '-mllvm -pgo-temporal-instrumentation' instead
427+
// CHECK-WARNING-DAG: argument '-forder-file-instrumentation' is deprecated, use '-fprofile-generate-temporal-instrumentation' instead
428428

429429
// Test that we mute the warning on these
430430
// RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument \
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-instrumentation %s 2>&1 | FileCheck %s
2+
// RUN: %clang -### -c -fcs-profile-generate -fprofile-generate-temporal-instrumentation %s 2>&1 | FileCheck %s
3+
// RUN: not %clang -### -c -fprofile-generate-temporal-instrumentation %s 2>&1 | FileCheck %s --check-prefix=ERR
4+
5+
// CHECK: "-mllvm" "--pgo-temporal-instrumentation"
6+
7+
// ERR: '-fprofile-generate-temporal-instrumentation' only allowed with '-fprofile-generate or -fcs-profile-generate'

0 commit comments

Comments
 (0)