| 1 | // RUN: rm -fr %t.prof |
| 2 | // RUN: %clang_pgogen=%t.prof/ -o %t.gen.cs -O2 %s |
| 3 | // RUN: %run %t.gen.cs |
| 4 | // RUN: llvm-profdata merge -o %t.cs.profdata %t.prof/ |
| 5 | // Check context sensitive profile |
| 6 | // RUN: %clang_profuse=%t.cs.profdata -O2 -emit-llvm -S %s -o - | FileCheck %s --check-prefix=CS |
| 7 | // |
| 8 | // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s |
| 9 | // RUN: %run %t.gen.cis |
| 10 | // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw |
| 11 | // Check context insensitive profile |
| 12 | // RUN: %clang_profuse=%t.cis.profdata -O2 -emit-llvm -S %s -o - | FileCheck %s --check-prefix=CIS |
| 13 | int g1 = 1; |
| 14 | int volatile g2 = 2; |
| 15 | static void toggle(int t) { |
| 16 | if (t & 1) |
| 17 | g1 *= t; |
| 18 | else |
| 19 | g2 *= t; |
| 20 | } |
| 21 | |
| 22 | int main() { |
| 23 | int i; |
| 24 | // CS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] |
| 25 | // CIS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD:[0-9]+]] |
| 26 | toggle(t: g1); |
| 27 | // CS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]] |
| 28 | // CIS: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD:[0-9]+]] |
| 29 | toggle(t: g2); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | // CS: ![[PD1]] = !{!"branch_weights", i32 0, i32 1} |
| 34 | // CS: ![[PD2]] = !{!"branch_weights", i32 1, i32 0} |
| 35 | // CIS: ![[PD]] = !{!"branch_weights", i32 2, i32 2} |
| 36 | |