xref: /llvm-project/llvm/test/Transforms/Inline/inline-cost-attributes.ll (revision 53e5e586709a329370ea268a8e8191b16fd641b7)
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: 7
15; INLINER-NEXT: NOT Inlining (cost=321, threshold=123), Call:   call void @fn1()
16; INLINER-NEXT: NOT Inlining (cost=963, threshold=123), Call:   call void @fn1()
17; INLINER-NEXT: NOT Inlining (cost=321, threshold=321), Call:   call void @fn1()
18; INLINER-NEXT: NOT Inlining (cost=197, threshold=123), Call:   call void @fn1()
19; INLINER-NEXT: Inlining (cost=197, threshold=321), Call:   call void @fn1()
20
21; COST-LABEL: define void @fn2()
22; COST-NEXT: entry:
23; COST-NEXT: threshold delta = 31
24; COST-NEXT: call void @extern()
25; COST-NEXT: cost delta = 132, threshold delta = 193
26; COST-NEXT: call void @fn1()
27; COST-NEXT: cost delta = 132, threshold delta = 193
28; COST-NEXT: call void @fn1()
29; COST-NEXT: cost delta = 0
30; COST-NEXT: call void @fn1()
31; COST-NEXT: cost delta = 271, threshold delta = 17
32; COST-NEXT: call void @fn1()
33; COST-NEXT: cost delta = 473
34; COST-NEXT: call void @fn1()
35
36entry:
37  call void @extern()
38  call void @fn1() "call-inline-cost"="132" "call-threshold-bonus"="193"
39  call void @fn1() "call-inline-cost"="132" "call-threshold-bonus"="193" "function-inline-cost-multiplier"="3"
40  call void @fn1() "call-inline-cost"="0" "function-inline-threshold"="321"
41  call void @fn1() "call-threshold-bonus"="17" "function-inline-cost"="197"
42  call void @fn1() "call-inline-cost"="473" "function-inline-cost"="197" "function-inline-threshold"="321"
43  ret void
44}
45
46define void @fn3() {
47; INLINER-LABEL: Inlining calls in: fn3
48; INLINER-NEXT: Function size: 3
49; INLINER-NEXT: Inlining (cost=386, threshold=849), Call:   call void @fn1()
50; INLINER-NEXT: Size after inlining: 2
51; INLINER-NEXT: NOT Inlining (cost=535, threshold=41), Call:   call void @fn2()
52
53entry:
54  call void @fn1() "function-inline-cost"="386" "function-inline-threshold"="849"
55  call void @fn2()
56  ret void
57}
58