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