r307052 - [CodeGen] Check key function for typeinfo import
Shoaib Meenai via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 3 18:02:19 PDT 2017
Author: smeenai
Date: Mon Jul 3 18:02:19 2017
New Revision: 307052
URL: http://llvm.org/viewvc/llvm-project?rev=307052&view=rev
Log:
[CodeGen] Check key function for typeinfo import
If the imported class does not have a key function, we should emit its
typeinfo locally instead of attempting to import it.
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=307052&r1=307051&r2=307052&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Jul 3 18:02:19 2017
@@ -2732,7 +2732,9 @@ static bool ShouldUseExternalRTTIDescrip
// function.
bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
if (CGM.getVTables().isVTableExternal(RD))
- return IsDLLImport ? false : true;
+ return IsDLLImport && !CGM.getTriple().isWindowsItaniumEnvironment()
+ ? false
+ : true;
if (IsDLLImport)
return true;
@@ -2968,7 +2970,8 @@ static llvm::GlobalVariable::LinkageType
if (RD->hasAttr<WeakAttr>())
return llvm::GlobalValue::WeakODRLinkage;
if (CGM.getTriple().isWindowsItaniumEnvironment())
- if (RD->hasAttr<DLLImportAttr>())
+ if (RD->hasAttr<DLLImportAttr>() &&
+ ShouldUseExternalRTTIDescriptor(CGM, Ty))
return llvm::GlobalValue::ExternalLinkage;
if (RD->isDynamicClass()) {
llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD);
@@ -3181,7 +3184,8 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
if (DLLExport || (RD && RD->hasAttr<DLLExportAttr>())) {
TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
- } else if (CGM.getLangOpts().RTTI && RD && RD->hasAttr<DLLImportAttr>()) {
+ } else if (RD && RD->hasAttr<DLLImportAttr>() &&
+ ShouldUseExternalRTTIDescriptor(CGM, Ty)) {
TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp?rev=307052&r1=307051&r2=307052&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Mon Jul 3 18:02:19 2017
@@ -32,9 +32,15 @@ void f() {
// CHECK-DAG: @_ZTV7derived = dllexport unnamed_addr constant
// CHECK-DAG: @_ZTI4base = external dllimport constant
-// CHECK-DAG: @_ZTS4base = external dllimport constant
-// CHECK-NOT: @_ZTV4base = external dllimport constant
// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr constant
// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr constant
+struct __declspec(dllimport) gatekeeper {};
+struct zuul : gatekeeper {
+ virtual ~zuul();
+};
+zuul::~zuul() {}
+
+// CHECK-DAG: @_ZTI10gatekeeper = linkonce_odr constant
+// CHECK-DAG: @_ZTS10gatekeeper = linkonce_odr constant
More information about the cfe-commits
mailing list