Use atexit when __cxa_atexit isn't available instead of adding a
global destructor entry.  For some reason this isn't enabled for
apple-kexts;  it'd be good to have documentation for that.

Based on a patch by Nakamura Takumi!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154191 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp
index 36c6c1c..6c60f30 100644
--- a/test/CodeGenCXX/arm.cpp
+++ b/test/CodeGenCXX/arm.cpp
@@ -20,9 +20,17 @@
 
 // The global dtor needs the right calling conv with -fno-use-cxa-atexit
 // rdar://7817590
-// Checked at end of file.
 bar baz;
 
+// PR9593
+// Make sure atexit(3) is used for global dtors.
+
+// CHECK:      call [[BAR:%.*]]* @_ZN3barC1Ev(
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_baz)
+
+// CHECK: define internal void @__dtor_baz()
+// CHECK: call [[BAR]]* @_ZN3barD1Ev([[BAR]]* @baz)
+
 // Destructors and constructors must return this.
 namespace test1 {
   void foo();
@@ -357,5 +365,5 @@
   // CHECK:   call void @_ZN5test21CD0Ev(
   // CHECK:   ret void
 
-// CHECK: @_GLOBAL__D_a()
-// CHECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)
+// CH_ECK: @_GLOBAL__D_a()
+// CH_ECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)