diff options
| author | Reid Kleckner <reid@kleckner.net> | 2013-08-22 20:07:45 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2013-08-22 20:07:45 +0000 |
| commit | 3738445cdd4da3452d04fc09a8f5191267f6f706 (patch) | |
| tree | e55ad44f1d0465c2bb34e9f182e0758fed1f3361 /clang/test | |
| parent | 9f7a1c10ea02747e765b417551efe24f82cef7e0 (diff) | |
| download | bcm5719-llvm-3738445cdd4da3452d04fc09a8f5191267f6f706.tar.gz bcm5719-llvm-3738445cdd4da3452d04fc09a8f5191267f6f706.zip | |
Add a separate llvm.global_ctors entry for linkonce_odr data initializers
Summary:
These typically come from static data members of class template
specializations. This accomplishes two things:
1. May expose GlobalOpt optimizations for Itanium C++ ABI code.
2. Works toward fixing double initialization in the Microsoft C++ ABI.
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1475
llvm-svn: 189051
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp | 7 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp | 25 |
2 files changed, 30 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp b/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp index 35e343bc4d3..56536b1a570 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s +// CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()* }] +// CHECK: [{ i32, void ()* } { i32 65535, void ()* [[INIT_foo:@.*global_var.*]] }, +// CHECK: { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] + struct S { S() {} ~S() {} @@ -33,7 +37,7 @@ void force_usage() { (void)B<int>::foo; // (void) - force usage } -// CHECK: define internal void [[INIT_foo:@.*global_var.*]] [[NUW]] +// CHECK: define internal void [[INIT_foo]]() [[NUW]] // CHECK: %{{[.0-9A-Z_a-z]+}} = call x86_thiscallcc %class.A* @"\01??0A@@QAE@XZ" // CHECK: call i32 @atexit(void ()* [[FOO_DTOR:@"__dtor_.*foo@.*]]) // CHECK: ret void @@ -48,7 +52,6 @@ void force_usage() { // CHECK: define internal void @_GLOBAL__I_a() [[NUW]] { // CHECK: call void [[INIT_s]] -// CHECK: call void [[INIT_foo]] // CHECK: ret void // CHECK: attributes [[NUW]] = { nounwind } diff --git a/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp b/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp index 94fd9aa12ce..e499efd2d03 100644 --- a/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp +++ b/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s // CHECK: ; ModuleID + template<typename> struct A { static int a; }; // CHECK-NOT: @_ZN1AIcE1aE @@ -8,4 +9,28 @@ template<> int A<char>::a; // CHECK: @_ZN1AIbE1aE = global i32 10 template<> int A<bool>::a = 10; +// CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()* }] +// CHECK: [{ i32, void ()* } { i32 65535, void ()* @__cxx_global_var_init }, +// CHECK: { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] + +extern "C" int foo(); +template<> int A<short>::a = foo(); // Separate global_ctor entry +int b = foo(); // Goes in _GLOBAL__I_a +int c = foo(); // Goes in _GLOBAL__I_a + +// An explicit specialization is ordered, and goes in __GLOBAL_I_a. +template<> struct A<int> { static int a; }; +int A<int>::a = foo(); + +// CHECK: define internal void @__cxx_global_var_init() +// CHECK: call i32 @foo() +// CHECK: store {{.*}} @_ZN1AIsE1aE +// CHECK: ret +// CHECK: define internal void @_GLOBAL__I_a() +// We call unique stubs for every ordered dynamic initializer in the TU. +// CHECK: call +// CHECK: call +// CHECK: call +// CHECK-NOT: call +// CHECK: ret |

