2011-09-10 04:45:50 +08:00
|
|
|
; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=PIC
|
|
|
|
; RUN: llc -march=mipsel -relocation-model=static < %s \
|
2011-05-31 10:53:58 +08:00
|
|
|
; RUN: | FileCheck %s -check-prefix=STATIC
|
2012-02-25 06:34:47 +08:00
|
|
|
; RUN: llc -march=mipsel -relocation-model=static < %s \
|
|
|
|
; RUN: -mips-fix-global-base-reg=false | FileCheck %s -check-prefix=STATICGP
|
2011-05-31 10:53:58 +08:00
|
|
|
|
|
|
|
@t1 = thread_local global i32 0, align 4
|
|
|
|
|
|
|
|
define i32 @f1() nounwind {
|
|
|
|
entry:
|
|
|
|
%tmp = load i32* @t1, align 4
|
|
|
|
ret i32 %tmp
|
|
|
|
|
|
|
|
; CHECK: f1:
|
|
|
|
|
|
|
|
; PIC: lw $25, %call16(__tls_get_addr)($gp)
|
|
|
|
; PIC: addiu $4, $gp, %tlsgd(t1)
|
|
|
|
; PIC: jalr $25
|
|
|
|
; PIC: lw $2, 0($2)
|
|
|
|
|
|
|
|
; STATIC: rdhwr $3, $29
|
|
|
|
; STATIC: lui $[[R0:[0-9]+]], %tprel_hi(t1)
|
|
|
|
; STATIC: addiu $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1)
|
|
|
|
; STATIC: addu $[[R2:[0-9]+]], $3, $[[R1]]
|
|
|
|
; STATIC: lw $2, 0($[[R2]])
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@t2 = external thread_local global i32
|
|
|
|
|
|
|
|
define i32 @f2() nounwind {
|
|
|
|
entry:
|
|
|
|
%tmp = load i32* @t2, align 4
|
|
|
|
ret i32 %tmp
|
|
|
|
|
|
|
|
; CHECK: f2:
|
|
|
|
|
|
|
|
; PIC: lw $25, %call16(__tls_get_addr)($gp)
|
|
|
|
; PIC: addiu $4, $gp, %tlsgd(t2)
|
|
|
|
; PIC: jalr $25
|
|
|
|
; PIC: lw $2, 0($2)
|
|
|
|
|
2012-02-25 06:34:47 +08:00
|
|
|
; STATICGP: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp)
|
|
|
|
; STATICGP: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp)
|
|
|
|
; STATICGP: lw ${{[0-9]+}}, %gottprel(t2)($[[GP]])
|
|
|
|
; STATIC: lui $gp, %hi(__gnu_local_gp)
|
|
|
|
; STATIC: addiu $gp, $gp, %lo(__gnu_local_gp)
|
2011-05-31 10:53:58 +08:00
|
|
|
; STATIC: rdhwr $3, $29
|
|
|
|
; STATIC: lw $[[R0:[0-9]+]], %gottprel(t2)($gp)
|
|
|
|
; STATIC: addu $[[R1:[0-9]+]], $3, $[[R0]]
|
|
|
|
; STATIC: lw $2, 0($[[R1]])
|
|
|
|
}
|
2011-12-15 02:26:41 +08:00
|
|
|
|
|
|
|
@f3.i = internal thread_local unnamed_addr global i32 1, align 4
|
|
|
|
|
|
|
|
define i32 @f3() nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: f3:
|
|
|
|
|
|
|
|
; PIC: addiu $4, $gp, %tlsldm(f3.i)
|
|
|
|
; PIC: jalr $25
|
|
|
|
; PIC: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
|
|
|
|
; PIC: addu $[[R1:[0-9]+]], $[[R0]], $2
|
Remove the restriction on the first operand of the add node in SelectAddr.
This change reduces the number of instructions generated.
For example,
(load (add (sub $n0, $n1), (MipsLo got(s))))
results in the following sequence of instructions:
1. sub $n2, $n0, $n1
2. lw got(s)($n2)
Previously, three instructions were needed.
1. sub $n2, $n0, $n1
2. addiu $n3, $n2, got(s)
3. lw 0($n3)
llvm-svn: 146888
2011-12-20 03:28:37 +08:00
|
|
|
; PIC: lw ${{[0-9]+}}, %dtprel_lo(f3.i)($[[R1]])
|
2011-12-15 02:26:41 +08:00
|
|
|
|
|
|
|
%0 = load i32* @f3.i, align 4
|
|
|
|
%inc = add nsw i32 %0, 1
|
|
|
|
store i32 %inc, i32* @f3.i, align 4
|
|
|
|
ret i32 %inc
|
|
|
|
}
|
|
|
|
|