r321298 - Revert "Fix for PR32990"
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 21 11:44:23 PST 2017
Author: rnk
Date: Thu Dec 21 11:44:23 2017
New Revision: 321298
URL: http://llvm.org/viewvc/llvm-project?rev=321298&view=rev
Log:
Revert "Fix for PR32990"
This reverts commit r321239. It broke the Chromium DLL build:
[8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb
FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb
zrule.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase destructor'(void)"
(__imp_??_DUnicodeString at icu_60@@QEAAXXZ)
Removed:
cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp
cfe/trunk/test/CodeGenCXX/external-linkage.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
cfe/trunk/test/CodeGenCXX/dllimport-members.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=321298&r1=321297&r2=321298&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 21 11:44:23 2017
@@ -856,25 +856,14 @@ CodeGenModule::getFunctionLinkage(Global
GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
if (isa<CXXDestructorDecl>(D) &&
- Context.getTargetInfo().getCXXABI().isMicrosoft()) {
- switch (GD.getDtorType()) {
- case CXXDtorType::Dtor_Base:
- break;
- case CXXDtorType::Dtor_Comdat:
- case CXXDtorType::Dtor_Complete:
- if (D->hasAttr<DLLImportAttr>() &&
- (cast<CXXDestructorDecl>(D)->getParent()->getNumVBases() ||
- (Linkage == GVA_AvailableExternally ||
- Linkage == GVA_StrongExternal)))
- return llvm::Function::AvailableExternallyLinkage;
- else
- return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
- : llvm::GlobalValue::LinkOnceODRLinkage;
- case CXXDtorType::Dtor_Deleting:
- return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
- : llvm::GlobalValue::LinkOnceODRLinkage;
- }
+ getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D),
+ GD.getDtorType())) {
+ // Destructor variants in the Microsoft C++ ABI are always internal or
+ // linkonce_odr thunks emitted on an as-needed basis.
+ return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
+ : llvm::GlobalValue::LinkOnceODRLinkage;
}
+
if (isa<CXXConstructorDecl>(D) &&
cast<CXXConstructorDecl>(D)->isInheritingConstructor() &&
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
@@ -890,25 +879,12 @@ CodeGenModule::getFunctionLinkage(Global
void CodeGenModule::setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F) {
const auto *FD = cast<FunctionDecl>(GD.getDecl());
- if (dyn_cast_or_null<CXXDestructorDecl>(FD)) {
- switch (GD.getDtorType()) {
- case CXXDtorType::Dtor_Comdat:
- case CXXDtorType::Dtor_Deleting: {
+ if (const auto *Dtor = dyn_cast_or_null<CXXDestructorDecl>(FD)) {
+ if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) {
// Don't dllexport/import destructor thunks.
F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
return;
}
- case CXXDtorType::Dtor_Complete:
- if (FD->hasAttr<DLLImportAttr>())
- F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
- else if (FD->hasAttr<DLLExportAttr>())
- F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
- else
- F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
- return;
- case CXXDtorType::Dtor_Base:
- break;
- }
}
if (FD->hasAttr<DLLImportAttr>())
Modified: cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp?rev=321298&r1=321297&r2=321298&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp Thu Dec 21 11:44:23 2017
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O1 -disable-llvm-passes -o - | FileCheck --check-prefix=MO1 %s
// FIXME: We should really consider removing -mconstructor-aliases for MS C++
// ABI. The risk of bugs introducing ABI incompatibility under
@@ -24,7 +23,9 @@ struct __declspec(dllimport) ImportOverr
virtual ~ImportOverrideVDtor() {}
};
-// Virtually inherits from a non-dllimport base class. Emit the vbase destructor.
+// Virtually inherits from a non-dllimport base class. This time we need to call
+// the complete destructor and emit it inline. It's not exported from the DLL,
+// and it must be emitted.
struct __declspec(dllimport) ImportVBaseOverrideVDtor
: public virtual BaseClass {
virtual ~ImportVBaseOverrideVDtor() {}
@@ -40,11 +41,9 @@ extern "C" void testit() {
// needs the complete destructor (_D).
// CHECK-LABEL: define void @testit()
// CHECK: call void @"\01??_DImportVBaseOverrideVDtor@@QEAAXXZ"(%struct.ImportVBaseOverrideVDtor* %{{.*}})
-// CHECK: call void @"\01??_DImportOverrideVDtor@@QEAAXXZ"(%struct.ImportOverrideVDtor* %{{.*}})
-// CHECK: call void @"\01??_DImportIntroVDtor@@QEAAXXZ"(%struct.ImportIntroVDtor* %{{.*}})
+// CHECK: call void @"\01??1ImportOverrideVDtor@@UEAA at XZ"(%struct.ImportOverrideVDtor* %{{.*}})
+// CHECK: call void @"\01??1ImportIntroVDtor@@UEAA at XZ"(%struct.ImportIntroVDtor* %{{.*}})
-// CHECK-LABEL: declare dllimport void @"\01??_DImportVBaseOverrideVDtor@@QEAAXXZ"(%struct.ImportVBaseOverrideVDtor*)
-// CHECK-LABEL: declare dllimport void @"\01??_DImportOverrideVDtor@@QEAAXXZ"(%struct.ImportOverrideVDtor*)
-// CHECK-LABEL: declare dllimport void @"\01??_DImportIntroVDtor@@QEAAXXZ"(%struct.ImportIntroVDtor*)
-
-// MO1-DAG: define available_externally dllimport void @"\01??_DImportIntroVDtor@@QEAAXXZ"
+// CHECK-LABEL: define linkonce_odr void @"\01??_DImportVBaseOverrideVDtor@@QEAAXXZ"
+// CHECK-LABEL: declare dllimport void @"\01??1ImportOverrideVDtor@@UEAA at XZ"
+// CHECK-LABEL: declare dllimport void @"\01??1ImportIntroVDtor@@UEAA at XZ"
Modified: cfe/trunk/test/CodeGenCXX/dllimport-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-members.cpp?rev=321298&r1=321297&r2=321298&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-members.cpp Thu Dec 21 11:44:23 2017
@@ -414,7 +414,8 @@ struct ImportSpecials {
// G64-DAG: declare dllimport void @_ZN14ImportSpecialsC1Ev(%struct.ImportSpecials*)
__declspec(dllimport) ImportSpecials();
- // M32-DAG: declare dllimport x86_thiscallcc void @"\01??_DImportSpecials@@QAEXXZ"(%struct.ImportSpecials*)
+ // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportSpecials@@QAE at XZ"(%struct.ImportSpecials*)
+ // M64-DAG: declare dllimport void @"\01??1ImportSpecials@@QEAA at XZ"(%struct.ImportSpecials*)
// G32-DAG: declare dllimport x86_thiscallcc void @_ZN14ImportSpecialsD1Ev(%struct.ImportSpecials*)
// G64-DAG: declare dllimport void @_ZN14ImportSpecialsD1Ev(%struct.ImportSpecials*)
__declspec(dllimport) ~ImportSpecials();
@@ -456,7 +457,8 @@ struct ImportInlineSpecials {
// GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1Ev(
__declspec(dllimport) ImportInlineSpecials() {}
- // M32-DAG: declare dllimport x86_thiscallcc void @"\01??_DImportInlineSpecials@@QAEXXZ"(%struct.ImportInlineSpecials*)
+ // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportInlineSpecials@@QAE at XZ"(%struct.ImportInlineSpecials*)
+ // M64-DAG: declare dllimport void @"\01??1ImportInlineSpecials@@QEAA at XZ"(%struct.ImportInlineSpecials*)
// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials* %this)
// G64-DAG: define linkonce_odr void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials* %this)
// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1ImportInlineSpecials@@QAE at XZ"(
@@ -510,7 +512,8 @@ struct ImportDefaulted {
// GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted* %this)
__declspec(dllimport) ImportDefaulted() = default;
- // M32-DAG: declare dllimport x86_thiscallcc void @"\01??_DImportDefaulted@@QAEXXZ"(%struct.ImportDefaulted*)
+ // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportDefaulted@@QAE at XZ"(%struct.ImportDefaulted*)
+ // M64-DAG: declare dllimport void @"\01??1ImportDefaulted@@QEAA at XZ"(%struct.ImportDefaulted*)
// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
// G64-DAG: define linkonce_odr void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1ImportDefaulted@@QAE at XZ"(%struct.ImportDefaulted* %this)
@@ -575,7 +578,8 @@ __declspec(dllimport) ImportDefaultedDef
#ifdef MSABI
// For MinGW, the function will not be dllimport, and we cannot add the attribute now.
-// M32-DAG: declare dllimport x86_thiscallcc void @"\01??_DImportDefaulted@@QAEXXZ"(%struct.ImportDefaulted*)
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportDefaultedDefs@@QAE at XZ"(%struct.ImportDefaultedDefs*)
+// M64-DAG: declare dllimport void @"\01??1ImportDefaultedDefs@@QEAA at XZ"(%struct.ImportDefaultedDefs*)
__declspec(dllimport) ImportDefaultedDefs::~ImportDefaultedDefs() = default;
#endif
Removed: cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp?rev=321297&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp (removed)
@@ -1,73 +0,0 @@
-// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -fms-compatibility %s -x c++ -o - | FileCheck %s
-
-namespace test1 {
-struct BaseClass {
- ~BaseClass();
-};
-
-struct __declspec(dllimport) Concrete : virtual BaseClass {
-};
-
-Concrete c;
-
-// CHECK-LABEL: declare dllimport x86_thiscallcc %"struct.test1::Concrete"* @"\01??0Concrete at test1@@QAE at XZ"
-// CHECK-LABEL: declare dllimport x86_thiscallcc void @"\01??_DConcrete at test1@@QAEXXZ"(%"struct.test1::Concrete"*) unnamed_addr
-
-} // namespace test1
-
-namespace test2 {
-class BaseClass {
-public:
- virtual ~BaseClass(){};
-};
-
-class __declspec(dllimport) VirtualClass : public virtual BaseClass {
-public:
- virtual ~VirtualClass(){};
-};
-
-int main() {
- VirtualClass c;
- return 0;
-}
-
-// CHECK-LABEL: declare dllimport x86_thiscallcc %"class.test2::VirtualClass"* @"\01??0VirtualClass at test2@@QAE at XZ"
-// CHECK-LABEL: declare dllimport x86_thiscallcc void @"\01??_DVirtualClass at test2@@QAEXXZ"(%"class.test2::VirtualClass"*)
-
-} // namespace test2
-
-namespace test3 {
-class IVirtualBase {
-public:
- virtual ~IVirtualBase(){};
- virtual void speak() = 0;
-};
-
-class VirtualClass : public virtual IVirtualBase {
-public:
- virtual ~VirtualClass(){};
- virtual void eat() = 0;
-};
-
-class __declspec(dllimport) ConcreteClass : public VirtualClass {
-public:
- ConcreteClass(int nn);
- void speak();
- void eat();
- virtual ~ConcreteClass();
-
-private:
- int n;
-};
-
-int main() {
- ConcreteClass c(10);
- c.speak();
- c.eat();
- return 0;
-}
-
-// CHECK-LABEL: declare dllimport x86_thiscallcc %"class.test3::ConcreteClass"* @"\01??0ConcreteClass at test3@@QAE at H@Z"
-// CHECK-LABEL: declare dllimport x86_thiscallcc void @"\01??_DConcreteClass at test3@@QAEXXZ"(%"class.test3::ConcreteClass"*)
-
-} // namespace test3
Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=321298&r1=321297&r2=321298&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Thu Dec 21 11:44:23 2017
@@ -362,8 +362,8 @@ struct __declspec(dllimport) ClassWithNo
struct __declspec(dllimport) ClassWithNonDllImportBase : public ClassWithDtor { };
USECLASS(ClassWithNonDllImportField);
USECLASS(ClassWithNonDllImportBase);
-// MO1-DAG: declare dllimport x86_thiscallcc void @"\01??_DClassWithNonDllImportBase@@QAEXXZ"(%struct.ClassWithNonDllImportBase*)
-// MO1-DAG: declare dllimport x86_thiscallcc void @"\01??_DClassWithNonDllImportField@@QAEXXZ"(%struct.ClassWithNonDllImportField*)
+// MO1-DAG: declare dllimport x86_thiscallcc void @"\01??1ClassWithNonDllImportBase@@QAE at XZ"(%struct.ClassWithNonDllImportBase*)
+// MO1-DAG: declare dllimport x86_thiscallcc void @"\01??1ClassWithNonDllImportField@@QAE at XZ"(%struct.ClassWithNonDllImportField*)
struct ClassWithCtor { ClassWithCtor() {} };
struct __declspec(dllimport) ClassWithNonDllImportFieldWithCtor { ClassWithCtor t; };
USECLASS(ClassWithNonDllImportFieldWithCtor);
Removed: cfe/trunk/test/CodeGenCXX/external-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/external-linkage.cpp?rev=321297&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/external-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/external-linkage.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=18.00 -emit-llvm -std=c++1y -O1 -disable-llvm-passes -o - %s -DMSABI -w | FileCheck --check-prefix=MO1 --check-prefix=MO2 %s
-
-// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=18.00 -emit-llvm -std=c++1y -o - %s -DMSABI -w | FileCheck --check-prefix=MO3 --check-prefix=MO4 %s
-
-// MO1-DAG:@"\01??_8B@@7B@" = available_externally dllimport unnamed_addr constant [2 x i32] [i32 0, i32 4]
-// MO2-DAG: define available_externally dllimport x86_thiscallcc %struct.B* @"\01??0B@@QAE at XZ"
-
-struct __declspec(dllimport) A {
- virtual ~A();
-};
-struct __declspec(dllimport) B : virtual A {
- virtual ~B();
-};
-void f() { B b; }
-
-// MO3-DAG: declare dllimport x86_thiscallcc %struct.B* @"\01??0B@@QAE at XZ"
-// MO4-DAG: declare dllimport x86_thiscallcc void @"\01??_DB@@QAEXXZ"
More information about the cfe-commits
mailing list