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