| 1 | // RUN: %clang_profgen -fdata-sections -ffunction-sections -fuse-ld=gold -Wl,--gc-sections -o %t -O3 %s |
| 2 | // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t |
| 3 | // RUN: llvm-profdata merge -o %t.profdata %t.profraw |
| 4 | // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s |
| 5 | |
| 6 | int begin(int i) { |
| 7 | // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] |
| 8 | if (i) |
| 9 | return 0; |
| 10 | return 1; |
| 11 | } |
| 12 | |
| 13 | int end(int i) { |
| 14 | // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]] |
| 15 | if (i) |
| 16 | return 0; |
| 17 | return 1; |
| 18 | } |
| 19 | |
| 20 | int main(int argc, const char *argv[]) { |
| 21 | begin(i: 0); |
| 22 | end(i: 1); |
| 23 | |
| 24 | // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]] |
| 25 | if (argc) |
| 26 | return 0; |
| 27 | return 1; |
| 28 | } |
| 29 | |
| 30 | // CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} |
| 31 | // CHECK: ![[PD2]] = !{!"branch_weights", i32 2, i32 1} |
| 32 | |