Displaying 2 results from an estimated 2 matches for "__tls_array".
2011 Dec 06
0
[LLVMdev] Implement implicit TLS on Windows - need advice
...sts.
As for the second patch, that's not how MSVC 2010 emits code (and it
needs tests).
thread_local.c:
#ifdef _MSC_VER
#define __thread __declspec(thread)
#endif
__thread int i = 0;
int foo() {
return i++;
}
thread_local.asm:
PUBLIC _i
_TLS SEGMENT
_i DD 00H
_TLS ENDS
PUBLIC _foo
EXTRN __tls_array:DWORD
EXTRN __tls_index:DWORD
; Function compile flags: /Ogtpy
_TEXT SEGMENT
_foo PROC
; File c:\users\mspencer\projects\llvm-project\test\thread_local.c
; Line 7
mov eax, DWORD PTR __tls_index
mov ecx, DWORD PTR fs:__tls_array
mov ecx, DWORD PTR [ecx+eax*4]
mov eax, DWORD PTR _i[ecx]
lea edx,...
2011 Dec 04
3
[LLVMdev] Implement implicit TLS on Windows - need advice
Hi!
LLVM currently does not implement the implicit TLS model on Windows.
This model is easy:
- a thread local variable ends up in the .tls section
- to access a thread local variable, you have to do
(1) load pointer to thread local storage from TEB
On x86_64, this is gs:0x58, on x86 it is fs:0x2C.
(2) load pointer to thread local state. In general, the index is
stored in variable