blob: 9a0d81fbbd78be5c39c12f01b00768f8976ade64 [file] [log] [blame]
Stefan Pintilie46f840f2018-12-04 20:14:57 +00001; RUN: llc -mtriple powerpc64le-unkown-gnu-linux -relocation-model=pic \
2; RUN: < %s | FileCheck %s
Sean Fertilec70d28b2017-10-26 15:00:26 +00003; RUN: llc -mtriple powerpc64le-unkown-gnu-linux -relocation-model=static \
4; RUN: < %s | FileCheck --check-prefix=STATIC %s
5; RUN: llc -mtriple powerpc64le-unkown-gnu-linux -relocation-model=pic \
6; RUN: < %s | FileCheck %s
7
8; globals
9
10@strong_default = global i32 55
11define i32* @get_strong_default() #0 {
12 ret i32* @strong_default
13
14; STATIC-LABEL: @get_strong_default
15; STATIC: addis 3, 2, strong_default@toc@ha
16; STATIC: addi 3, 3, strong_default@toc@l
17; STATIC: blr
18
19; CHECK-LABEL: @get_strong_default
20; CHECK: addis 3, 2, .LC0@toc@ha
21; CHECK: ld 3, .LC0@toc@l(3)
22; CHECK: blr
23}
24
25@weak_default = weak global i32 55
26define i32* @get_weak_default() #0 {
27 ret i32* @weak_default
28
29; STATIC-LABEL: @get_weak_default
30; STATIC: addis 3, 2, weak_default@toc@ha
31; STATIC: addi 3, 3, weak_default@toc@l
32; STATIC: blr
33
34; CHECK-LABEL: @get_weak_default
35; CHECK: addis 3, 2, .LC1@toc@ha
36; CHECK: ld 3, .LC1@toc@l(3)
37; CHECK: blr
38}
39
40@external_default_global = external global i32
41define i32* @get_external_default_global() {
42 ret i32* @external_default_global
43
44; STATIC-LABEL: @get_external_default_global
45; STATIC: addis 3, 2, .LC0@toc@ha
46; STATIC: ld 3, .LC0@toc@l(3)
47; STATIC: blr
48
49; CHECK-LABEL: @get_external_default_global
50; CHECK: addis 3, 2, .LC2@toc@ha
51; CHECK: ld 3, .LC2@toc@l(3)
52; CHECK: blr
53}
54
55
56@strong_local_global = dso_local global i32 55
57define i32* @get_strong_local_global() {
58 ret i32* @strong_local_global
59
60; STATIC-LABEL: @get_strong_local_global
61; STATIC: addis 3, 2, strong_local_global@toc@ha
62; STATIC: addi 3, 3, strong_local_global@toc@l
63; STATIC: blr
64
65; CHECK-LABEL: @get_strong_local_global
66; CHECK: addis 3, 2, strong_local_global@toc@ha
67; CHECK: addi 3, 3, strong_local_global@toc@l
68; CHECK: blr
69}
70
71@weak_local_global = weak dso_local global i32 42
72define i32* @get_weak_local_global() {
73 ret i32* @weak_local_global
74
75; STATIC-LABEL: @get_weak_local_global
76; STATIC: addis 3, 2, weak_local_global@toc@ha
77; STATIC: addi 3, 3, weak_local_global@toc@l
78; STATIC: blr
79
80; CHECK-LABEL: @get_weak_local_global
81; CHECK: addis 3, 2, weak_local_global@toc@ha
82; CHECK: addi 3, 3, weak_local_global@toc@l
83; CHECK: blr
84}
85
86@external_local_global = external dso_local global i32
87define i32* @get_external_local_global() {
88 ret i32* @external_local_global
89; STATIC-LABEL: @get_external_local_global
90; STATIC: addis 3, 2, external_local_global@toc@ha
91; STATIC: addi 3, 3, external_local_global@toc@l
92; STATIC: blr
93
94; CHECK-LABEL: @get_external_local_global
95; CHECK: addis 3, 2, external_local_global@toc@ha
96; CHECK: addi 3, 3, external_local_global@toc@l
97; CHECK: blr
98}
99
100@strong_preemptable_global = dso_preemptable global i32 42
101define i32* @get_strong_preemptable_global() {
102 ret i32* @strong_preemptable_global
103
104; STATIC-LABEL: @get_strong_preemptable_global
105; STATIC: addis 3, 2, strong_preemptable_global@toc@ha
106; STATIC: addi 3, 3, strong_preemptable_global@toc@l
107; STATIC: blr
108
109; CHECK-LABEL: @get_strong_preemptable_global
110; CHECK: addis 3, 2, .LC3@toc@ha
111; CHECK: ld 3, .LC3@toc@l(3)
112; CHECK: blr
113}
114
115@weak_preemptable_global = weak dso_preemptable global i32 42
116define i32* @get_weak_preemptable_global() {
117 ret i32* @weak_preemptable_global
118
119; STATIC-LABEL: @get_weak_preemptable_global
120; STATIC: addis 3, 2, weak_preemptable_global@toc@ha
121; STATIC: addi 3, 3, weak_preemptable_global@toc@l
122; STATIC: blr
123
124; CHECK-LABEL: @get_weak_preemptable_global
125; CHECK: addis 3, 2, .LC4@toc@ha
126; CHECK: ld 3, .LC4@toc@l(3)
127; CHECK: blr
128}
129
130@external_preemptable_global = external dso_preemptable global i32
131define i32* @get_external_preemptable_global() {
132 ret i32* @external_preemptable_global
133
134; STATIC-LABEL: @get_external_preemptable_global
135; STATIC: addis 3, 2, .LC1@toc@ha
136; STATIC: ld 3, .LC1@toc@l(3)
137; STATIC: blr
138
139; CHECK-LABEL: @get_external_preemptable_global
140; CHECK: addis 3, 2, .LC5@toc@ha
141; CHECK: ld 3, .LC5@toc@l(3)
142; CHECK: blr
143}
144
145; functions
146define signext i32 @strong_default_function(i32 %i) {
147 ret i32 %i
148}
149define signext i32 @strong_default_function_caller(i32 %i) {
150 %call = notail call signext i32 @strong_default_function(i32 signext %i)
151 ret i32 %call
152
153; STATIC-LABEL: @strong_default_function_caller
154; STATIC: bl strong_default_function
155; STATIC-NOT: nop
156; STATIC: blr
157
158; CHECK-LABEL: @strong_default_function_caller
159; CHECK: bl strong_default_function
160; CHECK-NEXT: nop
161; CHECK: blr
162}
163
164define weak signext i32 @weak_default_function(i32 %i) {
165 ret i32 %i
166}
167define signext i32 @weak_default_function_caller(i32 %i) {
168 %call = notail call signext i32 @weak_default_function(i32 signext %i)
169 ret i32 %call
170
171; STATIC-LABEL: @weak_default_function_caller
172; STATIC: bl weak_default_function
173; STATIC-NOT: nop
174; STATIC: blr
175
176; CHECK-LABEL: @weak_default_function_caller
177; CHECK: bl weak_default_function
178; CHECK-NEXT: nop
179; CHECK: blr
180}
181
182
183declare i32 @external_default_function(i32 %i)
184define i32 @external_default_function_caller(i32 %i) {
185 %call = notail call signext i32 @external_default_function(i32 signext %i)
186 ret i32 %call
187
188; STATIC-LABEL: @external_default_function_caller
189; STATIC: bl external_default_function
190; STATIC-NEXT: nop
191; STATIC: blr
192
193; CHECK-LABEL: @external_default_function_caller
194; CHECK: bl external_default_function
195; CHECK-NEXT: nop
196; CHECK: blr
197}
198
199define dso_local signext i32 @strong_local_function(i32 %i) {
200 ret i32 %i
201}
202define signext i32 @strong_local_function_caller(i32 %i) {
203 %call = notail call signext i32 @strong_local_function(i32 signext %i)
204 ret i32 %call
205
206; STATIC-LABEL: @strong_local_function_caller
207; STATIC: bl strong_local_function
208; STATIC-NOT: nop
209; STATIC: blr
210
211; CHECK-LABEL: @strong_local_function_caller
212; CHECK: bl strong_local_function
213; CHECK-NOT: nop
214; CHECK: blr
215}
216
217define weak dso_local signext i32 @weak_local_function(i32 %i) {
218 ret i32 %i
219}
220define signext i32 @weak_local_function_caller(i32 %i) {
221 %call = notail call signext i32 @weak_local_function(i32 signext %i)
222 ret i32 %call
223
224; STATIC-LABEL: @weak_local_function_caller
225; STATIC: bl weak_local_function
226; STATIC-NOT: nop
227; STATIC: blr
228
229; CHECK-LABEL: @weak_local_function_caller
230; CHECK: bl weak_local_function
231; CHECK-NOT: nop
232; CHECK: blr
233}
234
235declare dso_local i32 @external_local_function(i32 %i)
236define i32 @external_local_function_caller(i32 %i) {
237 %call = notail call signext i32 @external_local_function(i32 signext %i)
238 ret i32 %call
239
240; STATIC-LABEL: @external_local_function_caller
241; STATIC: bl external_local_function
242; STATIC-NOT: nop
243; STATIC: blr
244
245; CHECK-LABEL: @external_local_function_caller
246; CHECK: bl external_local_function
247; CHECK-NOT: nop
248; CHECK: blr
249}
250
251define dso_preemptable signext i32 @strong_preemptable_function(i32 %i) {
252 ret i32 %i
253}
254define signext i32 @strong_preemptable_function_caller(i32 %i) {
255 %call = notail call signext i32 @strong_preemptable_function(i32 signext %i)
256 ret i32 %call
257
258; STATIC-LABEL: @strong_preemptable_function_caller
259; STATIC: bl strong_preemptable_function
260; STATIC-NOT: nop
261; STATIC: blr
262
263; CHECK-LABEL: @strong_preemptable_function_caller
264; CHECK: bl strong_preemptable_function
265; CHECK-NEXT: nop
266; CHECK: blr
267}
268
269define weak dso_preemptable signext i32 @weak_preemptable_function(i32 %i) {
270 ret i32 %i
271}
272define signext i32 @weak_preemptable_function_caller(i32 %i) {
273 %call = notail call signext i32 @weak_preemptable_function(i32 signext %i)
274 ret i32 %call
275
276; STATIC-LABEL: @weak_preemptable_function_caller
277; STATIC: bl weak_preemptable_function
278; STATIC-NOT: nop
279; STATIC: blr
280
281; CHECK-LABEL: @weak_preemptable_function_caller
282; CHECK: bl weak_preemptable_function
283; CHECK-NEXT: nop
284; CHECK: blr
285}
286
287declare dso_preemptable i32 @external_preemptable_function(i32 %i)
288define i32 @external_preemptable_function_caller(i32 %i) {
289 %call = notail call signext i32 @external_preemptable_function(i32 signext %i)
290 ret i32 %call
291
292; STATIC-LABEL: @external_preemptable_function_caller
293; STATIC: bl external_preemptable_function
294; STATIC-NEXT: nop
295; STATIC: blr
296
297; CHECK-LABEL: @external_preemptable_function_caller
298; CHECK: bl external_preemptable_function
299; CHECK-NEXT: nop
300; CHECK: blr
301}
302