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 -O1 --amdgpu-internalize-symbols < %s | FileCheck -check-prefixes=OPT,OPT-INT %s
3; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s
4
5; OPT: declare void @foo4() local_unnamed_addr #0
6; OPT: define internal fastcc void @0() unnamed_addr #1
7; OPT-EXT: define void @foo3() local_unnamed_addr #1
8; OPT-INT: define internal fastcc void @foo3.2() unnamed_addr #1
9; OPT-EXT: define void @foo2() local_unnamed_addr #1
10; OPT-INT: define internal fastcc void @foo2() unnamed_addr #1
11; OPT-EXT: define void @foo1() local_unnamed_addr #1
12; OPT-INT: define internal fastcc void @foo1.1() unnamed_addr #1
13; OPT: define amdgpu_kernel void @kernel1() local_unnamed_addr #2
14; OPT: define amdgpu_kernel void @kernel2() local_unnamed_addr #3
15; OPT: define amdgpu_kernel void @kernel3() local_unnamed_addr #3
16; OPT-EXT: define internal fastcc void @foo1.1() unnamed_addr #4
17; OPT-INT: define internal fastcc void @foo1() unnamed_addr #4
18; OPT: define internal fastcc void @1() unnamed_addr #4
19; OPT-EXT: define internal fastcc void @foo3.2() unnamed_addr #4
20; OPT-INT: define internal fastcc void @foo3() unnamed_addr #4
21; OPT: attributes #0 = { {{.*}} "target-features"="+wavefrontsize64" }
22; OPT: attributes #1 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,-wavefrontsize32,+wavefrontsize64{{.*}}" }
23; OPT: attributes #2 = { {{.*}} "target-features"="+wavefrontsize32" }
24; OPT: attributes #3 = { {{.*}} "target-features"="+wavefrontsize64" }
25; OPT: attributes #4 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,+wavefrontsize32,-wavefrontsize64{{.*}}" }
26
27; LLC: foo3:
28; LLC: sample asm
29; LLC: foo2:
30; LLC: sample asm
31; LLC: foo1:
32; LLC: foo4@gotpcrel32@lo+4
33; LLC: foo4@gotpcrel32@hi+4
34; LLC: foo3@gotpcrel32@lo+4
35; LLC: foo3@gotpcrel32@hi+4
36; LLC: foo2@gotpcrel32@lo+4
37; LLC: foo2@gotpcrel32@hi+4
38; LLC: foo1@gotpcrel32@lo+4
39; LLC: foo1@gotpcrel32@hi+4
40; LLC: __unnamed_1@gotpcrel32@lo+4
41; LLC: __unnamed_1@gotpcrel32@hi+4
42; LLC: kernel1:
43; LLC: foo1@gotpcrel32@lo+4
44; LLC: foo1@gotpcrel32@hi+4
45; LLC: kernel2:
46; LLC: foo2@gotpcrel32@lo+4
47; LLC: foo2@gotpcrel32@hi+4
48; LLC: kernel3:
49; LLC: foo1@gotpcrel32@lo+4
50; LLC: foo1@gotpcrel32@hi+4
51
52declare void @foo4() #1
53
54define void @0() #1 {
55entry:
56  call void asm sideeffect "; sample asm", ""()
57  ret void
58}
59
60define void @foo3() #1 {
61entry:
62  call void asm sideeffect "; sample asm", ""()
63  ret void
64}
65
66define void @foo2() #1 {
67entry:
68  call void asm sideeffect "; sample asm", ""()
69  ret void
70}
71
72define void @foo1() #1 {
73entry:
74  tail call void @foo4()
75  tail call void @foo3()
76  tail call void @foo2()
77  tail call void @foo2()
78  tail call void @foo1()
79  tail call void @0()
80  ret void
81}
82
83define amdgpu_kernel void @kernel1() #0 {
84entry:
85  tail call void @foo1()
86  ret void
87}
88
89define amdgpu_kernel void @kernel2() #2 {
90entry:
91  tail call void @foo2()
92  ret void
93}
94
95define amdgpu_kernel void @kernel3() #3 {
96entry:
97  tail call void @foo1()
98  ret void
99}
100
101attributes #0 = { nounwind "target-features"="+wavefrontsize32" }
102attributes #1 = { noinline nounwind "target-features"="+wavefrontsize64" }
103attributes #2 = { nounwind "target-features"="+wavefrontsize64" }
104attributes #3 = { nounwind "target-features"="+wavefrontsize64" }
105