Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple x86_64-apple-darwin \
      2 ; RUN:     -relocation-model=static          < %s | FileCheck %s
      3 ; RUN: llc -mtriple x86_64-apple-darwin \
      4 ; RUN:     -relocation-model=pic             < %s | FileCheck %s
      5 ; RUN: llc -mtriple x86_64-apple-darwin \
      6 ; RUN:     -relocation-model=dynamic-no-pic  < %s | FileCheck %s
      7 
      8 ; 32 bits
      9 
     10 ; RUN: llc -mtriple i386-apple-darwin \
     11 ; RUN:    -relocation-model=static < %s | FileCheck --check-prefix=DARWIN32_S %s
     12 ; RUN: llc -mtriple i386-apple-darwin \
     13 ; RUN:     -relocation-model=pic     < %s | FileCheck --check-prefix=DARWIN32 %s
     14 ; RUN: llc -mtriple i386-apple-darwin \
     15 ; RUN:   -relocation-model=dynamic-no-pic < %s | \
     16 ; RUN:   FileCheck --check-prefix=DARWIN32_DNP %s
     17 
     18 ; globals
     19 
     20 @strong_default_global = global i32 42
     21 define i32* @get_strong_default_global() {
     22   ret i32* @strong_default_global
     23 }
     24 ; CHECK: leaq _strong_default_global(%rip), %rax
     25 ; DARWIN32: leal _strong_default_global-L{{.*}}$pb(%eax), %eax
     26 ; DARWIN32_S: movl $_strong_default_global, %eax
     27 ; DARWIN32_DNP: movl $_strong_default_global, %eax
     28 
     29 @weak_default_global = weak global i32 42
     30 define i32* @get_weak_default_global() {
     31   ret i32* @weak_default_global
     32 }
     33 ; CHECK: movq _weak_default_global@GOTPCREL(%rip), %rax
     34 ; DARWIN32: movl L_weak_default_global$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
     35 ; DARWIN32_S: movl $_weak_default_global, %eax
     36 ; DARWIN32_DNP: movl L_weak_default_global$non_lazy_ptr, %eax
     37 
     38 @external_default_global = external global i32
     39 define i32* @get_external_default_global() {
     40   ret i32* @external_default_global
     41 }
     42 ; CHECK: movq _external_default_global@GOTPCREL(%rip), %rax
     43 ; DARWIN32: movl L_external_default_global$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
     44 ; DARWIN32_S: movl $_external_default_global, %eax
     45 ; DARWIN32_DNP: movl L_external_default_global$non_lazy_ptr, %eax
     46 
     47 @strong_local_global = dso_local global i32 42
     48 define i32* @get_strong_local_global() {
     49   ret i32* @strong_local_global
     50 }
     51 ; CHECK: leaq _strong_local_global(%rip), %rax
     52 ; DARWIN32: leal _strong_local_global-L{{.*}}$pb(%eax), %eax
     53 ; DARWIN32_S: movl $_strong_local_global, %eax
     54 ; DARWIN32_DNP: movl $_strong_local_global, %eax
     55 
     56 @weak_local_global = weak dso_local global i32 42
     57 define i32* @get_weak_local_global() {
     58   ret i32* @weak_local_global
     59 }
     60 ; CHECK: leaq _weak_local_global(%rip), %rax
     61 ; DARWIN32: leal _weak_local_global-L{{.}}$pb(%eax), %eax
     62 ; DARWIN32_S: movl $_weak_local_global, %eax
     63 ; DARWIN32_DNP: movl $_weak_local_global, %eax
     64 
     65 @external_local_global = external dso_local global i32
     66 define i32* @get_external_local_global() {
     67   ret i32* @external_local_global
     68 }
     69 ; CHECK: leaq _external_local_global(%rip), %rax
     70 ; DARWIN32: movl L_external_local_global$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
     71 ; DARWIN32_S: movl $_external_local_global, %eax
     72 ; DARWIN32_DNP: movl $_external_local_global, %eax
     73 
     74 @strong_preemptable_global = dso_preemptable global i32 42
     75 define i32* @get_strong_preemptable_global() {
     76   ret i32* @strong_preemptable_global
     77 }
     78 ; CHECK: leaq _strong_preemptable_global(%rip), %rax
     79 ; DARWIN32: leal _strong_preemptable_global-L{{.*}}$pb(%eax), %eax
     80 ; DARWIN32_S: movl $_strong_preemptable_global, %eax
     81 ; DARWIN32_DNP: movl $_strong_preemptable_global, %eax
     82 
     83 @weak_preemptable_global = weak dso_preemptable global i32 42
     84 define i32* @get_weak_preemptable_global() {
     85   ret i32* @weak_preemptable_global
     86 }
     87 ; CHECK: movq _weak_preemptable_global@GOTPCREL(%rip), %rax
     88 ; DARWIN32: movl L_weak_preemptable_global$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
     89 ; DARWIN32_S: movl $_weak_preemptable_global, %eax
     90 ; DARWIN32_DNP: movl L_weak_preemptable_global$non_lazy_ptr, %eax
     91 
     92 @external_preemptable_global = external dso_preemptable global i32
     93 define i32* @get_external_preemptable_global() {
     94   ret i32* @external_preemptable_global
     95 }
     96 ; CHECK: movq _external_preemptable_global@GOTPCREL(%rip), %rax
     97 ; DARWIN32: movl L_external_preemptable_global$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
     98 ; DARWIN32_S: movl $_external_preemptable_global, %eax
     99 ; DARWIN32_DNP: movl L_external_preemptable_global$non_lazy_ptr, %eax
    100 
    101 ; aliases
    102 @aliasee = global i32 42
    103 
    104 @strong_default_alias = alias i32, i32* @aliasee
    105 define i32* @get_strong_default_alias() {
    106   ret i32* @strong_default_alias
    107 }
    108 ; CHECK: leaq _strong_default_alias(%rip), %rax
    109 ; DARWIN32: leal _strong_default_alias-L{{.*}}$pb(%eax), %eax
    110 ; DARWIN32_S: movl $_strong_default_alias, %eax
    111 ; DARWIN32_DNP: movl $_strong_default_alias, %eax
    112 
    113 @weak_default_alias = weak alias i32, i32* @aliasee
    114 define i32* @get_weak_default_alias() {
    115   ret i32* @weak_default_alias
    116 }
    117 ; CHECK: movq _weak_default_alias@GOTPCREL(%rip), %rax
    118 ; DARWIN32: movl L_weak_default_alias$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    119 ; DARWIN32_S: movl $_weak_default_alias, %eax
    120 ; DARWIN32_DNP: movl L_weak_default_alias$non_lazy_ptr, %eax
    121 
    122 @strong_local_alias = dso_local alias i32, i32* @aliasee
    123 define i32* @get_strong_local_alias() {
    124   ret i32* @strong_local_alias
    125 }
    126 ; CHECK: leaq _strong_local_alias(%rip), %rax
    127 ; DARWIN32: leal _strong_local_alias-L{{.*}}$pb(%eax), %eax
    128 ; DARWIN32_S: movl $_strong_local_alias, %eax
    129 ; DARWIN32_DNP: movl $_strong_local_alias, %eax
    130 
    131 @weak_local_alias = weak dso_local alias i32, i32* @aliasee
    132 define i32* @get_weak_local_alias() {
    133   ret i32* @weak_local_alias
    134 }
    135 ; CHECK: leaq _weak_local_alias(%rip), %rax
    136 ; DARWIN32: leal _weak_local_alias-L{{.*}}$pb(%eax), %eax
    137 ; DARWIN32_S: movl $_weak_local_alias, %eax
    138 ; DARWIN32_DNP: movl $_weak_local_alias, %eax
    139 
    140 @strong_preemptable_alias = dso_preemptable alias i32, i32* @aliasee
    141 define i32* @get_strong_preemptable_alias() {
    142   ret i32* @strong_preemptable_alias
    143 }
    144 ; CHECK: leaq _strong_preemptable_alias(%rip), %rax
    145 ; DARWIN32: leal _strong_preemptable_alias-L{{.*}}$pb(%eax), %eax
    146 ; DARWIN32_S: movl $_strong_preemptable_alias, %eax
    147 ; DARWIN32_DNP: movl $_strong_preemptable_alias, %eax
    148 
    149 @weak_preemptable_alias = weak dso_preemptable alias i32, i32* @aliasee
    150 define i32* @get_weak_preemptable_alias() {
    151   ret i32* @weak_preemptable_alias
    152 }
    153 ; CHECK: movq _weak_preemptable_alias@GOTPCREL(%rip), %rax
    154 ; DARWIN32: movl L_weak_preemptable_alias$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    155 ; DARWIN32_S: movl $_weak_preemptable_alias, %eax
    156 ; DARWIN32_DNP: movl L_weak_preemptable_alias$non_lazy_ptr, %eax
    157 
    158 ; functions
    159 
    160 define void @strong_default_function() {
    161   ret void
    162 }
    163 define void()* @get_strong_default_function() {
    164   ret void()* @strong_default_function
    165 }
    166 ; CHECK: leaq _strong_default_function(%rip), %rax
    167 ; DARWIN32: leal _strong_default_function-L{{.*}}$pb(%eax), %eax
    168 ; DARWIN32_S: movl $_strong_default_function, %eax
    169 ; DARWIN32_DNP: movl $_strong_default_function, %eax
    170 
    171 define weak void @weak_default_function() {
    172   ret void
    173 }
    174 define void()* @get_weak_default_function() {
    175   ret void()* @weak_default_function
    176 }
    177 ; CHECK: movq _weak_default_function@GOTPCREL(%rip), %rax
    178 ; DARWIN32: movl L_weak_default_function$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    179 ; DARWIN32_S: movl $_weak_default_function, %eax
    180 ; DARWIN32_DNP: movl L_weak_default_function$non_lazy_ptr, %eax
    181 
    182 declare void @external_default_function()
    183 define void()* @get_external_default_function() {
    184   ret void()* @external_default_function
    185 }
    186 ; CHECK: movq _external_default_function@GOTPCREL(%rip), %rax
    187 ; DARWIN32: movl L_external_default_function$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    188 ; DARWIN32_S: movl $_external_default_function, %eax
    189 ; DARWIN32_DNP: movl L_external_default_function$non_lazy_ptr, %eax
    190 
    191 define dso_local void @strong_local_function() {
    192   ret void
    193 }
    194 define void()* @get_strong_local_function() {
    195   ret void()* @strong_local_function
    196 }
    197 ; CHECK: leaq _strong_local_function(%rip), %rax
    198 ; DARWIN32: leal _strong_local_function-L{{.*}}$pb(%eax), %eax
    199 ; DARWIN32_S: movl $_strong_local_function, %eax
    200 ; DARWIN32_DNP: movl $_strong_local_function, %eax
    201 
    202 define weak dso_local void @weak_local_function() {
    203   ret void
    204 }
    205 define void()* @get_weak_local_function() {
    206   ret void()* @weak_local_function
    207 }
    208 ; CHECK: leaq _weak_local_function(%rip), %rax
    209 ; DARWIN32: leal _weak_local_function-L{{.*}}$pb(%eax), %eax
    210 ; DARWIN32_S: movl $_weak_local_function, %eax
    211 ; DARWIN32_DNP: movl $_weak_local_function, %eax
    212 
    213 declare dso_local void @external_local_function()
    214 define void()* @get_external_local_function() {
    215   ret void()* @external_local_function
    216 }
    217 ; CHECK: leaq _external_local_function(%rip), %rax
    218 ; DARWIN32: movl L_external_local_function$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    219 ; DARWIN32_S: movl $_external_local_function, %eax
    220 ; DARWIN32_DNP: movl $_external_local_function, %eax
    221 
    222 define dso_preemptable void @strong_preemptable_function() {
    223   ret void
    224 }
    225 define void()* @get_strong_preemptable_function() {
    226   ret void()* @strong_preemptable_function
    227 }
    228 ; CHECK: leaq _strong_preemptable_function(%rip), %rax
    229 ; DARWIN32: leal _strong_preemptable_function-L{{.*}}$pb(%eax), %eax
    230 ; DARWIN32_S: movl $_strong_preemptable_function, %eax
    231 ; DARWIN32_DNP: movl $_strong_preemptable_function, %eax
    232 
    233 define weak dso_preemptable void @weak_preemptable_function() {
    234   ret void
    235 }
    236 define void()* @get_weak_preemptable_function() {
    237   ret void()* @weak_preemptable_function
    238 }
    239 ; CHECK: movq _weak_preemptable_function@GOTPCREL(%rip), %rax
    240 ; DARWIN32: movl L_weak_preemptable_function$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    241 ; DARWIN32_S: movl $_weak_preemptable_function, %eax
    242 ; DARWIN32_DNP: movl L_weak_preemptable_function$non_lazy_ptr, %eax
    243 
    244 declare dso_preemptable void @external_preemptable_function()
    245 define void()* @get_external_preemptable_function() {
    246   ret void()* @external_preemptable_function
    247 }
    248 ; CHECK: movq _external_preemptable_function@GOTPCREL(%rip), %rax
    249 ; DARWIN32: movl L_external_preemptable_function$non_lazy_ptr-L{{.*}}$pb(%eax), %eax
    250 ; DARWIN32_S: movl $_external_preemptable_function, %eax
    251 ; DARWIN32_DNP: movl L_external_preemptable_function$non_lazy_ptr, %eax
    252