1; Test loads of symbolic addresses in PIC code.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -relocation-model=pic | FileCheck %s
4
5@ev = external global i32
6@dv = global i32 0
7@pv = protected global i32 0
8@hv = hidden global i32 0
9
10declare void @ef()
11define void @df() {
12  ret void
13}
14define protected void @pf() {
15  ret void
16}
17define hidden void @hf() {
18  ret void
19}
20
21; Test loads of external variables, which must go via the GOT.
22define i32 *@f1() {
23; CHECK-LABEL: f1:
24; CHECK: lgrl %r2, ev@GOT
25; CHECK: br %r14
26  ret i32 *@ev
27}
28
29; Check loads of locally-defined normal-visibility variables, which might
30; be overridden.  The load must go via the GOT.
31define i32 *@f2() {
32; CHECK-LABEL: f2:
33; CHECK: lgrl %r2, dv@GOT
34; CHECK: br %r14
35  ret i32 *@dv
36}
37
38; Check loads of protected variables, which in the small code model
39; must be in range of LARL.
40define i32 *@f3() {
41; CHECK-LABEL: f3:
42; CHECK: larl %r2, pv
43; CHECK: br %r14
44  ret i32 *@pv
45}
46
47; ...likewise hidden variables.
48define i32 *@f4() {
49; CHECK-LABEL: f4:
50; CHECK: larl %r2, hv
51; CHECK: br %r14
52  ret i32 *@hv
53}
54
55; Like f1, but for functions.
56define void() *@f5() {
57; CHECK-LABEL: f5:
58; CHECK: lgrl %r2, ef@GOT
59; CHECK: br %r14
60  ret void() *@ef
61}
62
63; Like f2, but for functions.
64define void() *@f6() {
65; CHECK-LABEL: f6:
66; CHECK: lgrl %r2, df@GOT
67; CHECK: br %r14
68  ret void() *@df
69}
70
71; Like f3, but for functions.
72define void() *@f7() {
73; CHECK-LABEL: f7:
74; CHECK: larl %r2, pf
75; CHECK: br %r14
76  ret void() *@pf
77}
78
79; Like f4, but for functions.
80define void() *@f8() {
81; CHECK-LABEL: f8:
82; CHECK: larl %r2, hf
83; CHECK: br %r14
84  ret void() *@hf
85}
86