Author: compnerd Date: Fri Sep 30 18:11:05 2016 New Revision: 282980 URL: http://llvm.org/viewvc/llvm-project?rev=282980&view=rev Log: CodeGen: inherit DLLExport attribute in Windows Itanium
When emitting the fundamental type information constants, inherit the DLLExportAttr from `__fundamental_type_info`. We would previously not honor the `__declspec(dllexport)` on the type information. Added: cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=282980&r1=282979&r2=282980&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Sep 30 18:11:05 2016 @@ -170,8 +170,8 @@ public: emitTerminateForUnexpectedException(CodeGenFunction &CGF, llvm::Value *Exn) override; - void EmitFundamentalRTTIDescriptor(QualType Type); - void EmitFundamentalRTTIDescriptors(); + void EmitFundamentalRTTIDescriptor(QualType Type, bool DLLExport); + void EmitFundamentalRTTIDescriptors(bool DLLExport); llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) override; CatchTypeInfo getAddrOfCXXCatchHandlerType(QualType Ty, @@ -1500,7 +1500,7 @@ void ItaniumCXXABI::emitVTableDefinition isa<NamespaceDecl>(DC) && cast<NamespaceDecl>(DC)->getIdentifier() && cast<NamespaceDecl>(DC)->getIdentifier()->isStr("__cxxabiv1") && DC->getParent()->isTranslationUnit()) - EmitFundamentalRTTIDescriptors(); + EmitFundamentalRTTIDescriptors(RD->hasAttr<DLLExportAttr>()); if (!VTable->isDeclarationForLinker()) CGM.EmitVTableTypeMetadata(VTable, VTLayout); @@ -2472,7 +2472,9 @@ public: /// BuildTypeInfo - Build the RTTI type info struct for the given type. /// /// \param Force - true to force the creation of this RTTI value - llvm::Constant *BuildTypeInfo(QualType Ty, bool Force = false); + /// \param DLLExport - true to mark the RTTI value as DLLExport + llvm::Constant *BuildTypeInfo(QualType Ty, bool Force = false, + bool DLLExport = false); }; } @@ -2904,7 +2906,8 @@ static llvm::GlobalVariable::LinkageType llvm_unreachable("Invalid linkage!"); } -llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) { +llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force, + bool DLLExport) { // We want to operate on the canonical type. Ty = Ty.getCanonicalType(); @@ -3089,6 +3092,8 @@ llvm::Constant *ItaniumRTTIBuilder::Buil llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility()); TypeName->setVisibility(llvmVisibility); GV->setVisibility(llvmVisibility); + if (DLLExport) + GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy); } @@ -3370,15 +3375,18 @@ llvm::Constant *ItaniumCXXABI::getAddrOf return ItaniumRTTIBuilder(*this).BuildTypeInfo(Ty); } -void ItaniumCXXABI::EmitFundamentalRTTIDescriptor(QualType Type) { +void ItaniumCXXABI::EmitFundamentalRTTIDescriptor(QualType Type, + bool DLLExport) { QualType PointerType = getContext().getPointerType(Type); QualType PointerTypeConst = getContext().getPointerType(Type.withConst()); - ItaniumRTTIBuilder(*this).BuildTypeInfo(Type, true); - ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerType, true); - ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerTypeConst, true); + ItaniumRTTIBuilder(*this).BuildTypeInfo(Type, /*Force=*/true, DLLExport); + ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerType, /*Force=*/true, + DLLExport); + ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerTypeConst, /*Force=*/true, + DLLExport); } -void ItaniumCXXABI::EmitFundamentalRTTIDescriptors() { +void ItaniumCXXABI::EmitFundamentalRTTIDescriptors(bool DLLExport) { // Types added here must also be added to TypeInfoIsInStandardLibrary. QualType FundamentalTypes[] = { getContext().VoidTy, getContext().NullPtrTy, @@ -3395,7 +3403,7 @@ void ItaniumCXXABI::EmitFundamentalRTTID getContext().Char16Ty, getContext().Char32Ty }; for (const QualType &FundamentalType : FundamentalTypes) - EmitFundamentalRTTIDescriptor(FundamentalType); + EmitFundamentalRTTIDescriptor(FundamentalType, DLLExport); } /// What sort of uniqueness rules should we use for the RTTI for the Added: 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=282980&view=auto ============================================================================== --- cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp (added) +++ cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Fri Sep 30 18:11:05 2016 @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s + +namespace __cxxabiv1 { +class __declspec(dllexport) __fundamental_type_info { +public: + virtual ~__fundamental_type_info(); +}; + +__fundamental_type_info::~__fundamental_type_info() {} +} + +// CHECK: @_ZTIi = dllexport constant + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits