| 1 | // RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=0 %s -o %t.0.out |
| 2 | // RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=1 %s -o %t.1.out |
| 3 | // RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=2 %s -o %t.2.out |
| 4 | // RUN: env LLVM_PROFILE_FILE=%t.0.profraw %run %t.0.out |
| 5 | // RUN: env LLVM_PROFILE_FILE=%t.1.profraw %run %t.1.out |
| 6 | // RUN: env LLVM_PROFILE_FILE=%t.2.profraw %run %t.2.out |
| 7 | // RUN: llvm-profdata merge -o %t.profdata %t.*.profraw |
| 8 | // RUN: llvm-profdata show %t.profdata --all-functions | FileCheck %s |
| 9 | |
| 10 | int foo(int i) { return 4 * i + 1; } |
| 11 | int bar(int i) { return 4 * i + 2; } |
| 12 | int goo(int i) { return 4 * i + 3; } |
| 13 | |
| 14 | int main(int argc, char *argv[]) { |
| 15 | foo(i: 5); |
| 16 | bar(i: 6); |
| 17 | goo(i: 7); |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | // Even though we ran this code three times, we expect all counts to be one if |
| 22 | // functions were partitioned into groups correctly. |
| 23 | |
| 24 | // CHECK: Counters: 1 |
| 25 | // CHECK: Counters: 1 |
| 26 | // CHECK: Counters: 1 |
| 27 | // CHECK: Counters: 1 |
| 28 | // CHECK: Total functions: 4 |
| 29 | |