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