Skip to content

Commit 4f2651c

Browse files
w2yehiaWael Yehia
andauthored
[PGO][test] Enable continuous mode PGO tests on AIX (#115987)
Co-authored-by: Wael Yehia <[email protected]>
1 parent 618f231 commit 4f2651c

File tree

9 files changed

+46
-19
lines changed

9 files changed

+46
-19
lines changed

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

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

3-
// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -o %t.exe %s
3+
// RUN: %clang_profgen_cont -fcoverage-mapping -o %t.exe %s
44
// RUN: echo "garbage" > %t.profraw
55
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %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
8-
// RUN: llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE
8+
//
9+
// COM: The "report" and "show" commands of llvm-cov are not supported on AIX.
10+
// RUN: %if !target={{.*aix.*}} %{ \
11+
// RUN: llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE \
12+
// RUN: %}
913

1014
// CHECK-COUNTS: Counters:
1115
// CHECK-COUNTS-NEXT: main:

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

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

3-
// RUN: %clang_pgogen -o %t.exe %s
3+
// RUN: %clang_pgogen_cont -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,6 +1,6 @@
1-
// REQUIRES: darwin
1+
// REQUIRES: target={{.*(darwin|aix).*}}
22

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

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,8 +1,8 @@
1-
// REQUIRES: darwin
1+
// REQUIRES: target={{.*(darwin|aix).*}}
22

33
// RUN: echo "static void dead_code(void) {}" > %t.dso.c
4-
// RUN: %clang_profgen -fcoverage-mapping -O3 -dynamiclib -o %t.dso.dylib %t.dso.c
5-
// RUN: %clang_profgen -fcoverage-mapping -O3 -o %t.exe %s %t.dso.dylib
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
66
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 2>&1 | count 0
77
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s
88

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

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

33
// Test the online merging mode (%m) along with continuous mode (%c).
44
//
@@ -8,9 +8,9 @@
88
// Create two DSOs and a driver program that uses them.
99
// RUN: echo "void dso1(void) {}" > dso1.c
1010
// RUN: echo "void dso2(void) {}" > dso2.c
11-
// RUN: %clang_pgogen -dynamiclib -o %t.dir/dso1.dylib dso1.c -mllvm -instrprof-atomic-counter-update-all=1
12-
// RUN: %clang_pgogen -dynamiclib -o %t.dir/dso2.dylib dso2.c -mllvm -instrprof-atomic-counter-update-all=1
13-
// RUN: %clang_pgogen -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -mllvm -instrprof-atomic-counter-update-all=1
11+
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso1.dylib dso1.c -mllvm -instrprof-atomic-counter-update-all=1
12+
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso2.dylib dso2.c -mllvm -instrprof-atomic-counter-update-all=1
13+
// RUN: %clang_pgogen_cont -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -mllvm -instrprof-atomic-counter-update-all=1
1414
//
1515
// === Round 1 ===
1616
// Test merging+continuous mode without any file contention.

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

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

33
// RUN: rm -rf %t.dir && mkdir -p %t.dir
4-
// RUN: %clang_pgogen -o %t.exe %s
4+
// RUN: %clang_pgogen_cont -o %t.exe %s
55
//
66
// Note: %%p is needed here, not %p, because of lit's path substitution.
77
// RUN: env LLVM_PROFILE_FILE="%t.dir/%c-%%p" %run %t.exe

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// REQUIRES: darwin || linux
1+
// REQUIRES: target={{.*(darwin|linux|aix).*}}
22

33
// Test when LLVM_PROFILE_FILE is set incorrectly, it should fall backs to use default.profraw without runtime error.
44

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

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

3-
// RUN: %clang_pgogen -o %t.exe %s
3+
// RUN: %clang_pgogen_cont -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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ 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"])
35+
3336
if config.host_os in ["Linux"]:
3437
extra_link_flags = ["-ldl"]
3538
elif target_is_msvc:
@@ -94,6 +97,14 @@ def exclude_unsupported_files_for_aix(dirname):
9497
config.substitutions.append(
9598
("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=")
9699
)
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+
)
97108
config.substitutions.append(
98109
(
99110
"%clangxx_profgen ",
@@ -113,6 +124,14 @@ def exclude_unsupported_files_for_aix(dirname):
113124
config.substitutions.append(
114125
("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=")
115126
)
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+
)
116135
config.substitutions.append(
117136
("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ")
118137
)
@@ -166,6 +185,10 @@ def exclude_unsupported_files_for_aix(dirname):
166185
]:
167186
config.unsupported = True
168187

188+
config.substitutions.append(
189+
("%shared_lib_flag", "-dynamiclib" if (config.host_os == "Darwin") else "-shared")
190+
)
191+
169192
if config.host_os in ["AIX"]:
170193
config.available_features.add("system-aix")
171194
exclude_unsupported_files_for_aix(config.test_source_root)

0 commit comments

Comments
 (0)