1 ; Test that global ctors are emitted into the proper COFF section for the
2 ; target. Mingw uses .ctors, whereas MSVC uses .CRT$XC*.
3 ; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN32
4 ; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN32
5 ; RUN: llc < %s -mtriple i686-pc-mingw32 | FileCheck %s --check-prefix MINGW32
6 ; RUN: llc < %s -mtriple x86_64-pc-mingw32 | FileCheck %s --check-prefix MINGW32
8 @.str = private unnamed_addr constant [13 x i8] c"constructing\00", align 1
9 @.str2 = private unnamed_addr constant [12 x i8] c"destructing\00", align 1
10 @.str3 = private unnamed_addr constant [5 x i8] c"main\00", align 1
12 %ini = type { i32, void()*, i8* }
14 @llvm.global_ctors = appending global [2 x %ini ] [
15 %ini { i32 65535, void ()* @a_global_ctor, i8* null },
16 %ini { i32 65535, void ()* @b_global_ctor, i8* bitcast (i32* @b to i8*) }
18 @llvm.global_dtors = appending global [1 x %ini ] [%ini { i32 65535, void ()* @a_global_dtor, i8* null }]
20 declare i32 @puts(i8*)
22 define void @a_global_ctor() nounwind {
23 %1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0))
27 @b = global i32 zeroinitializer
29 define void @b_global_ctor() nounwind {
34 define void @a_global_dtor() nounwind {
35 %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str2, i32 0, i32 0))
39 define i32 @main() nounwind {
40 %1 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str3, i32 0, i32 0))
44 ; WIN32: .section .CRT$XCU,"rd"
45 ; WIN32: a_global_ctor
46 ; WIN32: .section .CRT$XCU,"rd",associative .bss,{{_?}}b
47 ; WIN32: b_global_ctor
48 ; WIN32: .section .CRT$XTX,"rd"
49 ; WIN32: a_global_dtor
50 ; MINGW32: .section .ctors,"wd"
51 ; MINGW32: a_global_ctor
52 ; MINGW32: .section .ctors,"wd",associative .bss,{{_?}}b
53 ; MINGW32: b_global_ctor
54 ; MINGW32: .section .dtors,"wd"
55 ; MINGW32: a_global_dtor