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 [3 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*) },
17 %ini { i32 65535, void ()* @c_global_ctor, i8* bitcast (i32* @c to i8*) }
19 @llvm.global_dtors = appending global [1 x %ini ] [%ini { i32 65535, void ()* @a_global_dtor, i8* null }]
21 declare i32 @puts(i8*)
23 define void @a_global_ctor() nounwind {
24 %1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))
28 @b = global i32 zeroinitializer
30 @c = available_externally dllimport global i32 zeroinitializer
32 define void @b_global_ctor() nounwind {
37 define void @c_global_ctor() nounwind {
42 define void @a_global_dtor() nounwind {
43 %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str2, i32 0, i32 0))
47 define i32 @main() nounwind {
48 %1 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str3, i32 0, i32 0))
52 ; WIN32: .section .CRT$XCU,"dr"
53 ; WIN32: a_global_ctor
54 ; WIN32: .section .CRT$XCU,"dr",associative,{{_?}}b
55 ; WIN32: b_global_ctor
56 ; WIN32-NOT: c_global_ctor
57 ; WIN32: .section .CRT$XTX,"dr"
58 ; WIN32: a_global_dtor
59 ; MINGW32: .section .ctors,"dw"
60 ; MINGW32: a_global_ctor
61 ; MINGW32: .section .ctors,"dw",associative,{{_?}}b
62 ; MINGW32: b_global_ctor
63 ; MINGW32-NOT: c_global_ctor
64 ; MINGW32: .section .dtors,"dw"
65 ; MINGW32: a_global_dtor