1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -O2 -mtriple=m68k -verify-machineinstrs \
3 ; RUN: -code-model=medium -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: move.l (a@GOTPCREL,%pc), %a0
14 ; CHECK-NEXT: move.l (%a0), %d0
17 %0 = load i32, ptr @a, align 4
22 @b = weak global i32 0, align 4
24 define i32 @my_access_global_b() #0 {
25 ; CHECK-LABEL: my_access_global_b:
26 ; CHECK: .cfi_startproc
27 ; CHECK-NEXT: ; %bb.0: ; %entry
28 ; CHECK-NEXT: move.l (b@GOTPCREL,%pc), %a0
29 ; CHECK-NEXT: move.l (%a0), %d0
32 %0 = load i32, ptr @b, align 4
37 @c = internal global i32 0, align 4
39 define i32 @my_access_global_c() #0 {
40 ; CHECK-LABEL: my_access_global_c:
41 ; CHECK: .cfi_startproc
42 ; CHECK-NEXT: ; %bb.0: ; %entry
43 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
44 ; CHECK-NEXT: move.l #c@GOTOFF, %d0
45 ; CHECK-NEXT: move.l (0,%a0,%d0), %d0
48 %0 = load i32, ptr @c, align 4
52 ; External Linkage, only declaration.
53 @d = external global i32, align 4
55 define i32 @my_access_global_load_d() #0 {
56 ; CHECK-LABEL: my_access_global_load_d:
57 ; CHECK: .cfi_startproc
58 ; CHECK-NEXT: ; %bb.0: ; %entry
59 ; CHECK-NEXT: move.l (d@GOTPCREL,%pc), %a0
60 ; CHECK-NEXT: move.l (%a0), %d0
63 %0 = load i32, ptr @d, align 4
67 ; External Linkage, only declaration, store a value.
68 define i32 @my_access_global_store_d() #0 {
69 ; CHECK-LABEL: my_access_global_store_d:
70 ; CHECK: .cfi_startproc
71 ; CHECK-NEXT: ; %bb.0: ; %entry
72 ; CHECK-NEXT: move.l (d@GOTPCREL,%pc), %a0
73 ; CHECK-NEXT: move.l #2, (%a0)
74 ; CHECK-NEXT: moveq #0, %d0
77 store i32 2, ptr @d, align 4
81 ; External Linkage, function pointer access.
82 declare i32 @access_fp(ptr)
85 define i32 @my_access_fp_foo() #0 {
86 ; CHECK-LABEL: my_access_fp_foo:
87 ; CHECK: .cfi_startproc
88 ; CHECK-NEXT: ; %bb.0: ; %entry
89 ; CHECK-NEXT: suba.l #4, %sp
90 ; CHECK-NEXT: .cfi_def_cfa_offset -8
91 ; CHECK-NEXT: move.l (foo@GOTPCREL,%pc), (%sp)
92 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
93 ; CHECK-NEXT: adda.l #4, %sp
96 %call = call i32 @access_fp(ptr @foo)
100 ; LinkOnceODR Linkage, function pointer access.
104 define linkonce_odr i32 @bar() comdat {
106 ; CHECK: .cfi_startproc
107 ; CHECK-NEXT: ; %bb.0: ; %entry
108 ; CHECK-NEXT: moveq #0, %d0
114 define i32 @my_access_fp_bar() #0 {
115 ; CHECK-LABEL: my_access_fp_bar:
116 ; CHECK: .cfi_startproc
117 ; CHECK-NEXT: ; %bb.0: ; %entry
118 ; CHECK-NEXT: suba.l #4, %sp
119 ; CHECK-NEXT: .cfi_def_cfa_offset -8
120 ; CHECK-NEXT: move.l (bar@GOTPCREL,%pc), (%sp)
121 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
122 ; CHECK-NEXT: adda.l #4, %sp
125 %call = call i32 @access_fp(ptr @bar)
129 !llvm.module.flags = !{!0, !1}
130 !0 = !{i32 1, !"PIC Level", i32 1}
131 !1 = !{i32 1, !"PIE Level", i32 1}