1; Test that weak functions and globals are placed into selectany COMDAT
2; sections with the mangled name as suffix. Ensure that the weak linkage
3; type is not ignored by the backend if the section was specialized.
4;
5; RUN: llc -mtriple=i686-pc-win32 %s     -o - | FileCheck %s --check-prefix=X86
6; RUN: llc -mtriple=i686-pc-mingw32 %s   -o - | FileCheck %s --check-prefix=X86
7; RUN: llc -mtriple=x86_64-pc-win32 %s   -o - | FileCheck %s --check-prefix=X64
8; RUN: llc -mtriple=x86_64-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X64
9
10; Mangled function
11; X86: .section .text,"xr",discard,__Z3foo
12; X86: .globl __Z3foo
13;
14; X64: .section .text,"xr",discard,_Z3foo
15; X64: .globl _Z3foo
16define weak void @_Z3foo() {
17  ret void
18}
19
20; Unmangled function
21; X86: .section .sect,"xr",discard,_f
22; X86: .globl _f
23;
24; X64: .section .sect,"xr",discard,f
25; X64: .globl f
26define weak void @f() section ".sect" {
27  ret void
28}
29
30; Weak global
31; X86: .section .data,"rd",discard,_a
32; X86: .globl _a
33; X86: .zero 12
34;
35; X64: .section .data,"rd",discard,a
36; X64: .globl a
37; X64: .zero 12
38@a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data"
39
40; X86:  .section        .tls$,"wd",discard,_b
41; X86:  .globl  _b
42; X86:  .long   0
43;
44; X64:  .section        .tls$,"wd",discard,b
45; X64:  .globl  b
46; X64:  .long   0
47
48@b = weak_odr thread_local global i32 0, align 4
49