llvm-6502/test/MC/COFF/weak-symbol.ll
Rafael Espindola 0de6255877 Use the same tls section name as msvc.
We currently error in clang with:
"error: thread-local storage is unsupported for the current target", but we
can start to get the llvm level ready.

When compiling

template<typename T>
struct foo {
  static __declspec(thread) int bar;
};
template<typename T>
__declspec(therad) int foo<T>::bar;
template struct foo<int>;

msvc produces

SECTION HEADER #3
   .tls$ name
       0 physical address
       0 virtual address
       4 size of raw data
     12F file pointer to raw data (0000012F to 00000132)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0301040 flags
         Initialized Data
         COMDAT; sym= "public: static int foo<int>::bar" (?bar@?$foo@H@@2HA)
         4 byte align
         Read Write

gcc produces a ".data$__emutls_v.<symbol>" for the testcase with
__declspec(thread) replaced with thread_local.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195849 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27 15:52:11 +00:00

49 lines
1.4 KiB
LLVM

; Test that weak functions and globals are placed into selectany COMDAT
; sections with the mangled name as suffix. Ensure that the weak linkage
; type is not ignored by the backend if the section was specialized.
;
; RUN: llc -mtriple=i686-pc-win32 %s -o - | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=i686-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=x86_64-pc-win32 %s -o - | FileCheck %s --check-prefix=X64
; RUN: llc -mtriple=x86_64-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X64
; Mangled function
; X86: .section .text,"xr",discard,__Z3foo
; X86: .globl __Z3foo
;
; X64: .section .text,"xr",discard,_Z3foo
; X64: .globl _Z3foo
define weak void @_Z3foo() {
ret void
}
; Unmangled function
; X86: .section .sect,"xr",discard,_f
; X86: .globl _f
;
; X64: .section .sect,"xr",discard,f
; X64: .globl f
define weak void @f() section ".sect" {
ret void
}
; Weak global
; X86: .section .data,"r",discard,_a
; X86: .globl _a
; X86: .zero 12
;
; X64: .section .data,"r",discard,a
; X64: .globl a
; X64: .zero 12
@a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data"
; X86: .section .tls$,"w",discard,_b
; X86: .globl _b
; X86: .long 0
;
; X64: .section .tls$,"w",discard,b
; X64: .globl b
; X64: .long 0
@b = weak_odr thread_local global i32 0, align 4