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=small -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: move.l (c,%pc), %d0
46 %0 = load i32, ptr @c, align 4
50 ; External Linkage, only declaration.
51 @d = external global i32, align 4
53 define i32 @my_access_global_load_d() #0 {
54 ; CHECK-LABEL: my_access_global_load_d:
55 ; CHECK: .cfi_startproc
56 ; CHECK-NEXT: ; %bb.0: ; %entry
57 ; CHECK-NEXT: move.l (d@GOTPCREL,%pc), %a0
58 ; CHECK-NEXT: move.l (%a0), %d0
61 %0 = load i32, ptr @d, align 4
65 ; External Linkage, only declaration, store a value.
66 define i32 @my_access_global_store_d() #0 {
67 ; CHECK-LABEL: my_access_global_store_d:
68 ; CHECK: .cfi_startproc
69 ; CHECK-NEXT: ; %bb.0: ; %entry
70 ; CHECK-NEXT: move.l (d@GOTPCREL,%pc), %a0
71 ; CHECK-NEXT: move.l #2, (%a0)
72 ; CHECK-NEXT: moveq #0, %d0
75 store i32 2, ptr @d, align 4
79 ; External Linkage, function pointer access.
80 declare i32 @access_fp(ptr)
83 define i32 @my_access_fp_foo() #0 {
84 ; CHECK-LABEL: my_access_fp_foo:
85 ; CHECK: .cfi_startproc
86 ; CHECK-NEXT: ; %bb.0: ; %entry
87 ; CHECK-NEXT: suba.l #4, %sp
88 ; CHECK-NEXT: .cfi_def_cfa_offset -8
89 ; CHECK-NEXT: move.l (foo@GOTPCREL,%pc), (%sp)
90 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
91 ; CHECK-NEXT: adda.l #4, %sp
94 %call = call i32 @access_fp(ptr @foo)
98 ; LinkOnceODR Linkage, function pointer access.
102 define linkonce_odr i32 @bar() comdat {
104 ; CHECK: .cfi_startproc
105 ; CHECK-NEXT: ; %bb.0: ; %entry
106 ; CHECK-NEXT: moveq #0, %d0
112 define i32 @my_access_fp_bar() #0 {
113 ; CHECK-LABEL: my_access_fp_bar:
114 ; CHECK: .cfi_startproc
115 ; CHECK-NEXT: ; %bb.0: ; %entry
116 ; CHECK-NEXT: suba.l #4, %sp
117 ; CHECK-NEXT: .cfi_def_cfa_offset -8
118 ; CHECK-NEXT: move.l (bar@GOTPCREL,%pc), (%sp)
119 ; CHECK-NEXT: jsr (access_fp@PLT,%pc)
120 ; CHECK-NEXT: adda.l #4, %sp
123 %call = call i32 @access_fp(ptr @bar)
127 !llvm.module.flags = !{!0, !1}
128 !0 = !{i32 1, !"PIC Level", i32 1}
129 !1 = !{i32 1, !"PIE Level", i32 1}