1*7c3d14c8STreehugger Robot // REQUIRES: shell
2*7c3d14c8STreehugger Robot // RUN: %clang_profgen -o %t -O3 %s
3*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
4*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.profdata %t.profraw
5*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=COMMON --check-prefix=ORIG
6*7c3d14c8STreehugger Robot //
7*7c3d14c8STreehugger Robot // RUN: rm -f %t.profraw_e_*
8*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.profraw_e_%1m %run %t
9*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.profraw_e_%1m %run %t
10*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.em.profdata %t.profraw_e_*
11*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.em.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=COMMON --check-prefix=MERGE
12*7c3d14c8STreehugger Robot //
13*7c3d14c8STreehugger Robot // RUN: %clang_profgen=%t.%m.profraw -o %t.merge -O3 %s
14*7c3d14c8STreehugger Robot // RUN: rm -f %t.*.profraw*
15*7c3d14c8STreehugger Robot // RUN: %run %t.merge
16*7c3d14c8STreehugger Robot // RUN: %run %t.merge
17*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.m.profdata %t.*.profraw
18*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.m.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=COMMON --check-prefix=MERGE
19*7c3d14c8STreehugger Robot
begin(int i)20*7c3d14c8STreehugger Robot int begin(int i) {
21*7c3d14c8STreehugger Robot // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
22*7c3d14c8STreehugger Robot if (i)
23*7c3d14c8STreehugger Robot return 0;
24*7c3d14c8STreehugger Robot return 1;
25*7c3d14c8STreehugger Robot }
26*7c3d14c8STreehugger Robot
end(int i)27*7c3d14c8STreehugger Robot int end(int i) {
28*7c3d14c8STreehugger Robot // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]]
29*7c3d14c8STreehugger Robot if (i)
30*7c3d14c8STreehugger Robot return 0;
31*7c3d14c8STreehugger Robot return 1;
32*7c3d14c8STreehugger Robot }
33*7c3d14c8STreehugger Robot
main(int argc,const char * argv[])34*7c3d14c8STreehugger Robot int main(int argc, const char *argv[]) {
35*7c3d14c8STreehugger Robot begin(0);
36*7c3d14c8STreehugger Robot end(1);
37*7c3d14c8STreehugger Robot
38*7c3d14c8STreehugger Robot // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]]
39*7c3d14c8STreehugger Robot if (argc)
40*7c3d14c8STreehugger Robot return 0;
41*7c3d14c8STreehugger Robot return 1;
42*7c3d14c8STreehugger Robot }
43*7c3d14c8STreehugger Robot
44*7c3d14c8STreehugger Robot // ORIG: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}
45*7c3d14c8STreehugger Robot // ORIG: ![[PD2]] = !{!"branch_weights", i32 2, i32 1}
46*7c3d14c8STreehugger Robot // MERGE: ![[PD1]] = !{!"branch_weights", i32 1, i32 3}
47*7c3d14c8STreehugger Robot // MERGE: ![[PD2]] = !{!"branch_weights", i32 3, i32 1}
48