xref: /llvm-project/llvm/test/Transforms/PGOProfile/PR41279_2.ll (revision e3cf80c5c1fe55efd8216575ccadea0ab087e79c)
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
5
6
7define dso_local void @f() personality ptr @__C_specific_handler {
8; USE-LABEL: @f
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}
13;
14; GEN-LABEL: @f
15;
16; GEN: catch.dispatch:
17; GEN-NOT: call void @llvm.instrprof.increment
18;
19; GEN:  _except1:
20; GEN:    call void @llvm.instrprof.increment(ptr @__profn_f, i64 {{[0-9]+}}, i32 3, i32 1)
21;
22; GEN: __except6:
23; GEN:   call void @llvm.instrprof.increment(ptr @__profn_f, i64 {{[0-9]+}}, i32 3, i32 2)
24;
25; GEN: invoke.cont3:
26; GEN:   call void @llvm.instrprof.increment(ptr @__profn_f, i64 1096621589180411894, i32 3, i32 0)
27entry:
28  %__exception_code = alloca i32, align 4
29  %__exception_code2 = alloca i32, align 4
30  invoke void @f() #2
31          to label %invoke.cont unwind label %catch.dispatch
32
33catch.dispatch:
34  %0 = catchswitch within none [label %__except] unwind to caller
35
36__except:
37  %1 = catchpad within %0 [ptr null]
38  catchret from %1 to label %__except1
39
40__except1:
41  %2 = call i32 @llvm.eh.exceptioncode(token %1)
42  store i32 %2, ptr %__exception_code, align 4
43  br label %__try.cont7
44
45invoke.cont:
46  br label %__try.cont
47
48__try.cont:
49  invoke void @f()
50          to label %invoke.cont3 unwind label %catch.dispatch4
51
52catch.dispatch4:
53  %3 = catchswitch within none [label %__except5] unwind to caller
54
55__except5:
56  %4 = catchpad within %3 [ptr null]
57  catchret from %4 to label %__except6
58
59__except6:
60  %5 = call i32 @llvm.eh.exceptioncode(token %4)
61  store i32 %5, ptr %__exception_code2, align 4
62  br label %__try.cont7
63
64__try.cont7:
65  ret void
66
67invoke.cont3:
68  br label %__try.cont7
69}
70
71declare dso_local i32 @__C_specific_handler(...)
72
73declare i32 @llvm.eh.exceptioncode(token)
74