1 ; Test that instrumentaiton works fine for the case of catchswitch stmts.
2 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3 ; RUN: llvm-profdata merge %S/Inputs/PR41279_2.proftext -o %t.profdata
4 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
7 define dso_local void @f() personality ptr @__C_specific_handler {
9 ; USE-SAME: !prof ![[FUNC_ENTRY_COUNT:[0-9]+]]
10 ; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
11 ; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
12 ; USE-DAG: ![[FUNC_ENTRY_COUNT]] = !{!"function_entry_count", i64 6}
16 ; GEN: catch.dispatch:
17 ; GEN-NOT: call void @llvm.instrprof.increment
20 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_f, i64 {{[0-9]+}}, i32 3, i32 1)
23 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_f, i64 {{[0-9]+}}, i32 3, i32 2)
26 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_f, i64 1096621589180411894, i32 3, i32 0)
28 %__exception_code = alloca i32, align 4
29 %__exception_code2 = alloca i32, align 4
31 to label %invoke.cont unwind label %catch.dispatch
34 %0 = catchswitch within none [label %__except] unwind to caller
37 %1 = catchpad within %0 [ptr null]
38 catchret from %1 to label %__except1
41 %2 = call i32 @llvm.eh.exceptioncode(token %1)
42 store i32 %2, ptr %__exception_code, align 4
50 to label %invoke.cont3 unwind label %catch.dispatch4
53 %3 = catchswitch within none [label %__except5] unwind to caller
56 %4 = catchpad within %3 [ptr null]
57 catchret from %4 to label %__except6
60 %5 = call i32 @llvm.eh.exceptioncode(token %4)
61 store i32 %5, ptr %__exception_code2, align 4
71 declare dso_local i32 @__C_specific_handler(...)
73 declare i32 @llvm.eh.exceptioncode(token)