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