Fix for PR5967: Make const-marking for LLVM globals correct for cases requiring
run-time initialization, and emit run-time initializers aggresively to avoid
ordering issues with deferred globals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92976 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/attr.cpp b/test/CodeGenCXX/attr.cpp
index 8fd8641..1b214b7 100644
--- a/test/CodeGenCXX/attr.cpp
+++ b/test/CodeGenCXX/attr.cpp
@@ -15,6 +15,9 @@
virtual void bar3() __attribute__((aligned(1024)));
} c;
+// CHECK:.align 1, 0x90
+// CHECK-NEXT:.globl __ZN1CC1Ev
+
void C::bar1() { }
// CHECK:.align 1, 0x90
diff --git a/test/CodeGenCXX/default-destructor-synthesis.cpp b/test/CodeGenCXX/default-destructor-synthesis.cpp
index 098458d..71167a2 100644
--- a/test/CodeGenCXX/default-destructor-synthesis.cpp
+++ b/test/CodeGenCXX/default-destructor-synthesis.cpp
@@ -45,15 +45,14 @@
int main() {M m1;}
-// CHECK-LP64: callq __ZN1MC1Ev
-// CHECK-LP64: callq __ZN1MD1Ev
// CHECK-LP64: .globl __ZN1MD1Ev
// CHECK-LP64-NEXT: .weak_definition __ZN1MD1Ev
// CHECK-LP64-NEXT: __ZN1MD1Ev:
+// CHECK-LP64: callq __ZN1MC1Ev
+// CHECK-LP64: callq __ZN1MD1Ev
-
-// CHECK-LP32: call L__ZN1MC1Ev
-// CHECK-LP32: call L__ZN1MD1Ev
// CHECK-LP32: .globl __ZN1MD1Ev
// CHECK-LP32-NEXT: .weak_definition __ZN1MD1Ev
// CHECK-LP32-NEXT:__ZN1MD1Ev:
+// CHECK-LP32: call L__ZN1MC1Ev
+// CHECK-LP32: call L__ZN1MD1Ev
diff --git a/test/CodeGenCXX/deferred-global-init.cpp b/test/CodeGenCXX/deferred-global-init.cpp
new file mode 100644
index 0000000..5701479
--- /dev/null
+++ b/test/CodeGenCXX/deferred-global-init.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR5967
+
+extern void* foo;
+static void* const a = foo;
+void* bar() { return a; }
+
+// CHECK: @a = internal global i8* null
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: load i8** @foo
+// CHECK: ret void
+
+// CHECK: define internal void @__cxx_global_initialization
+// CHECK: call void @__cxx_global_var_init()
+// CHECK: ret void
diff --git a/test/CodeGenCXX/vtable-linkage.cpp b/test/CodeGenCXX/vtable-linkage.cpp
index 733a9f0..63e1743 100644
--- a/test/CodeGenCXX/vtable-linkage.cpp
+++ b/test/CodeGenCXX/vtable-linkage.cpp
@@ -121,12 +121,6 @@
// CHECK: @_ZTI1EIlE = weak_odr constant
// CHECK: @_ZTV1EIlE = weak_odr constant
-// The anonymous struct for e has no linkage, so the vtable should have
-// internal linkage.
-// CHECK: @"_ZTS3$_0" = internal constant
-// CHECK: @"_ZTI3$_0" = internal constant
-// CHECK: @"_ZTV3$_0" = internal constant
-
// F<long> is an implicit template instantiation with no key function,
// so its vtable should have weak_odr linkage.
// CHECK: @_ZTS1FIlE = weak_odr constant
@@ -144,6 +138,12 @@
// its vtable, not define it.
// CHECK: @_ZTV1EIiE = external constant
+// The anonymous struct for e has no linkage, so the vtable should have
+// internal linkage.
+// CHECK: @"_ZTS3$_0" = internal constant
+// CHECK: @"_ZTI3$_0" = internal constant
+// CHECK: @"_ZTV3$_0" = internal constant
+
// The A vtable should have internal linkage since it is inside an anonymous
// namespace.
// CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant