1+ ; RUN: split-file %s %t
2+
3+ ; RUN: opt -passes=prof-inject %t/inject.ll -S -o - | FileCheck %t/inject.ll
4+
5+ ; RUN: opt -passes=prof-inject %t/inject-some.ll \
6+ ; RUN: -profcheck-default-select-true-weight=1 -profcheck-default-select-false-weight=6 \
7+ ; RUN: -S -o - | FileCheck %t/inject-some.ll
8+
9+ ; RUN: opt -passes=prof-verify %t/verify.ll 2>&1 | FileCheck %t/verify.ll
10+
11+ ; RUN: not opt -passes=prof-verify %t/verify-missing.ll 2>&1 | FileCheck %t/verify-missing.ll
12+
13+ ; verify we can disable it. It's sufficient to see opt not failing.
14+ ; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 %t/verify-missing.ll
15+
16+ ;--- inject.ll
17+ declare void @foo (i32 %a );
18+ define void @bar (i1 %c ) {
19+ %v = select i1 %c , i32 1 , i32 2
20+ call void @foo (i32 %v )
21+ ret void
22+ }
23+ ; CHECK-LABEL: @bar
24+ ; CHECK: %v = select i1 %c, i32 1, i32 2, !prof !1
25+ ; CHECK: !0 = !{!"function_entry_count", i64 1000}
26+ ; CHECK: !1 = !{!"branch_weights", i32 2, i32 3}
27+
28+ ;--- inject-some.ll
29+ declare void @foo (i32 %a );
30+ define void @bar (i1 %c ) {
31+ %e = select i1 %c , i32 1 , i32 2 , !prof !0
32+ %c2 = icmp eq i32 %e , 2
33+ %v = select i1 %c2 , i32 5 , i32 10
34+ call void @foo (i32 %v )
35+ ret void
36+ }
37+ !0 = !{!"branch_weights" , i32 2 , i32 3 }
38+ ; CHECK-LABEL: @bar
39+ ; CHECK: %v = select i1 %c2, i32 5, i32 10, !prof !2
40+ ; CHECK: !0 = !{!"function_entry_count", i64 1000}
41+ ; CHECK: !1 = !{!"branch_weights", i32 2, i32 3}
42+ ; CHECK: !2 = !{!"branch_weights", i32 1, i32 6}
43+
44+ ;--- verify.ll
45+ declare void @foo (i32 %a );
46+ define void @bar (i1 %c ) !prof !0 {
47+ %v = select i1 %c , i32 1 , i32 2 , !prof !1
48+ call void @foo (i32 %v )
49+ ret void
50+ }
51+ !0 = !{!"function_entry_count" , i64 1000 }
52+ !1 = !{!"branch_weights" , i32 1 , i32 7 }
53+ ; CHECK-NOT: Profile verification failed: select annotation missing
54+
55+ ;--- verify-missing.ll
56+ declare void @foo (i32 %a );
57+ define void @bar (i1 %c ) !prof !0 {
58+ %v = select i1 %c , i32 1 , i32 2
59+ call void @foo (i32 %v )
60+ ret void
61+ }
62+ !0 = !{!"function_entry_count" , i64 1000 }
63+ ; CHECK: Profile verification failed: select annotation missing
0 commit comments