1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc < %s -O2 -mtriple=m68k -verify-machineinstrs \
3 ; RUN: -code-model=large -relocation-model=pic \
7 @a = global i32 0, align 4
9 define i32 @my_access_global_a() #0 {
10 ; CHECK-LABEL: my_access_global_a:
11 ; CHECK: .cfi_startproc
12 ; CHECK-NEXT: ; %bb.0: ; %entry
13 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
14 ; CHECK-NEXT: move.l #a@GOTOFF, %d0
15 ; CHECK-NEXT: move.l (0,%a0,%d0), %d0
18 %0 = load i32, ptr @a, align 4
23 @b = weak global i32 0, align 4
25 define i32 @my_access_global_b() #0 {
26 ; CHECK-LABEL: my_access_global_b:
27 ; CHECK: .cfi_startproc
28 ; CHECK-NEXT: ; %bb.0: ; %entry
29 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
30 ; CHECK-NEXT: move.l #b@GOTOFF, %d0
31 ; CHECK-NEXT: move.l (0,%a0,%d0), %d0
34 %0 = load i32, ptr @b, align 4
39 @c = internal global i32 0, align 4
41 define i32 @my_access_global_c() #0 {
42 ; CHECK-LABEL: my_access_global_c:
43 ; CHECK: .cfi_startproc
44 ; CHECK-NEXT: ; %bb.0: ; %entry
45 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
46 ; CHECK-NEXT: move.l #c@GOTOFF, %d0
47 ; CHECK-NEXT: move.l (0,%a0,%d0), %d0
50 %0 = load i32, ptr @c, align 4
54 ; External Linkage, only declaration.
55 @d = external global i32, align 4
57 define i32 @my_access_global_load_d() #0 {
58 ; CHECK-LABEL: my_access_global_load_d:
59 ; CHECK: .cfi_startproc
60 ; CHECK-NEXT: ; %bb.0: ; %entry
61 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
62 ; CHECK-NEXT: move.l #d@GOTOFF, %d0
63 ; CHECK-NEXT: move.l (0,%a0,%d0), %d0
66 %0 = load i32, ptr @d, align 4
70 ; External Linkage, only declaration, store a value.
71 define i32 @my_access_global_store_d() #0 {
72 ; CHECK-LABEL: my_access_global_store_d:
73 ; CHECK: .cfi_startproc
74 ; CHECK-NEXT: ; %bb.0: ; %entry
75 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
76 ; CHECK-NEXT: move.l #d@GOTOFF, %d0
77 ; CHECK-NEXT: move.l #2, (0,%a0,%d0)
78 ; CHECK-NEXT: moveq #0, %d0
81 store i32 2, ptr @d, align 4
85 ; External Linkage, function pointer access.
86 declare i32 @access_fp(ptr)
89 define i32 @my_access_fp_foo() #0 {
90 ; CHECK-LABEL: my_access_fp_foo:
91 ; CHECK: .cfi_startproc
92 ; CHECK-NEXT: ; %bb.0: ; %entry
93 ; CHECK-NEXT: suba.l #4, %sp
94 ; CHECK-NEXT: .cfi_def_cfa_offset -8
95 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
96 ; CHECK-NEXT: adda.l #foo@GOTOFF, %a0
97 ; CHECK-NEXT: move.l %a0, (%sp)
98 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
99 ; CHECK-NEXT: adda.l #4, %sp
102 %call = call i32 @access_fp(ptr @foo)
106 ; LinkOnceODR Linkage, function pointer access.
110 define linkonce_odr i32 @bar() comdat {
112 ; CHECK: .cfi_startproc
113 ; CHECK-NEXT: ; %bb.0: ; %entry
114 ; CHECK-NEXT: moveq #0, %d0
120 define i32 @my_access_fp_bar() #0 {
121 ; CHECK-LABEL: my_access_fp_bar:
122 ; CHECK: .cfi_startproc
123 ; CHECK-NEXT: ; %bb.0: ; %entry
124 ; CHECK-NEXT: suba.l #4, %sp
125 ; CHECK-NEXT: .cfi_def_cfa_offset -8
126 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
127 ; CHECK-NEXT: adda.l #bar@GOTOFF, %a0
128 ; CHECK-NEXT: move.l %a0, (%sp)
129 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
130 ; CHECK-NEXT: adda.l #4, %sp
133 %call = call i32 @access_fp(ptr @bar)
137 !llvm.module.flags = !{!0, !1}
138 !0 = !{i32 1, !"PIC Level", i32 1}
139 !1 = !{i32 1, !"PIE Level", i32 1}