1 ; Test that instrumentaiton works fine for the case of catchswitch stmts.
2 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
4 ; RUN: llvm-profdata merge %S/Inputs/PR41279_2.proftext -o %t.profdata
5 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
6 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
9 define dso_local void @f() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
11 ; USE-SAME: !prof ![[FUNC_ENTRY_COUNT:[0-9]+]]
12 ; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
13 ; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
14 ; USE-DAG: ![[FUNC_ENTRY_COUNT]] = !{!"function_entry_count", i64 5}
16 %__exception_code = alloca i32, align 4
17 %__exception_code2 = alloca i32, align 4
19 to label %invoke.cont unwind label %catch.dispatch
22 %0 = catchswitch within none [label %__except] unwind to caller
25 %1 = catchpad within %0 [i8* null]
26 catchret from %1 to label %__except1
29 %2 = call i32 @llvm.eh.exceptioncode(token %1)
30 store i32 %2, i32* %__exception_code, align 4
33 ;GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__profn_f, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 1)
40 to label %invoke.cont3 unwind label %catch.dispatch4
43 %3 = catchswitch within none [label %__except5] unwind to caller
44 ; GEN: catch.dispatch4:
45 ; GEN-NOT: call void @llvm.instrprof.increment
48 %4 = catchpad within %3 [i8* null]
49 catchret from %4 to label %__except6
52 %5 = call i32 @llvm.eh.exceptioncode(token %4)
53 store i32 %5, i32* %__exception_code2, align 4
62 ;GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__profn_f, i32 0, i32 0), i64 {{[0-9]+}}, i32 2, i32 0)
66 declare dso_local i32 @__C_specific_handler(...)
68 declare i32 @llvm.eh.exceptioncode(token)