1; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck -check-prefixes=OPT,OPT-EXT %s
2; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes='default<O1>' < %s | FileCheck -check-prefixes=OPT,OPT-EXT %s
3; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 --amdgpu-internalize-symbols < %s | FileCheck -check-prefixes=OPT,OPT-INT %s
4; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes='default<O1>' --amdgpu-internalize-symbols < %s | FileCheck -check-prefixes=OPT,OPT-INT %s
5; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s
6; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s
7
8; OPT: declare void @foo4() local_unnamed_addr #0
9; OPT: define internal fastcc void @0() unnamed_addr #1
10; OPT-EXT: define void @foo3() local_unnamed_addr #1
11; OPT-INT: define internal fastcc void @foo3.2() unnamed_addr #1
12; OPT-EXT: define void @foo2() local_unnamed_addr #1
13; OPT-INT: define internal fastcc void @foo2.3() unnamed_addr #1
14; OPT-EXT: define void @foo1() local_unnamed_addr #1
15; OPT-EXT:  tail call void @foo4()
16; OPT-EXT:  tail call void @foo3()
17; OPT-EXT:  tail call void @foo2()
18; OPT-EXT:  tail call void @foo2()
19; OPT-EXT:  tail call void @foo1()
20; OPT-EXT:  tail call fastcc void @0()
21; OPT-INT: define internal fastcc void @foo1.1() unnamed_addr #1
22; OPT-INT:  tail call void @foo4()
23; OPT-INT:  tail call fastcc void @foo3.2()
24; OPT-INT:  tail call fastcc void @foo2.3()
25; OPT-INT:  tail call fastcc void @foo2.3()
26; OPT-INT:  tail call fastcc void @foo1.1()
27; OPT-INT:  tail call fastcc void @0()
28; OPT:      ret void
29; OPT: define amdgpu_kernel void @kernel1() local_unnamed_addr #2
30; OPT-EXT:  tail call fastcc void @foo1.1()
31; OPT-INT:  tail call fastcc void @foo1()
32; OPT:      ret void
33; OPT: define amdgpu_kernel void @kernel2() local_unnamed_addr #3
34; OPT-EXT:  tail call void @foo2()
35; OPT-INT:  tail call fastcc void @foo2.3()
36; OPT:      ret void
37; OPT: define amdgpu_kernel void @kernel3() local_unnamed_addr #3
38; OPT-EXT:  tail call void @foo1()
39; OPT-INT:  tail call fastcc void @foo1.1()
40; OPT:      ret void
41; OPT-EXT: define internal fastcc void @foo1.1() unnamed_addr #4
42; OPT-EXT:  tail call void @foo4()
43; OPT-EXT:  tail call fastcc void @foo3.2()
44; OPT-EXT:  tail call fastcc void @foo2.3()
45; OPT-EXT:  tail call fastcc void @foo2.3()
46; OPT-EXT:  tail call fastcc void @foo1.1()
47; OPT-EXT:  tail call fastcc void @1()
48; OPT-INT: define internal fastcc void @foo1() unnamed_addr #4
49; OPT-INT:  tail call void @foo4()
50; OPT-INT:  tail call fastcc void @foo3()
51; OPT-INT:  tail call fastcc void @foo2()
52; OPT-INT:  tail call fastcc void @foo2()
53; OPT-INT:  tail call fastcc void @foo1()
54; OPT-INT:  tail call fastcc void @1()
55; OPT:      ret void
56; OPT: define internal fastcc void @1() unnamed_addr #4
57; OPT-EXT: define internal fastcc void @foo3.2() unnamed_addr #4
58; OPT-INT: define internal fastcc void @foo3() unnamed_addr #4
59; OPT-EXT: define internal fastcc void @foo2.3() unnamed_addr #4
60; OPT-INT: define internal fastcc void @foo2() unnamed_addr #4
61; OPT: attributes #0 = { {{.*}} "amdgpu-waves-per-eu"="1,1" "target-features"="+wavefrontsize64" }
62; OPT: attributes #1 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,-wavefrontsize32,+wavefrontsize64{{.*}}" }
63; OPT: attributes #2 = { {{.*}} "amdgpu-waves-per-eu"="2,4" "target-features"="+wavefrontsize32" }
64; OPT: attributes #3 = { {{.*}} "target-features"="+wavefrontsize64" }
65; OPT: attributes #4 = { {{.*}} "amdgpu-waves-per-eu"="2,4" "target-features"="{{.*}},-wavefrontsize16,+wavefrontsize32,-wavefrontsize64{{.*}}" }
66
67; LLC: foo3:
68; LLC: sample asm
69; LLC: foo2:
70; LLC: sample asm
71; LLC: foo1:
72; LLC: foo4@gotpcrel32@lo+4
73; LLC: foo4@gotpcrel32@hi+12
74; LLC: foo3@gotpcrel32@lo+4
75; LLC: foo3@gotpcrel32@hi+12
76; LLC: foo2@gotpcrel32@lo+4
77; LLC: foo2@gotpcrel32@hi+12
78; LLC: foo1@gotpcrel32@lo+4
79; LLC: foo1@gotpcrel32@hi+12
80; LLC: __unnamed_1@gotpcrel32@lo+4
81; LLC: __unnamed_1@gotpcrel32@hi+12
82; LLC: kernel1:
83; LLC: foo1@gotpcrel32@lo+4
84; LLC: foo1@gotpcrel32@hi+12
85; LLC: kernel2:
86; LLC: foo2@gotpcrel32@lo+4
87; LLC: foo2@gotpcrel32@hi+12
88; LLC: kernel3:
89; LLC: foo1@gotpcrel32@lo+4
90; LLC: foo1@gotpcrel32@hi+12
91
92declare void @foo4() #1
93
94define void @0() #1 {
95entry:
96  call void asm sideeffect "; sample asm", ""()
97  ret void
98}
99
100define void @foo3() #4 {
101entry:
102  call void asm sideeffect "; sample asm", ""()
103  ret void
104}
105
106define void @foo2() #1 {
107entry:
108  call void asm sideeffect "; sample asm", ""()
109  ret void
110}
111
112define void @foo1() #1 {
113entry:
114  tail call void @foo4()
115  tail call void @foo3()
116  tail call void @foo2()
117  tail call void @foo2()
118  tail call void @foo1()
119  tail call void @0()
120  ret void
121}
122
123define amdgpu_kernel void @kernel1() #0 {
124entry:
125  tail call void @foo1()
126  ret void
127}
128
129define amdgpu_kernel void @kernel2() #2 {
130entry:
131  tail call void @foo2()
132  ret void
133}
134
135define amdgpu_kernel void @kernel3() #3 {
136entry:
137  tail call void @foo1()
138  ret void
139}
140
141attributes #0 = { nounwind "target-features"="+wavefrontsize32" "amdgpu-waves-per-eu"="2,4" }
142attributes #1 = { noinline nounwind "target-features"="+wavefrontsize64" "amdgpu-waves-per-eu"="1,1" }
143attributes #2 = { nounwind "target-features"="+wavefrontsize64" }
144attributes #3 = { nounwind "target-features"="+wavefrontsize64" }
145attributes #4 = { noinline nounwind "target-features"="+wavefrontsize64" "amdgpu-waves-per-eu"="2,4" }
146