1 ; Test that instrumentaiton works fine for the case of failing the split critical edges.
2 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3 ; RUN: llvm-profdata merge %S/Inputs/PR41279.proftext -o %t.profdata
4 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
6 declare void @f3(ptr, ptr, i64)
7 declare { ptr, i64 } @f0(ptr)
9 declare void @invok2(ptr, ptr noalias readonly align 1, i64)
10 declare void @invok1(ptr, ptr, i64)
11 declare i32 @__CxxFrameHandler3(...)
13 define void @foo(ptr, ptr) personality ptr @__CxxFrameHandler3 {
15 ; USE-SAME: !prof ![[FUNC_ENTRY_COUNT:[0-9]+]]
17 %3 = alloca i8, align 1
18 store i8 0, ptr %3, align 1
20 %5 = icmp ult i64 %4, 32
21 br i1 %5, label %7, label %13
22 ; USE: br i1 %5, label %7, label %13
23 ; USE-SAME: !prof ![[BW_ENTRY1:[0-9]+]]
26 cleanupret from %17 unwind to caller
28 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 2)
31 store i8 1, ptr %3, align 1
32 %8 = call { ptr, i64 } @f0(ptr %0)
33 %9 = extractvalue { ptr, i64 } %8, 0
34 %10 = extractvalue { ptr, i64 } %8, 1
35 invoke void @invok1(ptr %1, ptr %0, i64 1)
36 to label %11 unwind label %16
38 ; GEN-NOT: call void @llvm.instrprof.increment
41 store i8 0, ptr %3, align 1
42 invoke void @invok2(ptr %1, ptr noalias readonly align 1 %9, i64 %10)
43 to label %12 unwind label %16
45 ; GEN-NOT: call void @llvm.instrprof.increment
48 store i8 0, ptr %3, align 1
51 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 1)
54 call void @f3(ptr %0, ptr %1, i64 1)
57 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 0)
63 store i8 0, ptr %3, align 1
66 ; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 3)
69 %17 = cleanuppad within none []
70 %18 = load i8, ptr %3, align 1
71 %19 = trunc i8 %18 to i1
72 br i1 %19, label %15, label %6
73 ; USE: br i1 %19, label %15, label %6
74 ; USE-SAME: !prof ![[BW_ENTRY2:[0-9]+]]
77 ; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
78 ; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
79 ; USE-DAG: ![[FUNC_ENTRY_COUNT]] = !{!"function_entry_count", i64 8}
80 ; USE-DAG: ![[BW_ENTRY1]] = !{!"branch_weights", i32 5, i32 3}
81 ; USE-DAG: ![[BW_ENTRY2]] = !{!"branch_weights", i32 2, i32 1}