[PGO] Resubmit "MST based PGO instrumentation infrastructure" (r254021)
[oota-llvm.git] / test / Transforms / PGOProfile / switch.ll
1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2 ; RUN: llvm-profdata merge %S/Inputs/switch.proftext -o %T/switch.profdata
3 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%T/switch.profdata -S | FileCheck %s --check-prefix=USE
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
6
7 ; GEN: @__llvm_profile_name_test_switch = private constant [11 x i8] c"test_switch"
8
9 define void @test_switch(i32 %i) {
10 entry:
11 ; GEN: entry:
12 ; GEN-NOT: call void @llvm.instrprof.increment
13   switch i32 %i, label %sw.default [
14     i32 1, label %sw.bb
15     i32 2, label %sw.bb1
16     i32 3, label %sw.bb2
17   ]
18 ; USE: ]
19 ; USE-SAME: !prof ![[BW_SWITCH:[0-9]+]]
20 ; USE: ![[BW_SWITCH]] = !{!"branch_weights", i32 3, i32 2, i32 0, i32 5}
21
22 sw.bb:
23 ; GEN: sw.bb:
24 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__llvm_profile_name_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
25   br label %sw.epilog
26
27 sw.bb1:
28 ; GEN: sw.bb1:
29 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__llvm_profile_name_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
30   br label %sw.epilog
31
32 sw.bb2:
33 ; GEN: sw.bb2:
34 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__llvm_profile_name_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 1)
35   br label %sw.epilog
36
37 sw.default:
38 ; GEN: sw.default:
39 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__llvm_profile_name_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 3)
40   br label %sw.epilog
41
42 sw.epilog:
43 ; GEN: sw.epilog:
44 ; GEN-NOT: call void @llvm.instrprof.increment
45   ret void
46 ; GEN: ret void
47 }