| 1 | // RUN: %libomptarget-compile-generic -fcreate-profile \ |
| 2 | // RUN: -Xarch_device -fprofile-generate |
| 3 | // RUN: env LLVM_PROFILE_FILE=%basename_t.llvm.profraw \ |
| 4 | // RUN: %libomptarget-run-generic 2>&1 |
| 5 | // RUN: %profdata show --all-functions --counts \ |
| 6 | // RUN: %target_triple.%basename_t.llvm.profraw | \ |
| 7 | // RUN: %fcheck-generic --check-prefix="LLVM-PGO" |
| 8 | |
| 9 | // RUN: %libomptarget-compile-generic -fcreate-profile \ |
| 10 | // RUN: -Xarch_device -fprofile-instr-generate |
| 11 | // RUN: env LLVM_PROFILE_FILE=%basename_t.clang.profraw \ |
| 12 | // RUN: %libomptarget-run-generic 2>&1 |
| 13 | // RUN: %profdata show --all-functions --counts \ |
| 14 | // RUN: %target_triple.%basename_t.clang.profraw | \ |
| 15 | // RUN: %fcheck-generic --check-prefix="CLANG-PGO" |
| 16 | |
| 17 | // REQUIRES: amdgpu |
| 18 | // REQUIRES: pgo |
| 19 | |
| 20 | int test1(int a) { return a / 2; } |
| 21 | int test2(int a) { return a * 2; } |
| 22 | |
| 23 | int main() { |
| 24 | int m = 2; |
| 25 | #pragma omp target |
| 26 | { |
| 27 | for (int i = 0; i < 10; i++) { |
| 28 | m = test1(a: m); |
| 29 | for (int j = 0; j < 2; j++) { |
| 30 | m = test2(a: m); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // LLVM-PGO-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}: |
| 37 | // LLVM-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 38 | // LLVM-PGO: Counters: 4 |
| 39 | // LLVM-PGO: Block counts: [20, 10, {{.*}}, 1] |
| 40 | |
| 41 | // LLVM-PGO-LABEL: test1: |
| 42 | // LLVM-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 43 | // LLVM-PGO: Counters: 1 |
| 44 | // LLVM-PGO: Block counts: [10] |
| 45 | |
| 46 | // LLVM-PGO-LABEL: test2: |
| 47 | // LLVM-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 48 | // LLVM-PGO: Counters: 1 |
| 49 | // LLVM-PGO: Block counts: [20] |
| 50 | |
| 51 | // LLVM-PGO-LABEL: Instrumentation level: |
| 52 | // LLVM-PGO-SAME: IR |
| 53 | // LLVM-PGO-SAME: entry_first = 0 |
| 54 | // LLVM-PGO-LABEL: Functions shown: |
| 55 | // LLVM-PGO-SAME: 3 |
| 56 | // LLVM-PGO-LABEL: Maximum function count: |
| 57 | // LLVM-PGO-SAME: 20 |
| 58 | |
| 59 | // CLANG-PGO-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}: |
| 60 | // CLANG-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 61 | // CLANG-PGO: Block counts: [10, 20] |
| 62 | |
| 63 | // CLANG-PGO-LABEL: test1: |
| 64 | // CLANG-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 65 | // CLANG-PGO: Counters: 1 |
| 66 | // CLANG-PGO: Function count: 10 |
| 67 | // CLANG-PGO: Block counts: [] |
| 68 | |
| 69 | // CLANG-PGO-LABEL: test2: |
| 70 | // CLANG-PGO: Hash: {{0[xX][0-9a-fA-F]+}} |
| 71 | // CLANG-PGO: Counters: 1 |
| 72 | // CLANG-PGO: Function count: 20 |
| 73 | // CLANG-PGO: Block counts: [] |
| 74 | |
| 75 | // CLANG-PGO-LABEL: Instrumentation level: |
| 76 | // CLANG-PGO-SAME: Front-end |
| 77 | // CLANG-PGO-LABEL: Functions shown: |
| 78 | // CLANG-PGO-SAME: 3 |
| 79 | // CLANG-PGO-LABEL: Maximum internal block count: |
| 80 | // CLANG-PGO-SAME: 20 |
| 81 | |