1
- ; RUN: opt < %s -passes=pgo-instr-gen -pgo-function-entry-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,ENTRY
2
- ; RUN: opt < %s -passes=pgo-instr-gen -pgo-block-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,BLOCK
1
+ ; RUN: opt < %s -passes=pgo-instr-gen -pgo-function-entry-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,GEN,ENTRY
2
+ ; RUN: opt < %s -passes=pgo-instr-gen -pgo-block-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,GEN,BLOCK
3
+
4
+ ; RUN: llvm-profdata merge %S/Inputs/coverage.proftext -o %t.profdata
5
+ ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=CHECK,USE
3
6
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4
7
target triple = "x86_64-unknown-linux-gnu"
5
8
9
+ ; CHECK-LABEL: @foo()
10
+ ; USE-SAME: !prof ![[HOT:[0-9]+]]
6
11
define void @foo () {
7
12
; CHECK-LABEL: entry:
8
13
entry:
9
14
; ENTRY: call void @llvm.instrprof.cover({{.*}})
10
15
%c = call i1 @choice ()
11
16
br i1 %c , label %if.then , label %if.else
17
+ ; USE: br i1 %c, label %if.then, label %if.else, !prof ![[WEIGHTS0:[0-9]+]]
12
18
13
19
; CHECK-LABEL: if.then:
14
20
if.then:
@@ -25,12 +31,15 @@ if.end:
25
31
ret void
26
32
}
27
33
34
+ ; CHECK-LABEL: @bar()
35
+ ; USE-SAME: !prof ![[HOT:[0-9]+]]
28
36
define void @bar () {
29
37
; CHECK-LABEL: entry:
30
38
entry:
31
39
; ENTRY: call void @llvm.instrprof.cover({{.*}})
32
40
%c = call i1 @choice ()
33
41
br i1 %c , label %if.then , label %if.end
42
+ ; USE: br i1 %c, label %if.then, label %if.end, !prof ![[WEIGHTS1:[0-9]+]]
34
43
35
44
; CHECK-LABEL: if.then:
36
45
if.then:
@@ -43,24 +52,29 @@ if.end:
43
52
ret void
44
53
}
45
54
55
+ ; CHECK-LABEL: @goo()
56
+ ; USE-SAME: !prof ![[HOT:[0-9]+]]
46
57
define void @goo () {
47
58
; CHECK-LABEL: entry:
48
59
entry:
49
- ; CHECK : call void @llvm.instrprof.cover({{.*}})
60
+ ; GEN : call void @llvm.instrprof.cover({{.*}})
50
61
ret void
51
62
}
52
63
64
+ ; CHECK-LABEL: @loop()
65
+ ; USE-SAME: !prof ![[HOT:[0-9]+]]
53
66
define void @loop () {
54
67
; CHECK-LABEL: entry:
55
68
entry:
56
- ; CHECK : call void @llvm.instrprof.cover({{.*}})
69
+ ; GEN : call void @llvm.instrprof.cover({{.*}})
57
70
br label %while
58
71
while:
59
72
; BLOCK: call void @llvm.instrprof.cover({{.*}})
60
73
br label %while
61
74
}
62
75
63
- ; Function Attrs: noinline nounwind ssp uwtable
76
+ ; CHECK-LABEL: @hoo(
77
+ ; USE-SAME: !prof ![[HOT:[0-9]+]]
64
78
define void @hoo (i32 %a ) #0 {
65
79
; CHECK-LABEL: entry:
66
80
entry:
72
86
%rem = srem i32 %0 , 2
73
87
%cmp = icmp eq i32 %rem , 0
74
88
br i1 %cmp , label %if.then , label %if.else
89
+ ; USE: br i1 %cmp, label %if.then, label %if.else, !prof ![[WEIGHTS1]]
75
90
76
91
; CHECK-LABEL: if.then:
77
92
if.then: ; preds = %entry
@@ -94,13 +109,15 @@ for.cond: ; preds = %for.inc, %if.end
94
109
%2 = load i32 , i32* %a.addr , align 4
95
110
%cmp1 = icmp slt i32 %1 , %2
96
111
br i1 %cmp1 , label %for.body , label %for.end
112
+ ; USE: br i1 %cmp1, label %for.body, label %for.end, !prof ![[WEIGHTS1]]
97
113
98
114
; CHECK-LABEL: for.body:
99
115
for.body: ; preds = %for.cond
100
116
%3 = load i32 , i32* %a.addr , align 4
101
117
%rem2 = srem i32 %3 , 3
102
118
%cmp3 = icmp eq i32 %rem2 , 0
103
119
br i1 %cmp3 , label %if.then4 , label %if.else5
120
+ ; USE: br i1 %cmp3, label %if.then4, label %if.else5, !prof ![[WEIGHTS0]]
104
121
105
122
; CHECK-LABEL: if.then4:
106
123
if.then4: ; preds = %for.body
@@ -113,6 +130,7 @@ if.else5: ; preds = %for.body
113
130
%rem6 = srem i32 %4 , 1001
114
131
%cmp7 = icmp eq i32 %rem6 , 0
115
132
br i1 %cmp7 , label %if.then8 , label %if.end9
133
+ ; USE: br i1 %cmp7, label %if.then8, label %if.end9, !prof ![[WEIGHTS1]]
116
134
117
135
; CHECK-LABEL: if.then8:
118
136
if.then8: ; preds = %if.else5
@@ -147,4 +165,8 @@ return: ; preds = %for.end, %if.then8
147
165
148
166
declare i1 @choice ()
149
167
150
- ; CHECK: declare void @llvm.instrprof.cover({{.*}})
168
+ ; GEN: declare void @llvm.instrprof.cover({{.*}})
169
+
170
+ ; USE-DAG: ![[HOT]] = !{!"function_entry_count", i64 10000}
171
+ ; USE-DAG: ![[WEIGHTS0]] = !{!"branch_weights", i32 1, i32 1}
172
+ ; USE-DAG: ![[WEIGHTS1]] = !{!"branch_weights", i32 1, i32 0}
0 commit comments