1; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=PIC
2; RUN: llc -march=mipsel -relocation-model=static < %s \
3; RUN:                             | FileCheck %s -check-prefix=STATIC
4
5
6@t1 = thread_local global i32 0, align 4
7
8define i32 @f1() nounwind {
9entry:
10  %tmp = load i32* @t1, align 4
11  ret i32 %tmp
12
13; CHECK: f1:
14
15; PIC:   lw      $25, %call16(__tls_get_addr)($gp)
16; PIC:   addiu   $4, $gp, %tlsgd(t1)
17; PIC:   jalr    $25
18; PIC:   lw      $2, 0($2)
19
20; STATIC:   rdhwr   $3, $29
21; STATIC:   lui     $[[R0:[0-9]+]], %tprel_hi(t1)
22; STATIC:   addiu   $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1)
23; STATIC:   addu    $[[R2:[0-9]+]], $3, $[[R1]]
24; STATIC:   lw      $2, 0($[[R2]])
25}
26
27
28@t2 = external thread_local global i32
29
30define i32 @f2() nounwind {
31entry:
32  %tmp = load i32* @t2, align 4
33  ret i32 %tmp
34
35; CHECK: f2:
36
37; PIC:   lw      $25, %call16(__tls_get_addr)($gp)
38; PIC:   addiu   $4, $gp, %tlsgd(t2)
39; PIC:   jalr    $25
40; PIC:   lw      $2, 0($2)
41
42; STATIC:   rdhwr   $3, $29
43; STATIC:   lw      $[[R0:[0-9]+]], %gottprel(t2)($gp)
44; STATIC:   addu    $[[R1:[0-9]+]], $3, $[[R0]]
45; STATIC:   lw      $2, 0($[[R1]])
46}
47