Skip to content

Commit 6089e4f

Browse files
committed
add sample- prefix and improve test
1 parent 290d0b9 commit 6089e4f

File tree

6 files changed

+37
-23
lines changed

6 files changed

+37
-23
lines changed

clang/docs/UsersManual.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,9 +3394,9 @@ This can be done using the ``-fprofile-list`` option.
33943394
33953395
$ clang++ -O2 -fprofile-instr-generate -fcoverage-mapping -fprofile-list=fun.list -fprofile-list=code.list code.cc -o code
33963396
3397-
Supported sections are ``[clang]``, ``[llvm]``, ``[csllvm]``, and ``[coldcov]`` representing
3398-
clang PGO, IRPGO, CSIRPGO and cold function coverage, respectively. Supported prefixes are
3399-
``function`` and ``source``. Supported categories are ``allow``, ``skip``, and ``forbid``.
3397+
Supported sections are ``[clang]``, ``[llvm]``, ``[csllvm]``, and ``[sample-coldcov]`` representing
3398+
clang PGO, IRPGO, CSIRPGO and sample PGO based cold function coverage, respectively. Supported prefixes
3399+
are ``function`` and ``source``. Supported categories are ``allow``, ``skip``, and ``forbid``.
34003400
``skip`` adds the ``skipprofile`` attribute while ``forbid`` adds the
34013401
``noprofile`` attribute to the appropriate function. Use
34023402
``default:<allow|skip|forbid>`` to specify the default category.

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
8686
// to use with PGO.
8787
ProfileIRInstr, // IR level PGO instrumentation in LLVM.
8888
ProfileCSIRInstr, // IR level PGO context sensitive instrumentation in LLVM.
89-
ProfileIRColdCov, // IR level cold function coverage instrumentation in
90-
// LLVM.
89+
ProfileIRSampleColdCov, // IR level sample pgo based cold function coverage
90+
// instrumentation in LLVM.
9191
};
9292

9393
enum EmbedBitcodeKind {

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7732,9 +7732,9 @@ def fpatchable_function_entry_section_EQ
77327732
HelpText<"Use Section instead of __patchable_function_entries">,
77337733
MarshallingInfoString<CodeGenOpts<"PatchableFunctionEntrySection">>;
77347734
def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
7735-
HelpText<"Enable PGO instrumentation">, Values<"none,clang,llvm,csllvm,coldcov">,
7735+
HelpText<"Enable PGO instrumentation">, Values<"none,clang,llvm,csllvm,sample-coldcov">,
77367736
NormalizedValuesScope<"CodeGenOptions">,
7737-
NormalizedValues<["ProfileNone", "ProfileClangInstr", "ProfileIRInstr", "ProfileCSIRInstr", "ProfileIRColdCov"]>,
7737+
NormalizedValues<["ProfileNone", "ProfileClangInstr", "ProfileIRInstr", "ProfileCSIRInstr", "ProfileIRSampleColdCov"]>,
77387738
MarshallingInfoEnum<CodeGenOpts<"ProfileInstr">, "ProfileNone">;
77397739
def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
77407740
HelpText<"Generate instrumented code to collect execution counts into "

clang/lib/Basic/ProfileList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ static StringRef getSectionName(CodeGenOptions::ProfileInstrKind Kind) {
8181
return "llvm";
8282
case CodeGenOptions::ProfileCSIRInstr:
8383
return "csllvm";
84-
case CodeGenOptions::ProfileIRColdCov:
85-
return "coldcov";
84+
case CodeGenOptions::ProfileIRSampleColdCov:
85+
return "sample-coldcov";
8686
}
8787
llvm_unreachable("Unhandled CodeGenOptions::ProfileInstrKind enum");
8888
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
628628
CmdArgs.push_back("--pgo-instrument-cold-function-only");
629629
CmdArgs.push_back("-mllvm");
630630
CmdArgs.push_back("--pgo-function-entry-coverage");
631-
CmdArgs.push_back("-fprofile-instrument=coldcov");
631+
CmdArgs.push_back("-fprofile-instrument=sample-coldcov");
632632
}
633633

634634
if (auto *A = Args.getLastArg(options::OPT_ftemporal_profile)) {

clang/test/CodeGen/profile-filter.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm %s -o - | FileCheck %s
1+
// RUN: rm -rf %t && split-file %s %t
22

3-
// RUN: echo "fun:test1" > %t-func.list
4-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
3+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm %t/main.c -o - | FileCheck %s
4+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t/func.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=FUNC
55

6-
// RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t-file.list
7-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE
6+
// RUN: echo "src:%t/main.c" | sed -e 's/\\/\\\\/g' > %t-file.list
7+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=FILE
8+
// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t/section.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=SECTION
9+
// RUN: %clang_cc1 -fprofile-instrument=sample-coldcov -fprofile-list=%t/cold-func.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=COLDCOV
10+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t/exclude.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=EXCLUDE
11+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t/exclude-only.list -emit-llvm %t/main.c -o - | FileCheck %s --check-prefix=EXCLUDE
812

9-
// RUN: echo -e "[clang]\nfun:test1\n[llvm]\nfun:test2" > %t-section.list
10-
// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t-section.list -emit-llvm %s -o - | FileCheck %s --check-prefix=SECTION
13+
//--- func.list
14+
fun:test1
1115

12-
// RUN: echo -e "[coldcov]\nfun:test*\n!fun:test2" > %t-cold-func.list
13-
// RUN: %clang_cc1 -fprofile-instrument=coldcov -fprofile-list=%t-cold-func.list -emit-llvm %s -o - | FileCheck %s --check-prefix=COLDCOV
16+
//--- section.list
17+
[clang]
18+
fun:test1
19+
[llvm]
20+
fun:test2
1421

15-
// RUN: echo -e "fun:test*\n!fun:test1" > %t-exclude.list
16-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-exclude.list -emit-llvm %s -o - | FileCheck %s --check-prefix=EXCLUDE
22+
//--- cold-func.list
23+
[sample-coldcov]
24+
fun:test*
25+
!fun:test2
1726

18-
// RUN: echo "!fun:test1" > %t-exclude-only.list
19-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-exclude-only.list -emit-llvm %s -o - | FileCheck %s --check-prefix=EXCLUDE
27+
//--- exclude.list
28+
fun:test*
29+
!fun:test1
2030

31+
//--- exclude-only.list
32+
!fun:test1
33+
34+
//--- main.c
2135
unsigned i;
2236

2337
// CHECK: test1

0 commit comments

Comments
 (0)