Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -march=arm -mtriple=arm-linux-gnueabi < %s \
      2 ; RUN:     | FileCheck -check-prefix=CHECK-NONPIC -check-prefix=COMMON %s
      3 ; RUN: llc -march=arm -mtriple=arm-linux-gnueabi -relocation-model=pic < %s \
      4 ; RUN:     | FileCheck -check-prefix=CHECK-PIC  -check-prefix=COMMON %s
      5 ; RUN: llc -emulated-tls -march=arm -mtriple=arm-linux-gnueabi < %s \
      6 ; RUN:     | FileCheck -check-prefix=EMUNONPIC -check-prefix=EMU -check-prefix=COMMON %s
      7 ; RUN: llc -emulated-tls -march=arm -mtriple=arm-linux-gnueabi -relocation-model=pic < %s \
      8 ; RUN:     | FileCheck -check-prefix=EMUPIC -check-prefix=EMU -check-prefix=COMMON %s
      9 
     10 
     11 @external_gd = external thread_local global i32
     12 @internal_gd = internal thread_local global i32 42
     13 
     14 @external_ld = external thread_local(localdynamic) global i32
     15 @internal_ld = internal thread_local(localdynamic) global i32 42
     16 
     17 @external_ie = external thread_local(initialexec) global i32
     18 @internal_ie = internal thread_local(initialexec) global i32 42
     19 
     20 @external_le = external thread_local(localexec) global i32
     21 @internal_le = internal thread_local(localexec) global i32 42
     22 
     23 ; ----- no model specified -----
     24 
     25 define i32* @f1() {
     26 entry:
     27   ret i32* @external_gd
     28 
     29   ; COMMON-LABEL:   f1:
     30   ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
     31   ; CHECK-NONPIC:   external_gd(GOTTPOFF)
     32   ; CHECK-PIC:      external_gd(TLSGD)
     33   ; EMU:            __emutls_get_address
     34 }
     35 
     36 define i32* @f2() {
     37 entry:
     38   ret i32* @internal_gd
     39 
     40   ; COMMON-LABEL:   f2:
     41   ; Non-PIC code can use local exec, PIC code can use local dynamic,
     42   ; but that is not implemented, so falls back to general dynamic.
     43   ; CHECK-NONPIC:   internal_gd(TPOFF)
     44   ; CHECK-PIC:      internal_gd(TLSGD)
     45   ; EMU:            __emutls_get_address
     46 }
     47 
     48 
     49 ; ----- localdynamic specified -----
     50 
     51 define i32* @f3() {
     52 entry:
     53   ret i32* @external_ld
     54 
     55   ; COMMON-LABEL:   f3:
     56   ; Non-PIC code can use initial exec, PIC should use local dynamic,
     57   ; but that is not implemented, so falls back to general dynamic.
     58   ; CHECK-NONPIC:   external_ld(GOTTPOFF)
     59   ; CHECK-PIC:      external_ld(TLSGD)
     60   ; EMU:            __emutls_get_address
     61 }
     62 
     63 define i32* @f4() {
     64 entry:
     65   ret i32* @internal_ld
     66 
     67   ; COMMON-LABEL:   f4:
     68   ; Non-PIC code can use local exec, PIC code can use local dynamic,
     69   ; but that is not implemented, so it falls back to general dynamic.
     70   ; CHECK-NONPIC:   internal_ld(TPOFF)
     71   ; CHECK-PIC:      internal_ld(TLSGD)
     72   ; EMU:            __emutls_get_address
     73 }
     74 
     75 
     76 ; ----- initialexec specified -----
     77 
     78 define i32* @f5() {
     79 entry:
     80   ret i32* @external_ie
     81 
     82   ; COMMON-LABEL:   f5:
     83   ; Non-PIC and PIC code will use initial exec as specified.
     84   ; CHECK-NONPIC:   external_ie(GOTTPOFF)
     85   ; CHECK-PIC:      external_ie(GOTTPOFF)
     86   ; EMU:            __emutls_get_address
     87 }
     88 
     89 define i32* @f6() {
     90 entry:
     91   ret i32* @internal_ie
     92 
     93   ; COMMON-LABEL:   f6:
     94   ; Non-PIC code can use local exec, PIC code use initial exec as specified.
     95   ; CHECK-NONPIC:   internal_ie(TPOFF)
     96   ; CHECK-PIC:      internal_ie(GOTTPOFF)
     97   ; EMU:            __emutls_get_address
     98 }
     99 
    100 
    101 ; ----- localexec specified -----
    102 
    103 define i32* @f7() {
    104 entry:
    105   ret i32* @external_le
    106 
    107   ; COMMON-LABEL:   f7:
    108   ; Non-PIC and PIC code will use local exec as specified.
    109   ; CHECK-NONPIC:   external_le(TPOFF)
    110   ; CHECK-PIC:      external_le(TPOFF)
    111   ; EMU:            __emutls_get_address
    112 }
    113 
    114 define i32* @f8() {
    115 entry:
    116   ret i32* @internal_le
    117 
    118   ; COMMON-LABEL:   f8:
    119   ; Non-PIC and PIC code will use local exec as specified.
    120   ; CHECK-NONPIC:   internal_le(TPOFF)
    121   ; CHECK-PIC:      internal_le(TPOFF)
    122   ; EMU:            __emutls_get_address
    123 }
    124 
    125 
    126 ; ----- emulated specified -----
    127 
    128 ; External declaration has no initializer.
    129 ; Internal definition has initializer.
    130 
    131 ; EMU-NOT:   __emutls_t.external_gd
    132 ; EMU-NOT:   __emutls_v.external_gd
    133 ; EMU:       .align 2
    134 ; EMU-LABEL: __emutls_v.internal_gd:
    135 ; EMU-NEXT:  .long 4
    136 ; EMU-NEXT:  .long 4
    137 ; EMU-NEXT:  .long 0
    138 ; EMU-NEXT:  .long __emutls_t.internal_gd
    139 ; EMU-LABEL: __emutls_t.internal_gd:
    140 ; EMU-NEXT:  .long 42
    141 ; EMU-NOT:   __emutls_t.external_gd
    142 
    143 ; __emutls_t and __emutls_v are the same for PIC and non-PIC modes.
    144 
    145 ; EMU-NOT:   __emutls_t.external_gd
    146 ; EMU-NOT:   __emutls_v.external_gd
    147 ; EMU:       .align 2
    148 ; EMU-LABEL: __emutls_v.internal_le:
    149 ; EMU-NEXT:  .long 4
    150 ; EMU-NEXT:  .long 4
    151 ; EMU-NEXT:  .long 0
    152 ; EMU-NEXT:  .long __emutls_t.internal_le
    153 ; EMU-LABEL: __emutls_t.internal_le:
    154 ; EMU-NEXT:  .long 42
    155 ; EMU-NOT:   __emutls_t.external_le
    156