66 lines · plain
1; Test that global ctors are emitted into the proper COFF section for the2; target. Mingw uses .ctors, whereas MSVC uses .CRT$XC*.3; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN324; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN325; RUN: llc < %s -mtriple i686-pc-mingw32 | FileCheck %s --check-prefix MINGW326; RUN: llc < %s -mtriple x86_64-pc-mingw32 | FileCheck %s --check-prefix MINGW327 8@.str = private unnamed_addr constant [13 x i8] c"constructing\00", align 19@.str2 = private unnamed_addr constant [12 x i8] c"destructing\00", align 110@.str3 = private unnamed_addr constant [5 x i8] c"main\00", align 111 12%ini = type { i32, ptr, ptr }13 14@llvm.global_ctors = appending global [3 x %ini ] [15 %ini { i32 65535, ptr @a_global_ctor, ptr null },16 %ini { i32 65535, ptr @b_global_ctor, ptr @b },17 %ini { i32 65535, ptr @c_global_ctor, ptr @c }18]19@llvm.global_dtors = appending global [1 x %ini ] [%ini { i32 65535, ptr @a_global_dtor, ptr null }]20 21declare i32 @puts(ptr)22 23define void @a_global_ctor() nounwind {24 %1 = call i32 @puts(ptr @.str)25 ret void26}27 28@b = global i32 zeroinitializer29 30@c = available_externally dllimport global i32 zeroinitializer31 32define void @b_global_ctor() nounwind {33 store i32 42, ptr @b34 ret void35}36 37define void @c_global_ctor() nounwind {38 store i32 42, ptr @c39 ret void40}41 42define void @a_global_dtor() nounwind {43 %1 = call i32 @puts(ptr @.str2)44 ret void45}46 47define i32 @main() nounwind {48 %1 = call i32 @puts(ptr @.str3)49 ret i32 050}51 52; WIN32: .section .CRT$XCU,"dr"53; WIN32: a_global_ctor54; WIN32: .section .CRT$XCU,"dr",associative,{{_?}}b,unique,055; WIN32: b_global_ctor56; WIN32-NOT: c_global_ctor57; WIN32: .section .CRT$XTX,"dr"58; WIN32: a_global_dtor59; MINGW32: .section .ctors,"dw"60; MINGW32: a_global_ctor61; MINGW32: .section .ctors,"dw",associative,{{_?}}b,unique,062; MINGW32: b_global_ctor63; MINGW32-NOT: c_global_ctor64; MINGW32: .section .dtors,"dw"65; MINGW32: a_global_dtor66