Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s
      2 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64_PIC %s
      3 ; RUN: llc < %s -march=x86 -mtriple=i386-linux-gnu | FileCheck -check-prefix=X32 %s
      4 ; RUN: llc < %s -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X32_PIC %s
      5 
      6 ; Darwin always uses the same model.
      7 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN %s
      8 
      9 @external_gd = external thread_local global i32
     10 @internal_gd = internal thread_local global i32 42
     11 
     12 @external_ld = external thread_local(localdynamic) global i32
     13 @internal_ld = internal thread_local(localdynamic) global i32 42
     14 
     15 @external_ie = external thread_local(initialexec) global i32
     16 @internal_ie = internal thread_local(initialexec) global i32 42
     17 
     18 @external_le = external thread_local(localexec) global i32
     19 @internal_le = internal thread_local(localexec) global i32 42
     20 
     21 ; See test cases for emulated model in emutls.ll, emutls-pic.ll and emutls-pie.ll.
     22 
     23 ; ----- no model specified -----
     24 
     25 define i32* @f1() {
     26 entry:
     27   ret i32* @external_gd
     28 
     29   ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
     30   ; X64-LABEL:     f1:
     31   ; X64:     external_gd@GOTTPOFF
     32   ; X32-LABEL:     f1:
     33   ; X32:     external_gd@INDNTPOFF
     34   ; X64_PIC-LABEL: f1:
     35   ; X64_PIC: external_gd@TLSGD
     36   ; X32_PIC-LABEL: f1:
     37   ; X32_PIC: external_gd@TLSGD
     38   ; DARWIN-LABEL:  f1:
     39   ; DARWIN:  _external_gd@TLVP
     40 }
     41 
     42 define i32* @f2() {
     43 entry:
     44   ret i32* @internal_gd
     45 
     46   ; Non-PIC code can use local exec, PIC code can use local dynamic.
     47   ; X64-LABEL:     f2:
     48   ; X64:     internal_gd@TPOFF
     49   ; X32-LABEL:     f2:
     50   ; X32:     internal_gd@NTPOFF
     51   ; X64_PIC-LABEL: f2:
     52   ; X64_PIC: internal_gd@TLSLD
     53   ; X32_PIC-LABEL: f2:
     54   ; X32_PIC: internal_gd@TLSLDM
     55   ; DARWIN-LABEL:  f2:
     56   ; DARWIN:  _internal_gd@TLVP
     57 }
     58 
     59 
     60 ; ----- localdynamic specified -----
     61 
     62 define i32* @f3() {
     63 entry:
     64   ret i32* @external_ld
     65 
     66   ; Non-PIC code can use initial exec, PIC code use local dynamic as specified.
     67   ; X64-LABEL:     f3:
     68   ; X64:     external_ld@GOTTPOFF
     69   ; X32-LABEL:     f3:
     70   ; X32:     external_ld@INDNTPOFF
     71   ; X64_PIC-LABEL: f3:
     72   ; X64_PIC: external_ld@TLSLD
     73   ; X32_PIC-LABEL: f3:
     74   ; X32_PIC: external_ld@TLSLDM
     75   ; DARWIN-LABEL:  f3:
     76   ; DARWIN:  _external_ld@TLVP
     77 }
     78 
     79 define i32* @f4() {
     80 entry:
     81   ret i32* @internal_ld
     82 
     83   ; Non-PIC code can use local exec, PIC code can use local dynamic.
     84   ; X64-LABEL:     f4:
     85   ; X64:     internal_ld@TPOFF
     86   ; X32-LABEL:     f4:
     87   ; X32:     internal_ld@NTPOFF
     88   ; X64_PIC-LABEL: f4:
     89   ; X64_PIC: internal_ld@TLSLD
     90   ; X32_PIC-LABEL: f4:
     91   ; X32_PIC: internal_ld@TLSLDM
     92   ; DARWIN-LABEL:  f4:
     93   ; DARWIN:  _internal_ld@TLVP
     94 }
     95 
     96 
     97 ; ----- initialexec specified -----
     98 
     99 define i32* @f5() {
    100 entry:
    101   ret i32* @external_ie
    102 
    103   ; Non-PIC and PIC code will use initial exec as specified.
    104   ; X64-LABEL:     f5:
    105   ; X64:     external_ie@GOTTPOFF
    106   ; X32-LABEL:     f5:
    107   ; X32:     external_ie@INDNTPOFF
    108   ; X64_PIC-LABEL: f5:
    109   ; X64_PIC: external_ie@GOTTPOFF
    110   ; X32_PIC-LABEL: f5:
    111   ; X32_PIC: external_ie@GOTNTPOFF
    112   ; DARWIN-LABEL:  f5:
    113   ; DARWIN:  _external_ie@TLVP
    114 }
    115 
    116 define i32* @f6() {
    117 entry:
    118   ret i32* @internal_ie
    119 
    120   ; Non-PIC code can use local exec, PIC code use initial exec as specified.
    121   ; X64-LABEL:     f6:
    122   ; X64:     internal_ie@TPOFF
    123   ; X32-LABEL:     f6:
    124   ; X32:     internal_ie@NTPOFF
    125   ; X64_PIC-LABEL: f6:
    126   ; X64_PIC: internal_ie@GOTTPOFF
    127   ; X32_PIC-LABEL: f6:
    128   ; X32_PIC: internal_ie@GOTNTPOFF
    129   ; DARWIN-LABEL:  f6:
    130   ; DARWIN:  _internal_ie@TLVP
    131 }
    132 
    133 define i32 @PR22083() {
    134 entry:
    135   ret i32 ptrtoint (i32* @external_ie to i32)
    136   ; X64-LABEL:     PR22083:
    137   ; X64:     movq    external_ie@GOTTPOFF(%rip), %rax
    138   ; X64_PIC-LABEL: PR22083:
    139   ; X64_PIC: movq    external_ie@GOTTPOFF(%rip), %rax
    140 }
    141 
    142 ; ----- localexec specified -----
    143 
    144 define i32* @f7() {
    145 entry:
    146   ret i32* @external_le
    147 
    148   ; Non-PIC and PIC code will use local exec as specified.
    149   ; X64-LABEL:     f7:
    150   ; X64:     external_le@TPOFF
    151   ; X32-LABEL:     f7:
    152   ; X32:     external_le@NTPOFF
    153   ; X64_PIC-LABEL: f7:
    154   ; X64_PIC: external_le@TPOFF
    155   ; X32_PIC-LABEL: f7:
    156   ; X32_PIC: external_le@NTPOFF
    157   ; DARWIN-LABEL:  f7:
    158   ; DARWIN:  _external_le@TLVP
    159 }
    160 
    161 define i32* @f8() {
    162 entry:
    163   ret i32* @internal_le
    164 
    165   ; Non-PIC and PIC code will use local exec as specified.
    166   ; X64-LABEL:     f8:
    167   ; X64:     internal_le@TPOFF
    168   ; X32-LABEL:     f8:
    169   ; X32:     internal_le@NTPOFF
    170   ; X64_PIC-LABEL: f8:
    171   ; X64_PIC: internal_le@TPOFF
    172   ; X32_PIC-LABEL: f8:
    173   ; X32_PIC: internal_le@NTPOFF
    174   ; DARWIN-LABEL:  f8:
    175   ; DARWIN:  _internal_le@TLVP
    176 }
    177