1; REQUIRES: asserts
2; RUN: opt -inline-cost-full -passes='cgscc(inline)' -debug-only=inline -disable-output %s 2>&1 | FileCheck --check-prefix=INLINER %s
3; RUN: opt -inline-cost-full -passes='print<inline-cost>' -disable-output %s 2>&1 | FileCheck --check-prefix=COST %s
4
5declare void @extern() "call-threshold-bonus"="31"
6
7define void @fn1() "function-inline-cost"="321" "function-inline-threshold"="123" "call-inline-cost"="271" {
8entry:
9  ret void
10}
11
12define void @fn2() "function-inline-threshold"="41" {
13; INLINER-LABEL: Inlining calls in: fn2
14; INLINER-NEXT: Function size: 6
15; INLINER-NEXT: NOT Inlining (cost=321, threshold=123), Call:   call void @fn1()
16; INLINER-NEXT: NOT Inlining (cost=321, threshold=321), Call:   call void @fn1()
17; INLINER-NEXT: NOT Inlining (cost=197, threshold=123), Call:   call void @fn1()
18; INLINER-NEXT: Inlining (cost=197, threshold=321), Call:   call void @fn1()
19
20; COST-LABEL: define void @fn2()
21; COST-NEXT: entry:
22; COST-NEXT: threshold delta = 31
23; COST-NEXT: call void @extern()
24; COST-NEXT: cost delta = 132, threshold delta = 193
25; COST-NEXT: call void @fn1()
26; COST-NEXT: cost delta = 0
27; COST-NEXT: call void @fn1()
28; COST-NEXT: cost delta = 271, threshold delta = 17
29; COST-NEXT: call void @fn1()
30; COST-NEXT: cost delta = 473
31; COST-NEXT: call void @fn1()
32
33entry:
34  call void @extern()
35  call void @fn1() "call-inline-cost"="132" "call-threshold-bonus"="193"
36  call void @fn1() "call-inline-cost"="0" "function-inline-threshold"="321"
37  call void @fn1() "call-threshold-bonus"="17" "function-inline-cost"="197"
38  call void @fn1() "call-inline-cost"="473" "function-inline-cost"="197" "function-inline-threshold"="321"
39  ret void
40}
41
42define void @fn3() {
43; INLINER-LABEL: Inlining calls in: fn3
44; INLINER-NEXT: Function size: 3
45; INLINER-NEXT: Inlining (cost=386, threshold=849), Call:   call void @fn1()
46; INLINER-NEXT: Size after inlining: 2
47; INLINER-NEXT: NOT Inlining (cost=403, threshold=41), Call:   call void @fn2()
48
49entry:
50  call void @fn1() "function-inline-cost"="386" "function-inline-threshold"="849"
51  call void @fn2()
52  ret void
53}
54