xref: /llvm-project/llvm/test/tools/gold/X86/opt-remarks.ll (revision 6ec8c6fc7b30bb770cf3e454a89ebd2be1bed88e)
1; Test plugin options for opt-remarks.
2; RUN: llvm-as %s -o %t.o
3; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
4; RUN:	  -plugin-opt=save-temps \
5; RUN:    -plugin-opt=opt-remarks-passes=inline \
6; RUN:    -plugin-opt=opt-remarks-format=yaml \
7; RUN:    -plugin-opt=opt-remarks-filename=%t.yaml %t.o -o %t2.o 2>&1
8; RUN: llvm-dis %t2.o.0.4.opt.bc -o - | FileCheck %s
9; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
10; RUN:    -plugin-opt=opt-remarks-passes=inline \
11; RUN:    -plugin-opt=opt-remarks-format=yaml \
12; RUN:    -plugin-opt=opt-remarks-with-hotness \
13; RUN:	  -plugin-opt=opt-remarks-filename=%t.hot.yaml %t.o -o %t2.o 2>&1
14; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
15; RUN:    -plugin-opt=opt-remarks-passes=inline \
16; RUN:    -plugin-opt=opt-remarks-format=yaml \
17; RUN:    -plugin-opt=opt-remarks-with-hotness \
18; RUN:    -plugin-opt=opt-remarks-hotness-threshold=300 \
19; RUN:	  -plugin-opt=opt-remarks-filename=%t.t300.yaml %t.o -o %t2.o 2>&1
20; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
21; RUN:    -plugin-opt=opt-remarks-passes=inline \
22; RUN:    -plugin-opt=opt-remarks-format=yaml \
23; RUN:    -plugin-opt=opt-remarks-with-hotness \
24; RUN:    -plugin-opt=opt-remarks-hotness-threshold=301 \
25; RUN:	  -plugin-opt=opt-remarks-filename=%t.t301.yaml %t.o -o %t2.o 2>&1
26; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
27; RUN: cat %t.hot.yaml | FileCheck %s -check-prefix=YAML-HOT
28; RUN: FileCheck %s -check-prefix=YAML-HOT < %t.t300.yaml
29; RUN: count 0 < %t.t301.yaml
30
31; Check that @f is inlined after optimizations.
32; CHECK-LABEL: define i32 @_start
33; CHECK-NEXT:  %a.i = tail call i32 @bar()
34; CHECK-NEXT:  ret i32 %a.i
35; CHECK-NEXT: }
36
37; YAML: --- !Missed
38; YAML-NEXT: Pass:            inline
39; YAML-NEXT: Name:            NoDefinition
40; YAML-NEXT: Function:        f
41; YAML-NEXT: Args:
42; YAML-NEXT:   - Callee:          bar
43; YAML-NEXT:   - String:          ' will not be inlined into '
44; YAML-NEXT:   - Caller:          f
45; YAML-NEXT:   - String:          ' because its definition is unavailable'
46; YAML-NEXT: ...
47; YAML-NEXT: --- !Missed
48; YAML-NEXT: Pass:            inline
49; YAML-NEXT: Name:            NoDefinition
50; YAML-NEXT: Function:        f
51; YAML-NEXT: Args:
52; YAML-NEXT:   - Callee:          bar
53; YAML-NEXT:   - String:          ' will not be inlined into '
54; YAML-NEXT:   - Caller:          f
55; YAML-NEXT:   - String:          ' because its definition is unavailable'
56; YAML-NEXT: ...
57; YAML-NEXT: --- !Passed
58; YAML-NEXT: Pass:            inline
59; YAML-NEXT: Name:            Inlined
60; YAML-NEXT: Function:        _start
61; YAML-NEXT: Args:
62; YAML-NEXT:   - String:          ''''
63; YAML-NEXT:   - Callee:          f
64; YAML-NEXT:   - String:          ''' inlined into '''
65; YAML-NEXT:   - Caller:          _start
66; YAML-NEXT:   - String:          ''''
67; YAML-NEXT:   - String:          ' with '
68; YAML-NEXT:   - String:          '(cost='
69; YAML-NEXT:   - Cost:            '0'
70; YAML-NEXT:   - String:          ', threshold='
71; YAML-NEXT:   - Threshold:       '337'
72; YAML-NEXT:   - String:          ')'
73; YAML-NEXT: ...
74
75; YAML-HOT: --- !Passed
76; YAML-HOT: Pass:            inline
77; YAML-HOT-NEXT: Name:            Inlined
78; YAML-HOT-NEXT: Function:        _start
79; YAML-HOT-NEXT: Hotness:         300
80; YAML-HOT-NEXT: Args:
81; YAML-HOT-NEXT:   - String:          ''''
82; YAML-HOT-NEXT:   - Callee:          f
83; YAML-HOT-NEXT:   - String:          ''' inlined into '''
84; YAML-HOT-NEXT:   - Caller:          _start
85; YAML-HOT-NEXT:   - String:          ''''
86; YAML-HOT-NEXT:   - String:          ' with '
87; YAML-HOT-NEXT:   - String:          '(cost='
88; YAML-HOT-NEXT:   - Cost:            '0'
89; YAML-HOT-NEXT:   - String:          ', threshold='
90; YAML-HOT-NEXT:   - Threshold:       '337'
91; YAML-HOT-NEXT:   - String:          ')'
92; YAML-HOT-NEXT: ...
93
94target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
95target triple = "x86_64-unknown-linux-gnu"
96
97declare i32 @bar()
98
99define i32 @f() {
100  %a = call i32 @bar()
101  ret i32 %a
102}
103
104define i32 @_start() !prof !0 {
105  %call = call i32 @f()
106  ret i32 %call
107}
108
109!0 = !{!"function_entry_count", i64 300}
110