From 5b41e92e1e63a49e451c201e09e38ffed031747c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 11 Apr 2019 21:26:34 +0000 Subject: [PATCH] Revert r357610, it caused PR41471 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358232 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDeclCXX.cpp | 6 -- .../microsoft-abi-template-static-init.cpp | 57 ------------------- 2 files changed, 63 deletions(-) delete mode 100644 test/CodeGenCXX/microsoft-abi-template-static-init.cpp diff --git a/lib/CodeGen/CGDeclCXX.cpp b/lib/CodeGen/CGDeclCXX.cpp index d6fd7f2628..cd3301bd6c 100644 --- a/lib/CodeGen/CGDeclCXX.cpp +++ b/lib/CodeGen/CGDeclCXX.cpp @@ -481,12 +481,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, // minor startup time optimization. In the MS C++ ABI, there are no guard // variables, so this COMDAT key is required for correctness. AddGlobalCtor(Fn, 65535, COMDATKey); - if (getTarget().getCXXABI().isMicrosoft()) { - // In The MS C++, MS add template static data member in the linker - // drective. - assert(COMDATKey); - addUsedGlobal(COMDATKey); - } } else if (D->hasAttr()) { // SelectAny globals will be comdat-folded. Put the initializer into a // COMDAT group associated with the global, so the initializers get folded diff --git a/test/CodeGenCXX/microsoft-abi-template-static-init.cpp b/test/CodeGenCXX/microsoft-abi-template-static-init.cpp deleted file mode 100644 index 0bceaf0dec..0000000000 --- a/test/CodeGenCXX/microsoft-abi-template-static-init.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s - -struct S { - S(); - ~S(); -}; - -template struct __declspec(dllexport) ExportedTemplate { - static S s; -}; -template S ExportedTemplate::s; -void useExportedTemplate(ExportedTemplate x) { - (void)x.s; -} -int f(); -namespace selectany_init { -// MS don't put selectany static var in the linker directive, init routine -// f() is not getting called if x is not referenced. -int __declspec(selectany) x = f(); -} - -namespace explicit_template_instantiation { -template struct A { static int x; }; -template int A::x = f(); -template struct A; -} - -namespace implicit_template_instantiation { -template struct A { static int x; }; -template int A::x = f(); -int g() { return A::x; } -} - - -template -struct X_ { - static T ioo; - static T init(); -}; -template T X_::ioo = X_::init(); -template struct X_; - -template -struct X { - static T ioo; - static T init(); -}; -// template specialized static data don't need in llvm.used, -// the static init routine get call from _GLOBAL__sub_I_ routines. -template <> int X::ioo = X::init(); -template struct X; -// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* @"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* @"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* @"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* @"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8* getelementptr inbounds (%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) }, { i32, void ()*, i8* } { i32 65535, void ()* @"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* @"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }] -// CHECK: @llvm.used = appending global [4 x i8*] [i8* bitcast (i32* @"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* @"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* @"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section "llvm.metadata" - -- 2.40.0