Fix the bug that was breaking self-host, and re-land the static ctor fixes.

llvm-svn: 95400
diff --git a/clang/test/CodeGenCXX/global-init.cpp b/clang/test/CodeGenCXX/global-init.cpp
index fd8c159..b60e056 100644
--- a/clang/test/CodeGenCXX/global-init.cpp
+++ b/clang/test/CodeGenCXX/global-init.cpp
@@ -9,6 +9,8 @@
 
 struct C { void *field; };
 
+struct D { ~D(); };
+
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
@@ -23,4 +25,7 @@
 // CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
 C c;
 
+// 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*))
+D d;
+
 // CHECK: define internal void @__cxx_global_initialization() {