Skip to content

Commit f83726e

Browse files
w2yehiaWael Yehia
andauthored
[profile] Use fprofile-continuous in compiler-rt tests (#126617)
PR #124353 introduced the clang option `-fprofile-continuous` to enable continuous mode. Use this option in all compiler-rt tests, where applicable. Changes can be summarized as follows: 1) tests that use `-fprofile-instr-generate` (`%clang_profgen`), which is an option that takes profile file name, are changed like so: ``` -// RUN: %clang_profgen_cont <SOME-OPTIONS> -o %t.exe %s -// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe +// RUN: %clang_profgen=%t.profraw -fprofile-continuous <SOME-OPTIONS> -o %t.exe %s +// RUN: %run %t.exe ``` 2) tests that use `-fprofile-generate` (`%clang_pgogen`), which is an option that takes a profile directory, are on case-by-case basis. Where the default name "default_%m.profraw" works, those tests were changed to use `%clang_pgogen=<dir>`, and the rest (`set-filename.c` and `get-filename.c`) continued to use the `LLVM_PROFILE_FILE` environment variable . 3) `set-file-object.c` uses different filename for different run of the same executable, so it continued to use the `LLVM_PROFILE_FILE` environment variable. 4) `pid-substitution.c` add a clang_profgen variation. --------- Co-authored-by: Wael Yehia <[email protected]>
1 parent 65e68a3 commit f83726e

13 files changed

+31
-57
lines changed

compiler-rt/test/profile/ContinuousSyncMode/basic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// REQUIRES: continuous-mode
22

3-
// RUN: %clang_profgen_cont -fcoverage-mapping -o %t.exe %s
3+
// RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -o %t.exe %s
44
// RUN: echo "garbage" > %t.profraw
5-
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe
5+
// RUN: %run %t.exe
66
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s -check-prefix=CHECK-COUNTS
77
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
88
//

compiler-rt/test/profile/ContinuousSyncMode/get-filename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: continuous-mode
22

3-
// RUN: %clang_pgogen_cont -o %t.exe %s
3+
// RUN: %clang_pgogen -fprofile-continuous -o %t.exe %s
44
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.profraw
55
// RUN: env LLVM_PROFILE_FILE="%t%c.profraw" %run %t.exe %t.profraw
66
// RUN: env LLVM_PROFILE_FILE="%t.profraw%c" %run %t.exe %t.profraw

compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: continuous-mode
22

3-
// RUN: %clang_profgen_cont -fcoverage-mapping -fcoverage-mcdc -O3 -o %t.exe %s
4-
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 3 3
3+
// RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -fcoverage-mcdc -O3 -o %t.exe %s
4+
// RUN: %run %t.exe 3 3
55
// RUN: llvm-profdata show --text --all-functions %t.profraw | FileCheck %s
66

77
// CHECK: Num Bitmap Bytes:

compiler-rt/test/profile/ContinuousSyncMode/image-with-no-counters.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// REQUIRES: target={{.*(darwin|aix).*}}
22

33
// RUN: echo "static void dead_code(void) {}" > %t.dso.c
4-
// RUN: %clang_profgen_cont -fcoverage-mapping -O3 %shared_lib_flag -o %t.dso.dylib %t.dso.c
5-
// RUN: %clang_profgen_cont -fcoverage-mapping -O3 -o %t.exe %s %t.dso.dylib
6-
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 2>&1 | count 0
4+
// RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -O3 %shared_lib_flag -o %t.dso.dylib %t.dso.c
5+
// RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -O3 -o %t.exe %s %t.dso.dylib
6+
// RUN: %run %t.exe 2>&1 | count 0
77
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s
88

99
// CHECK: Total functions: 1

compiler-rt/test/profile/ContinuousSyncMode/multi-threaded.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// REQUIRES: continuous-mode
22

3-
// RUN: rm -f %t.profraw
4-
// RUN: %clangxx_pgogen_cont -lpthread %s -o %t.exe -mllvm -disable-vp -fprofile-update=atomic
5-
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe
6-
// RUN: llvm-profdata show --counts --function=accum %t.profraw | FileCheck %s
3+
// RUN: rm -rf %t.dir
4+
// RUN: %clangxx_pgogen=%t.dir -fprofile-continuous -lpthread %s -o %t.exe -mllvm -disable-vp -fprofile-update=atomic
5+
// RUN: %run %t.exe
6+
// RUN: llvm-profdata show --counts --function=accum %t.dir/default_*.profraw | FileCheck %s
77
// CHECK: Block counts: [100000, 4]
88

99
#include <thread>

compiler-rt/test/profile/ContinuousSyncMode/online-merging-windows.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
// RUN: rm -rf %t.dir && split-file %s %t.dir && cd %t.dir
1111
//
1212
// Create two DLLs and a driver program that uses them.
13-
// RUN: %clang_pgogen foo.c -mllvm -instrprof-atomic-counter-update-all=1 -mllvm -runtime-counter-relocation=true -fuse-ld=lld -Wl,-dll -o %t.dir/foo.dll
14-
// RUN: %clang_pgogen bar.c -mllvm -instrprof-atomic-counter-update-all=1 -mllvm -runtime-counter-relocation=true -fuse-ld=lld -Wl,-dll -o %t.dir/bar.dll
15-
// RUN: %clang_pgogen main.c -o main.exe %t.dir/foo.lib %t.dir/bar.lib -mllvm -instrprof-atomic-counter-update-all=1 -mllvm -runtime-counter-relocation=true -fuse-ld=lld
13+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic foo.c -fuse-ld=lld -Wl,-dll -o %t.dir/foo.dll
14+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic bar.c -fuse-ld=lld -Wl,-dll -o %t.dir/bar.dll
15+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic main.c -o main.exe %t.dir/foo.lib %t.dir/bar.lib -fuse-ld=lld
1616
//
1717
// === Round 1 ===
1818
// Test merging+continuous mode without any file contention.
1919
//
20-
// RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%m%c.profraw" %run %t.dir/main.exe nospawn
20+
// RUN: %run %t.dir/main.exe nospawn
2121
// RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
2222
// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND1
2323

@@ -37,7 +37,7 @@
3737
// === Round 2 ===
3838
// Test merging+continuous mode with some file contention.
3939
//
40-
// RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%m%c.profraw" %run %t.dir/main.exe spawn
40+
// RUN: %run %t.dir/main.exe spawn
4141
// RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
4242
// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND2
4343

@@ -157,4 +157,4 @@ int main(int argc, char *const argv[]) {
157157
}
158158

159159
return 1;
160-
}
160+
}

