File: function-count-update.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (50 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (27)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -S | FileCheck %s

; This tests that the function count of two callees get correctly updated after
; they have been inlined into two back-to-back callsites in a single basic block
; in the caller. The callees have the alwaysinline attribute and so they get
; inlined both with the regular inliner pass and the always inline pass. In
; both cases, the new count of each callee is the original count minus callsite
; count which is 200 (since the caller's entry count is 400 and the block
; containing the calls have a relative block frequency of 0.5).

; CHECK: @callee1(i32 %n) #0 !prof [[COUNT1:![0-9]+]]
define i32 @callee1(i32 %n) #0 !prof !1 {
  %cond = icmp sle i32 %n, 10
  br i1 %cond, label %cond_true, label %cond_false

cond_true:
  %r1 = add i32 %n, 1
  ret i32 %r1
cond_false:
  %r2 = add i32 %n, 2
  ret i32 %r2
}

; CHECK: @callee2(i32 %n) #0 !prof [[COUNT2:![0-9]+]]
define i32 @callee2(i32 %n) #0 !prof !2 {
  %r1 = add i32 %n, 1
  ret i32 %r1
}

define i32 @caller(i32 %n) !prof !3 {
  %cond = icmp sle i32 %n, 100
  br i1 %cond, label %cond_true, label %cond_false

cond_true:
  %i = call i32 @callee1(i32 %n)
  %j = call i32 @callee2(i32 %i)
  ret i32 %j
cond_false:
  ret i32 0
}

!llvm.module.flags = !{!0}
; CHECK: [[COUNT1]] = !{!"function_entry_count", i64 800}
; CHECK: [[COUNT2]] = !{!"function_entry_count", i64 1800}
!0 = !{i32 1, !"MaxFunctionCount", i32 1000}
!1 = !{!"function_entry_count", i64 1000}
!2 = !{!"function_entry_count", i64 2000}
!3 = !{!"function_entry_count", i64 400}
attributes #0 = { alwaysinline }