mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 21:41:43 +00:00

The 'common' section TLS is not implemented. Current C/C++ TLS variables are not placed in common section. DWARF debug info to get the address of TLS variables is not generated yet. clang and driver changes in http://reviews.llvm.org/D10524 Added -femulated-tls flag to select the emulated TLS model, which will be used for old targets like Android that do not support ELF TLS models. Added TargetLowering::LowerToTLSEmulatedModel as a target-independent function to convert a SDNode of TLS variable address to a function call to __emutls_get_address. Added into lib/Target/*/*ISelLowering.cpp to call LowerToTLSEmulatedModel for TLSModel::Emulated. Although all targets supporting ELF TLS models are enhanced, emulated TLS model has been tested only for Android ELF targets. Modified AsmPrinter.cpp to print the emutls_v.* and emutls_t.* variables for emulated TLS variables. Modified DwarfCompileUnit.cpp to skip some DIE for emulated TLS variabls. TODO: Add proper DIE for emulated TLS variables. Added new unit tests with emulated TLS. Differential Revision: http://reviews.llvm.org/D10522 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243438 91177308-0d34-0410-b5e6-96231b3b80d8
49 lines
1.3 KiB
LLVM
49 lines
1.3 KiB
LLVM
; RUN: llc < %s -emulated-tls -march=x86 -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel | FileCheck %s
|
|
; PR3654
|
|
|
|
@v = thread_local global i32 0
|
|
define i32 @f() nounwind {
|
|
entry:
|
|
%t = load i32, i32* @v
|
|
%s = add i32 %t, 1
|
|
ret i32 %s
|
|
}
|
|
|
|
; CHECK-LABEL: f:
|
|
; CHECK: movl __emutls_v.v@GOT(%ebx), %eax
|
|
; CHECK-NEXT: movl %eax, (%esp)
|
|
; CHECK-NEXT: calll __emutls_get_address@PLT
|
|
; CHECK-NEXT: movl (%eax), %eax
|
|
|
|
@alias = internal alias i32* @v
|
|
define i32 @f_alias() nounwind {
|
|
entry:
|
|
%t = load i32, i32* @v
|
|
%s = add i32 %t, 1
|
|
ret i32 %s
|
|
}
|
|
|
|
; CHECK-LABEL: f_alias:
|
|
; CHECK: movl __emutls_v.v@GOT(%ebx), %eax
|
|
; CHECK-NEXT: movl %eax, (%esp)
|
|
; CHECK-NEXT: calll __emutls_get_address@PLT
|
|
; CHECK-NEXT: movl (%eax), %eax
|
|
|
|
; Use my_emutls_get_address like __emutls_get_address.
|
|
@my_emutls_v_xyz = external global i8*, align 4
|
|
declare i8* @my_emutls_get_address(i8*)
|
|
|
|
define i32 @my_get_xyz() {
|
|
entry:
|
|
%call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
|
|
%0 = bitcast i8* %call to i32*
|
|
%1 = load i32, i32* %0, align 4
|
|
ret i32 %1
|
|
}
|
|
|
|
; CHECK-LABEL: my_get_xyz:
|
|
; CHECK: movl my_emutls_v_xyz@GOT(%ebx), %eax
|
|
; CHECK-NEXT: movl %eax, (%esp)
|
|
; CHECK-NEXT: calll my_emutls_get_address@PLT
|
|
; CHECK-NEXT: movl (%eax), %eax
|