compiler-rt/test/profile/ContinuousSyncMode/online-merging.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// Create two DSOs and a driver program that uses them.
1010
// RUN: echo "void dso1(void) {}" > dso1.c
1111
// RUN: echo "void dso2(void) {}" > dso2.c
12-
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso1.dylib dso1.c -fprofile-update=atomic
13-
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso2.dylib dso2.c -fprofile-update=atomic
14-
// RUN: %clang_pgogen_cont -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -fprofile-update=atomic
12+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic %shared_lib_flag -o %t.dir/dso1.dylib dso1.c
13+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic %shared_lib_flag -o %t.dir/dso2.dylib dso2.c
14+
// RUN: %clang_pgogen=%t.dir/profdir -fprofile-continuous -fprofile-update=atomic -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib
1515
//
1616
// === Round 1 ===
1717
// Test merging+continuous mode without any file contention.
1818
//
19-
// RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%m%c.profraw" %run %t.dir/main.exe nospawn
19+
// RUN: %run %t.dir/main.exe nospawn
2020
// RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
2121
// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND1
2222

@@ -40,7 +40,7 @@
4040
// === Round 2 ===
4141
// Test merging+continuous mode with some file contention.
4242
//
43-
// RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%m%c.profraw" %run %t.dir/main.exe spawn 'LLVM_PROFILE_FILE=%t.dir/profdir/%m%c.profraw'
43+
// RUN: %run %t.dir/main.exe spawn 'LLVM_PROFILE_FILE=%t.dir/profdir/%m%c.profraw'
4444
// RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
4545
// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND2
4646

compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// REQUIRES: continuous-mode
22

33
// RUN: rm -rf %t.dir && mkdir -p %t.dir
4-
// RUN: %clang_pgogen_cont -o %t.exe %s
54
//
65
// Note: %%p is needed here, not %p, because of lit's path substitution.
6+
// RUN: %clang_profgen=%t.dir/-%%p -fprofile-continuous -o %t.exe %s
7+
// RUN: %run %t.exe
8+
// RUN: %clang_pgogen -fprofile-continuous -o %t.exe %s
79
// RUN: env LLVM_PROFILE_FILE="%t.dir/%c-%%p" %run %t.exe
810

