• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -S | FileCheck %s
2
3; This tests that the function count of two callees get correctly updated after
4; they have been inlined into two back-to-back callsites in a single basic block
5; in the caller. The callees have the alwaysinline attribute and so they get
6; inlined both with the regular inliner pass and the always inline pass. In
7; both cases, the new count of each callee is the original count minus callsite
8; count which is 200 (since the caller's entry count is 400 and the block
9; containing the calls have a relative block frequency of 0.5).
10
11; CHECK: @callee1(i32 %n) #0 !prof [[COUNT1:![0-9]+]]
12define i32 @callee1(i32 %n) #0 !prof !1 {
13  %cond = icmp sle i32 %n, 10
14  br i1 %cond, label %cond_true, label %cond_false
15
16cond_true:
17  %r1 = add i32 %n, 1
18  ret i32 %r1
19cond_false:
20  %r2 = add i32 %n, 2
21  ret i32 %r2
22}
23
24; CHECK: @callee2(i32 %n) #0 !prof [[COUNT2:![0-9]+]]
25define i32 @callee2(i32 %n) #0 !prof !2 {
26  %r1 = add i32 %n, 1
27  ret i32 %r1
28}
29
30define i32 @caller(i32 %n) !prof !3 {
31  %cond = icmp sle i32 %n, 100
32  br i1 %cond, label %cond_true, label %cond_false
33
34cond_true:
35  %i = call i32 @callee1(i32 %n)
36  %j = call i32 @callee2(i32 %i)
37  ret i32 %j
38cond_false:
39  ret i32 0
40}
41
42!llvm.module.flags = !{!0}
43; CHECK: [[COUNT1]] = !{!"function_entry_count", i64 800}
44; CHECK: [[COUNT2]] = !{!"function_entry_count", i64 1800}
45!0 = !{i32 1, !"MaxFunctionCount", i32 1000}
46!1 = !{!"function_entry_count", i64 1000}
47!2 = !{!"function_entry_count", i64 2000}
48!3 = !{!"function_entry_count", i64 400}
49attributes #0 = { alwaysinline }
50
51