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 <wyehia@ca.ibm.com>
30 lines
760 B
C++
30 lines
760 B
C++
// REQUIRES: continuous-mode
|
|
|
|
// RUN: rm -rf %t.dir
|
|
// RUN: %clangxx_pgogen=%t.dir -fprofile-continuous -lpthread %s -o %t.exe -mllvm -disable-vp -fprofile-update=atomic
|
|
// RUN: %run %t.exe
|
|
// RUN: llvm-profdata show --counts --function=accum %t.dir/default_*.profraw | FileCheck %s
|
|
// CHECK: Block counts: [100000, 4]
|
|
|
|
#include <thread>
|
|
|
|
int x = 0;
|
|
void accum(int n) {
|
|
for (int i = 0; i < n; i++)
|
|
x += i; // don't care about accuracy, no need for atomic.
|
|
}
|
|
|
|
int main() {
|
|
int init_value = 10000;
|
|
auto t1 = std::thread(accum, 1*init_value);
|
|
auto t2 = std::thread(accum, 2*init_value);
|
|
auto t3 = std::thread(accum, 3*init_value);
|
|
auto t4 = std::thread(accum, 4*init_value);
|
|
|
|
t1.join();
|
|
t2.join();
|
|
t3.join();
|
|
t4.join();
|
|
return !x;
|
|
}
|