1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
2; RUN: FileCheck -check-prefix=REMARK %s < %t
3
4; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
5; STDERR-NEXT: remark: foo.cl:27:0:     SGPRs: 24
6; STDERR-NEXT: remark: foo.cl:27:0:     VGPRs: 9
7; STDERR-NEXT: remark: foo.cl:27:0:     AGPRs: 43
8; STDERR-NEXT: remark: foo.cl:27:0:     ScratchSize [bytes/lane]: 0
9; STDERR-NEXT: remark: foo.cl:27:0:     Occupancy [waves/SIMD]: 5
10; STDERR-NEXT: remark: foo.cl:27:0:     SGPRs Spill: 0
11; STDERR-NEXT: remark: foo.cl:27:0:     VGPRs Spill: 0
12; STDERR-NEXT: remark: foo.cl:27:0:     LDS Size [bytes/block]: 512
13
14; REMARK-LABEL: --- !Analysis
15; REMARK: Pass:            kernel-resource-usage
16; REMARK-NEXT: Name:            FunctionName
17; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
18; REMARK-NEXT: Function:        test_kernel
19; REMARK-NEXT: Args:
20; REMARK-NEXT:   - String:          'Function Name: '
21; REMARK-NEXT:   - FunctionName:      test_kernel
22; REMARK-NEXT: ...
23; REMARK-NEXT: --- !Analysis
24; REMARK-NEXT: Pass:            kernel-resource-usage
25; REMARK-NEXT: Name:            NumSGPR
26; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
27; REMARK-NEXT: Function:        test_kernel
28; REMARK-NEXT: Args:
29; REMARK-NEXT:   - String:          '    SGPRs: '
30; REMARK-NEXT:   - NumSGPR:         '24'
31; REMARK-NEXT: ...
32; REMARK-NEXT: --- !Analysis
33; REMARK-NEXT: Pass:            kernel-resource-usage
34; REMARK-NEXT: Name:            NumVGPR
35; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
36; REMARK-NEXT: Function:        test_kernel
37; REMARK-NEXT: Args:
38; REMARK-NEXT:   - String:          '    VGPRs: '
39; REMARK-NEXT:   - NumVGPR:         '9'
40; REMARK-NEXT: ...
41; REMARK-NEXT: --- !Analysis
42; REMARK-NEXT: Pass:            kernel-resource-usage
43; REMARK-NEXT: Name:            NumAGPR
44; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
45; REMARK-NEXT: Function:        test_kernel
46; REMARK-NEXT: Args:
47; REMARK-NEXT:   - String:          '    AGPRs: '
48; REMARK-NEXT:   - NumAGPR:         '43'
49; REMARK-NEXT: ...
50; REMARK-NEXT: --- !Analysis
51; REMARK-NEXT: Pass:            kernel-resource-usage
52; REMARK-NEXT: Name:            ScratchSize
53; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
54; REMARK-NEXT: Function:        test_kernel
55; REMARK-NEXT: Args:
56; REMARK-NEXT:   - String:          '    ScratchSize [bytes/lane]: '
57; REMARK-NEXT:   - ScratchSize:     '0'
58; REMARK-NEXT: ...
59; REMARK-NEXT: --- !Analysis
60; REMARK-NEXT: Pass:            kernel-resource-usage
61; REMARK-NEXT: Name:            Occupancy
62; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
63; REMARK-NEXT: Function:        test_kernel
64; REMARK-NEXT: Args:
65; REMARK-NEXT:   - String:          '    Occupancy [waves/SIMD]: '
66; REMARK-NEXT:   - Occupancy:       '5'
67; REMARK-NEXT: ...
68; REMARK-NEXT: --- !Analysis
69; REMARK-NEXT: Pass:            kernel-resource-usage
70; REMARK-NEXT: Name:            SGPRSpill
71; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
72; REMARK-NEXT: Function:        test_kernel
73; REMARK-NEXT: Args:
74; REMARK-NEXT:   - String:          '    SGPRs Spill: '
75; REMARK-NEXT:   - SGPRSpill:       '0'
76; REMARK-NEXT: ...
77; REMARK-NEXT: --- !Analysis
78; REMARK-NEXT: Pass:            kernel-resource-usage
79; REMARK-NEXT: Name:            VGPRSpill
80; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
81; REMARK-NEXT: Function:        test_kernel
82; REMARK-NEXT: Args:
83; REMARK-NEXT:   - String:          '    VGPRs Spill: '
84; REMARK-NEXT:   - VGPRSpill:       '0'
85; REMARK-NEXT: ...
86; REMARK-NEXT: --- !Analysis
87; REMARK-NEXT: Pass:            kernel-resource-usage
88; REMARK-NEXT: Name:            BytesLDS
89; REMARK-NEXT: DebugLoc:        { File: foo.cl, Line: 27, Column: 0 }
90; REMARK-NEXT: Function:        test_kernel
91; REMARK-NEXT: Args:
92; REMARK-NEXT:   - String:          '    LDS Size [bytes/block]: '
93; REMARK-NEXT:   - BytesLDS:        '512'
94; REMARK-NEXT: ...
95
96@lds = internal unnamed_addr addrspace(3) global [128 x i32] undef, align 4
97
98define amdgpu_kernel void @test_kernel() !dbg !3 {
99  call void asm sideeffect "; clobber v8", "~{v8}"()
100  call void asm sideeffect "; clobber s23", "~{s23}"()
101  call void asm sideeffect "; clobber a42", "~{a42}"()
102  call void asm sideeffect "; use $0", "v"([128 x i32] addrspace(3)* @lds)
103  ret void
104}
105
106; STDERR: remark: foo.cl:42:0: Function Name: test_func
107; STDERR-NEXT: remark: foo.cl:42:0:     SGPRs: 0
108; STDERR-NEXT: remark: foo.cl:42:0:     VGPRs: 0
109; STDERR-NEXT: remark: foo.cl:42:0:     AGPRs: 0
110; STDERR-NEXT: remark: foo.cl:42:0:     ScratchSize [bytes/lane]: 0
111; STDERR-NEXT: remark: foo.cl:42:0:     Occupancy [waves/SIMD]: 0
112; STDERR-NEXT: remark: foo.cl:42:0:     SGPRs Spill: 0
113; STDERR-NEXT: remark: foo.cl:42:0:     VGPRs Spill: 0
114; STDERR-NOT: LDS Size
115define void @test_func() !dbg !6 {
116  call void asm sideeffect "; clobber v17", "~{v17}"()
117  call void asm sideeffect "; clobber s11", "~{s11}"()
118  call void asm sideeffect "; clobber a9", "~{a9}"()
119  ret void
120}
121
122; STDERR: remark: foo.cl:8:0: Function Name: empty_kernel
123; STDERR-NEXT: remark: foo.cl:8:0:     SGPRs: 0
124; STDERR-NEXT: remark: foo.cl:8:0:     VGPRs: 0
125; STDERR-NEXT: remark: foo.cl:8:0:     AGPRs: 0
126; STDERR-NEXT: remark: foo.cl:8:0:     ScratchSize [bytes/lane]: 0
127; STDERR-NEXT: remark: foo.cl:8:0:     Occupancy [waves/SIMD]: 10
128; STDERR-NEXT: remark: foo.cl:8:0:     SGPRs Spill: 0
129; STDERR-NEXT: remark: foo.cl:8:0:     VGPRs Spill: 0
130; STDERR-NEXT: remark: foo.cl:8:0:     LDS Size [bytes/block]: 0
131define amdgpu_kernel void @empty_kernel() !dbg !7 {
132  ret void
133}
134
135; STDERR: remark: foo.cl:52:0: Function Name: empty_func
136; STDERR-NEXT: remark: foo.cl:52:0:     SGPRs: 0
137; STDERR-NEXT: remark: foo.cl:52:0:     VGPRs: 0
138; STDERR-NEXT: remark: foo.cl:52:0:     AGPRs: 0
139; STDERR-NEXT: remark: foo.cl:52:0:     ScratchSize [bytes/lane]: 0
140; STDERR-NEXT: remark: foo.cl:52:0:     Occupancy [waves/SIMD]: 0
141; STDERR-NEXT: remark: foo.cl:52:0:     SGPRs Spill: 0
142; STDERR-NEXT: remark: foo.cl:52:0:     VGPRs Spill: 0
143define void @empty_func() !dbg !8 {
144  ret void
145}
146
147!llvm.dbg.cu = !{!0}
148!llvm.module.flags = !{!2}
149
150!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
151!1 = !DIFile(filename: "foo.cl", directory: "/tmp")
152!2 = !{i32 2, !"Debug Info Version", i32 3}
153!3 = distinct !DISubprogram(name: "test_kernel", scope: !1, file: !1, type: !4, scopeLine: 27, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
154!4 = !DISubroutineType(types: !5)
155!5 = !{null}
156!6 = distinct !DISubprogram(name: "test_func", scope: !1, file: !1, type: !4, scopeLine: 42, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
157!7 = distinct !DISubprogram(name: "empty_kernel", scope: !1, file: !1, type: !4, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
158!8 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, type: !4, scopeLine: 52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
159