global-init.cpp revision 9df792c199473ac1bd012b8018373680ac00c309
1// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck %s
2
3struct A {
4  A();
5  ~A();
6};
7
8struct B { B(); ~B(); };
9
10struct C { void *field; };
11
12struct D { ~D(); };
13
14// CHECK: @c = global %struct.C zeroinitializer, align 8
15
16// CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
17// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
18A a;
19
20// CHECK: call void @_ZN1BC1Ev(%struct.A* @b)
21// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @b, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
22B b;
23
24// PR6205: this should not require a global initializer
25// CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
26C c;
27
28// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @d, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
29D d;
30
31// CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
32
33