summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDavid Tenty <daltenty@ibm.com>2022-05-10 11:39:58 -0400
committerDavid Tenty <daltenty@ibm.com>2022-06-13 13:43:46 -0400
commit6a8673038b0c7e20962d732515cd2cd4812f52ef (patch)
tree51f599846900cebc39e24460e1e157ce71f531ab /clang/lib/CodeGen/CodeGenModule.cpp
parent166d6ed5c70a509a266a942f6247ed64ecc6e232 (diff)
Reland [clang][AIX] add option mdefault-visibility-export-mapping
The option mdefault-visibility-export-mapping is created to allow mapping default visibility to an explicit shared library export (e.g. dllexport). Exactly how and if this is manifested is target dependent (since it depends on how they map dllexport in the IR). Three values are provided for the option: * none: the default and behavior without the option, no additional export linkage information is created. * explicit: add the export for entities with explict default visibility from the source, including RTTI * all: add the export for all entities with default visibility This option is useful for targets which do not export symbols as part of their usual default linkage behaviour (e.g. AIX), such targets traditionally specified such information in external files (e.g. export lists), but this mapping allows them to use the visibility information typically used for this purpose on other (e.g. ELF) platforms. This relands commit: 8c8a2679a20f621994fa904bcfc68775e7345edc with fixes for the compile time and assert problems that were reported by: * making shouldMapVisibilityToDLLExport inline and provide an early return in the case where no mapping is in effect (aka non-AIX platforms) * don't try to export RTTI types which we will give internal linkage to Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D126340
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 23b0df26ba2a..95d1a4c5f1bc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1214,7 +1214,9 @@ void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,
if (D && D->isExternallyVisible()) {
if (D->hasAttr<DLLImportAttr>())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
- else if (D->hasAttr<DLLExportAttr>() && !GV->isDeclarationForLinker())
+ else if ((D->hasAttr<DLLExportAttr>() ||
+ shouldMapVisibilityToDLLExport(D)) &&
+ !GV->isDeclarationForLinker())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
}
}
@@ -3790,7 +3792,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
}
// Handle dropped DLL attributes.
- if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>()) {
+ if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>() &&
+ !shouldMapVisibilityToDLLExport(cast_or_null<NamedDecl>(D))) {
Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
setDSOLocal(Entry);
}
@@ -4102,7 +4105,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
}
// Handle dropped DLL attributes.
- if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>())
+ if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>() &&
+ !shouldMapVisibilityToDLLExport(D))
Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
if (LangOpts.OpenMP && !LangOpts.OpenMPSimd && D)