File: last-call-bonus.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (53 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (9)
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
51
52
53
; The goal of this test is checking if LastCallToStaticBonus is applied
; correctly while deciding inline deferral. For the test code below, when
; inliner evaluates the callsite of bar->baz, it checks if inlining of bar->baz
; prevents ininling of foo->bar, even when foo->bar inlining is more beneficial
; than bar->baz inlining. As LastCallToStaticBonus has a massive value, and
; both baz and bar has only one caller, the cost of foo->bar inlining and
; bar->baz inlining should be non-trivial for inliner to compute that bar->baz
; inlining can actaully prevent foo->bar inlining. To make the cost of these
; callsites big enough, loop unrolling pass with very high threshold is used to
; preprocess the test.

; RUN: opt < %s -loop-unroll -inline -unroll-threshold=15000 -inline-threshold=250 -S | FileCheck %s
; RUN: opt < %s -passes='function(require<opt-remark-emit>,loop-unroll),require<profile-summary>,cgscc(inline)' -unroll-threshold=15000 -inline-threshold=250 -S | FileCheck %s
; CHECK-LABEL: define internal i32 @bar()

define internal i32 @baz() {
entry:
  br label %bb1

bb1:
  %ind = phi i32 [ 0, %entry ], [ %inc, %bb1 ]
  call void @extern()
  %inc = add nsw i32 %ind, 1
  %cmp = icmp sgt i32 %inc, 510
  br i1 %cmp, label %ret, label %bb1

ret:
  ret i32 0
}

define internal i32 @bar() {
entry:
  br label %bb1

bb1:
  %ind = phi i32 [ 0, %entry ], [ %inc, %bb1 ]
  call void @extern()
  %inc = add nsw i32 %ind, 1
  %cmp = icmp sgt i32 %inc, 510
  br i1 %cmp, label %ret, label %bb1

ret:
  call i32 @baz()
  ret i32 0
}

define i32 @foo() {
entry:
  call i32 @bar()
  ret i32 0
}

declare void @extern()