911
#include <stdlib.h>

compiler-rt/test/profile/ContinuousSyncMode/reset-default-profile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Create & cd into a temporary directory.
66
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
7-
// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation=true -o %t.exe %s
7+
// RUN: %clang_profgen -fprofile-continuous -fcoverage-mapping -o %t.exe %s
88
// RUN: env LLVM_PROFILE_FILE="incorrect-profile-name%m%c%c.profraw" %run %t.exe
99
// RUN: ls -l | FileCheck %s
1010

compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// REQUIRES: target={{.*(linux|solaris|windows-msvc|aix).*}}
22

3-
// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation=true -o %t.exe %s
3+
// RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -o %t.exe %s
44
// RUN: echo "garbage" > %t.profraw
5-
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe
5+
// RUN: %run %t.exe
66
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s -check-prefix=CHECK-COUNTS
77
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
88
// RUN: %if !target={{.*aix.*}} %{ llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE %}

compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
// Create & cd into a temporary directory.
55
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
66

7-
// The -mllvm -runtime-counter-relocation=true flag has effect only on linux.
8-
// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -fprofile-update=atomic -mllvm -runtime-counter-relocation=true -o main.exe %s
7+
// RUN: %clang_profgen -fprofile-continuous -fcoverage-mapping -fprofile-update=atomic -o main.exe %s
98

109
// Test continuous mode with __llvm_profile_set_file_object with mergin disabled.
1110
// RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%c%mprofraw.old" %run %t.dir/main.exe nomerge %t.dir/profdir/profraw.new 2>&1 | FileCheck %s -check-prefix=WARN

compiler-rt/test/profile/ContinuousSyncMode/set-filename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: continuous-mode
22

3-
// RUN: %clang_pgogen_cont -o %t.exe %s
3+
// RUN: %clang_pgogen -fprofile-continuous -o %t.exe %s
44
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.profraw %t.bad
55

66
#include <string.h>

compiler-rt/test/profile/lit.cfg.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ def get_required_attr(config, attr_name):
3030

3131
target_is_msvc = bool(re.match(r".*-windows-msvc$", config.target_triple))
3232

33-
# Whether continous profile collection (%c) requires runtime counter relocation on this platform
34-
runtime_reloc = bool(config.host_os in ["AIX", "Linux"])
35-
3633
if config.host_os in ["Linux"]:
3734
extra_link_flags = ["-ldl"]
3835
elif target_is_msvc:
@@ -97,14 +94,6 @@ def exclude_unsupported_files_for_aix(dirname):
9794
config.substitutions.append(
9895
("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=")
9996
)
100-
config.substitutions.append(
101-
(
102-
"%clang_profgen_cont ",
103-
build_invocation(clang_cflags)
104-
+ " -fprofile-instr-generate "
105-
+ ("-mllvm -runtime-counter-relocation " if runtime_reloc else ""),
106-
)
107-
)
10897
config.substitutions.append(
10998
(
11099
"%clangxx_profgen ",
@@ -124,28 +113,12 @@ def exclude_unsupported_files_for_aix(dirname):
124113
config.substitutions.append(
125114
("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=")
126115
)
127-
config.substitutions.append(
128-
(
129-
"%clang_pgogen_cont ",
130-
build_invocation(clang_cflags)
131-
+ " -fprofile-generate "
132-
+ ("-mllvm -runtime-counter-relocation " if runtime_reloc else ""),
133-
)
134-
)
135116
config.substitutions.append(
136117
("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ")
137118
)
138119
config.substitutions.append(
139120
("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=")
140121
)
141-
config.substitutions.append(
142-
(
143-
"%clangxx_pgogen_cont ",
144-
build_invocation(clang_cxxflags)
145-
+ " -fprofile-generate "
146-
+ ("-mllvm -runtime-counter-relocation " if runtime_reloc else ""),
147-
)
148-
)
149122

150123
config.substitutions.append(
151124
("%clang_cspgogen ", build_invocation(clang_cflags) + " -fcs-profile-generate ")

0 commit comments

Comments
 (0)