Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -844,20 +844,21 @@ GVALinkage Linkage = getContext().GetGVALinkageForFunction(D); if (isa(D) && - getCXXABI().useThunkForDtorVariant(cast(D), - GD.getDtorType())) { - // Destructor variants in the Microsoft C++ ABI are always internal or - // linkonce_odr thunks emitted on an as-needed basis. Except destructors - // that have a virtual base and dllimport attributes. Those will - // be marked with an external linkage. - if (cast(D)->getParent()->getNumVBases() && - (GD.getDtorType() == CXXDtorType::Dtor_Complete || - GD.getDtorType() == CXXDtorType::Dtor_Base) && - D->hasAttr()) - return llvm::Function::AvailableExternallyLinkage; - else - return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage - : llvm::GlobalValue::LinkOnceODRLinkage; + Context.getTargetInfo().getCXXABI().isMicrosoft()) { + switch (GD.getDtorType()) { + case CXXDtorType::Dtor_Base: + break; + case CXXDtorType::Dtor_Comdat: + case CXXDtorType::Dtor_Complete: + if (cast(D)->getParent()->getNumVBases() && + D->hasAttr()) + return llvm::Function::AvailableExternallyLinkage; + else + return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage + : llvm::GlobalValue::LinkOnceODRLinkage; + case CXXDtorType::Dtor_Deleting: + return llvm::GlobalValue::LinkOnceODRLinkage; + } } if (isa(D) && @@ -875,12 +876,19 @@ void CodeGenModule::setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F) { const auto *FD = cast(GD.getDecl()); - if (const auto *Dtor = dyn_cast_or_null(FD)) { - if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) { + if (dyn_cast_or_null(FD) && + Context.getTargetInfo().getCXXABI().isMicrosoft()) { + switch (GD.getDtorType()) { + case CXXDtorType::Dtor_Comdat: + case CXXDtorType::Dtor_Complete: + case CXXDtorType::Dtor_Deleting: { // Don't dllexport/import destructor thunks. F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); return; } + case CXXDtorType::Dtor_Base: + break; + } } if (FD->hasAttr())