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