1 ; RUN: llc < %s -mtriple=x86_64-unknown-freebsd9 | FileCheck %s 2 3 ; Check that our compiler never emits global constructors 4 ; inside the .init_array section when building for a non-Linux ELF target. 5 ; Because of this, the test depends on UseInitArray behavior under FreeBSD 6 ; as found in Generic_ELF::addClangTargetOptions(). 7 8 ; This is to workaround a Visual Studio bug which causes field 9 ; UseInitArray to be left uninitialized instead of being 10 ; zero-initialized (as specified in [dcl.init]p7). 11 ; This workaround consists in providing a user default constructor 12 ; that explicitly initializes field UseInitArray. 13 14 %class.C = type { i8 } 15 %class.D = type { i8 } 16 17 @c1 = global %class.C zeroinitializer, align 1 18 @d1 = global %class.D zeroinitializer, align 1 19 @llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 101, void ()* @_GLOBAL__I_000101 }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] 20 21 define linkonce_odr void @_ZN1CC1Ev(%class.C* nocapture %this) { 22 entry: 23 ret void 24 } 25 26 define linkonce_odr void @_ZN1DC1Ev(%class.D* nocapture %this) { 27 entry: 28 ret void 29 } 30 31 define linkonce_odr void @_ZN1DC2Ev(%class.D* nocapture %this) { 32 entry: 33 ret void 34 } 35 36 define linkonce_odr void @_ZN1CC2Ev(%class.C* nocapture %this) { 37 entry: 38 ret void 39 } 40 41 define internal void @_GLOBAL__I_000101() nounwind readnone { 42 entry: 43 ret void 44 } 45 46 define internal void @_GLOBAL__I_a() nounwind readnone { 47 entry: 48 ret void 49 } 50 51 ; CHECK-NOT: .init_array 52