summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-05-28 01:52:23 +0000
committerHans Wennborg <hans@hanshq.net>2014-05-28 01:52:23 +0000
commit275efb9e5020d60178251611373d636da6def0ca (patch)
treef76ac970bcacede0b9f36a0658ddaca6ead8bd1d /clang/lib/CodeGen/CodeGenModule.cpp
parent8399d69cb27f8bf67e25a40b8c3965eec180d00e (diff)
downloadbcm5719-llvm-275efb9e5020d60178251611373d636da6def0ca.tar.gz
bcm5719-llvm-275efb9e5020d60178251611373d636da6def0ca.zip
Don't dllimport/export destructor variants implemented by thunks.
MSVC doesn't export these functions, so trying to import them doesnt' work. Also, don't let any dll attributes on the CXXDestructorDecl influence the thunk's linkage -- they should always be linkonce_odr. This takes care of the FIXME's for this in Nico's tests. Differential Revision: http://reviews.llvm.org/D3930 llvm-svn: 209706
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 9e8401da3a8..c55e2310d8c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -561,13 +561,16 @@ CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
- bool UseThunkForDtorVariant =
- isa<CXXDestructorDecl>(D) &&
+ if (isa<CXXDestructorDecl>(D) &&
getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D),
- GD.getDtorType());
+ 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;
+ }
- return getLLVMLinkageForDeclarator(D, Linkage, /*isConstantVariable=*/false,
- UseThunkForDtorVariant);
+ return getLLVMLinkageForDeclarator(D, Linkage, /*isConstantVariable=*/false);
}
void CodeGenModule::setFunctionDefinitionAttributes(const FunctionDecl *D,
@@ -780,6 +783,13 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD,
setLinkageAndVisibilityForGV(F, FD);
+ 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);
+ }
+ }
+
if (const SectionAttr *SA = FD->getAttr<SectionAttr>())
F->setSection(SA->getName());
@@ -1914,8 +1924,7 @@ static bool isVarDeclStrongDefinition(const VarDecl *D, bool NoCommon) {
}
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
- const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable,
- bool UseThunkForDtorVariant) {
+ const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable) {
if (Linkage == GVA_Internal)
return llvm::Function::InternalLinkage;
@@ -1954,11 +1963,6 @@ llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
return !Context.getLangOpts().AppleKext ? llvm::Function::WeakODRLinkage
: llvm::Function::ExternalLinkage;
- // Destructor variants in the Microsoft C++ ABI are always linkonce_odr thunks
- // emitted on an as-needed basis.
- if (UseThunkForDtorVariant)
- return llvm::GlobalValue::LinkOnceODRLinkage;
-
// If required by the ABI, give definitions of static data members with inline
// initializers at least linkonce_odr linkage.
if (getCXXABI().isInlineInitializedStaticDataMemberLinkOnce() &&
@@ -1987,8 +1991,7 @@ llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageVarDefinition(
const VarDecl *VD, bool IsConstant) {
GVALinkage Linkage = getContext().GetGVALinkageForVariable(VD);
- return getLLVMLinkageForDeclarator(VD, Linkage, IsConstant,
- /*UseThunkForDtorVariant=*/false);
+ return getLLVMLinkageForDeclarator(VD, Linkage, IsConstant);
}
/// Replace the uses of a function that was declared with a non-proto type.
OpenPOWER on IntegriCloud