xref: /aosp_15_r20/external/llvm/test/Transforms/PGOProfile/switch.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3*9880d681SAndroid Build Coastguard Worker; RUN: llvm-profdata merge %S/Inputs/switch.proftext -o %t.profdata
4*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
5*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
6*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu"
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; GEN: $__llvm_profile_raw_version = comdat any
10*9880d681SAndroid Build Coastguard Worker; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
11*9880d681SAndroid Build Coastguard Worker; GEN: @__profn_test_switch = private constant [11 x i8] c"test_switch"
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdefine void @test_switch(i32 %i) {
14*9880d681SAndroid Build Coastguard Workerentry:
15*9880d681SAndroid Build Coastguard Worker; GEN: entry:
16*9880d681SAndroid Build Coastguard Worker; GEN-NOT: call void @llvm.instrprof.increment
17*9880d681SAndroid Build Coastguard Worker  switch i32 %i, label %sw.default [
18*9880d681SAndroid Build Coastguard Worker    i32 1, label %sw.bb
19*9880d681SAndroid Build Coastguard Worker    i32 2, label %sw.bb1
20*9880d681SAndroid Build Coastguard Worker    i32 3, label %sw.bb2
21*9880d681SAndroid Build Coastguard Worker  ]
22*9880d681SAndroid Build Coastguard Worker; USE: ]
23*9880d681SAndroid Build Coastguard Worker; USE-SAME: !prof ![[BW_SWITCH:[0-9]+]]
24*9880d681SAndroid Build Coastguard Worker; USE: ![[BW_SWITCH]] = !{!"branch_weights", i32 3, i32 2, i32 0, i32 5}
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workersw.bb:
27*9880d681SAndroid Build Coastguard Worker; GEN: sw.bb:
28*9880d681SAndroid Build Coastguard Worker; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
29*9880d681SAndroid Build Coastguard Worker  br label %sw.epilog
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workersw.bb1:
32*9880d681SAndroid Build Coastguard Worker; GEN: sw.bb1:
33*9880d681SAndroid Build Coastguard Worker; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
34*9880d681SAndroid Build Coastguard Worker  br label %sw.epilog
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workersw.bb2:
37*9880d681SAndroid Build Coastguard Worker; GEN: sw.bb2:
38*9880d681SAndroid Build Coastguard Worker; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 1)
39*9880d681SAndroid Build Coastguard Worker  br label %sw.epilog
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workersw.default:
42*9880d681SAndroid Build Coastguard Worker; GEN: sw.default:
43*9880d681SAndroid Build Coastguard Worker; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 3)
44*9880d681SAndroid Build Coastguard Worker  br label %sw.epilog
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workersw.epilog:
47*9880d681SAndroid Build Coastguard Worker; GEN: sw.epilog:
48*9880d681SAndroid Build Coastguard Worker; GEN-NOT: call void @llvm.instrprof.increment
49*9880d681SAndroid Build Coastguard Worker  ret void
50*9880d681SAndroid Build Coastguard Worker; GEN: ret void
51*9880d681SAndroid Build Coastguard Worker}
52