Skip to content

Commit a17f11b

Browse files
author
Wael Yehia
committed
[test][PGO] Add a multi-threaded test for continuous PGO.
1 parent 08ef939 commit a17f11b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// REQUIRES: target={{.*(darwin|aix).*}}
2+
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
7+
// CHECK: Block counts: [100000, 4]
8+
9+
#include <thread>
10+
11+
int x = 0;
12+
void accum(int n) {
13+
for (int i = 0; i < n; i++)
14+
x += i; // don't care about accuracy, no need for atomic.
15+
}
16+
17+
int main() {
18+
int init_value = 10000;
19+
auto t1 = std::thread(accum, 1*init_value);
20+
auto t2 = std::thread(accum, 2*init_value);
21+
auto t3 = std::thread(accum, 3*init_value);
22+
auto t4 = std::thread(accum, 4*init_value);
23+
24+
t1.join();
25+
t2.join();
26+
t3.join();
27+
t4.join();
28+
return !x;
29+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ def exclude_unsupported_files_for_aix(dirname):
138138
config.substitutions.append(
139139
("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=")
140140
)
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+
)
141149

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

0 commit comments

Comments
 (0)