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