Index: clang/docs/UsersManual.rst =================================================================== --- clang/docs/UsersManual.rst +++ clang/docs/UsersManual.rst @@ -3624,6 +3624,23 @@ `Some tests might fail `_ on ``x86_64-w64-mingw32``. +AIX +^^^ + +The ``-mdefault-visibility-export-mapping=`` option can be used to control +mapping of default visibility to an explicit shared object export +(i.e. XCOFF exported visibility). Three values are provided for the option: + +* ``-mdefault-visibility-export-mapping=none``: no additional export + information is created for entities with default visibility. +* ``-mdefault-visibility-export-mapping=explicit``: mark entities for export + if they have explict (e.g. via an attribute) default visibility from the + source, including RTTI. +* ``-mdefault-visibility-export-mapping=all``: set XCOFF exported visibility + for all entities with default visibility from any source. This gives a + export behavior similar to ELF platforms where all entities with default + visibility are exported. + .. _spir-v: SPIR-V support Index: clang/include/clang/Basic/LangOptions.h =================================================================== --- clang/include/clang/Basic/LangOptions.h +++ clang/include/clang/Basic/LangOptions.h @@ -353,6 +353,14 @@ PerThread, }; + enum class DefaultVisiblityExportMapping { + None, + /// map only explicit public visibilities to exported + Explicit, + /// map all public visibilities to exported + All, + }; + public: /// The used language standard. LangStandard::Kind LangStd; @@ -584,6 +592,16 @@ bool isSYCL() const { return SYCLIsDevice || SYCLIsHost; } + bool isExplicitDefaultVisibilityExportMapping() const { + return getDefaultVisibilityExportMapping() == + DefaultVisiblityExportMapping::Explicit; + } + + bool isAllDefaultVisibilityExportMapping() const { + return getDefaultVisibilityExportMapping() == + DefaultVisiblityExportMapping::All; + } + /// Remap path prefix according to -fmacro-prefix-path option. void remapPathPrefix(SmallVectorImpl &Path) const; }; Index: clang/include/clang/Basic/LangOptions.def =================================================================== --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -289,6 +289,7 @@ BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables") LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings") BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline C++ methods") +BENIGN_ENUM_LANGOPT(DefaultVisibilityExportMapping, DefaultVisiblityExportMapping, 2, DefaultVisiblityExportMapping::None, "controls mapping of public visibility to dllexport") BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility attributes that are specified in the source code are ignored in aix XCOFF.") BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0, "hidden visibility for static local variables in inline C++ " Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2908,6 +2908,13 @@ def fvisibility_global_new_delete_hidden : Flag<["-"], "fvisibility-global-new-delete-hidden">, Group, HelpText<"Give global C++ operator new and delete declarations hidden visibility">, Flags<[CC1Option]>, MarshallingInfoFlag>; +def mdefault_visibility_export_mapping_EQ : Joined<["-"], "mdefault-visibility-export-mapping=">, + Values<"none,explicit,all">, + NormalizedValuesScope<"LangOptions::DefaultVisiblityExportMapping">, + NormalizedValues<["None", "Explicit", "All"]>, + HelpText<"Mapping between default visibility and export">, + Group, Flags<[CC1Option]>, + MarshallingInfoEnum,"None">; defm new_infallible : BoolFOption<"new-infallible", LangOpts<"NewInfallible">, DefaultFalse, PosFlag, NegFlag, Index: clang/lib/CodeGen/CodeGenModule.h =================================================================== --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -798,6 +798,7 @@ void setDSOLocal(llvm::GlobalValue *GV) const; + bool shouldMapVisibilityToDLLExport(const NamedDecl *D) const; void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const; void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const; /// Set visibility, dllimport/dllexport and dso_local. Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -1212,12 +1212,21 @@ setDLLImportDLLExport(GV, D); } +bool CodeGenModule::shouldMapVisibilityToDLLExport(const NamedDecl *D) const { + return (D->getLinkageAndVisibility().getVisibility() == DefaultVisibility) && + ((D->getLinkageAndVisibility().isVisibilityExplicit() && + getLangOpts().isExplicitDefaultVisibilityExportMapping()) || + getLangOpts().isAllDefaultVisibilityExportMapping()); +} + void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const { if (D && D->isExternallyVisible()) { if (D->hasAttr()) GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); - else if (D->hasAttr() && !GV->isDeclarationForLinker()) + else if ((D->hasAttr() || + shouldMapVisibilityToDLLExport(D)) && + !GV->isDeclarationForLinker()) GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); } } Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3680,12 +3680,12 @@ llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass = llvm::GlobalValue::DefaultStorageClass; - if (CGM.getTriple().isWindowsItaniumEnvironment()) { - auto RD = Ty->getAsCXXRecordDecl(); - if (RD && RD->hasAttr()) + if (auto RD = Ty->getAsCXXRecordDecl()) { + if ((CGM.getTriple().isWindowsItaniumEnvironment() && + RD->hasAttr()) || + CGM.shouldMapVisibilityToDLLExport(RD)) DLLStorageClass = llvm::GlobalValue::DLLExportStorageClass; } - return BuildTypeInfo(Ty, Linkage, llvmVisibility, DLLStorageClass); } @@ -4168,7 +4168,7 @@ getContext().Char32Ty }; llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass = - RD->hasAttr() + RD->hasAttr() || CGM.shouldMapVisibilityToDLLExport(RD) ? llvm::GlobalValue::DLLExportStorageClass : llvm::GlobalValue::DefaultStorageClass; llvm::GlobalValue::VisibilityTypes Visibility = Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp =================================================================== --- clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -47,7 +47,11 @@ : CGCXXABI(CGM), BaseClassDescriptorType(nullptr), ClassHierarchyDescriptorType(nullptr), CompleteObjectLocatorType(nullptr), CatchableTypeType(nullptr), - ThrowInfoType(nullptr) {} + ThrowInfoType(nullptr) { + assert(!(CGM.getLangOpts().isExplicitDefaultVisibilityExportMapping() || + CGM.getLangOpts().isAllDefaultVisibilityExportMapping()) && + "visibility export mapping option unimplemented in this ABI"); + } bool HasThisReturn(GlobalDecl GD) const override; bool hasMostDerivedReturn(GlobalDecl GD) const override; Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5966,6 +5966,14 @@ << A->getAsString(Args) << TripleStr; } + if (const Arg *A = + Args.getLastArg(options::OPT_mdefault_visibility_export_mapping_EQ)) { + if (Triple.isOSAIX()) + A->render(Args, CmdArgs); + else + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; + } if (Args.hasFlag(options::OPT_fvisibility_inlines_hidden, options::OPT_fno_visibility_inlines_hidden, false)) Index: clang/test/CodeGen/mdefault-visibility-export-mapping.c =================================================================== --- /dev/null +++ clang/test/CodeGen/mdefault-visibility-export-mapping.c @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-DEF %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=none -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-DEF %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=explicit -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-EXP %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=all -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-EXP,EXPLICIT-EXP %s +// RUN: %clang -target powerpc-ibm-aix %s -mdefault-visibility-export-mapping=all -fvisibility=hidden -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-HID,EXPLICIT-EXP %s + +// RUN: not %clang -mdefault-visibility-export-mapping=explicit -target powerpc-unknown-linux %s 2>&1 | \ +// RUN: FileCheck -check-prefix=ERROR %s +// ERROR: unsupported option '-mdefault-visibility-export-mapping=explicit' for target 'powerpc-unknown-linux' + +// UNSPECIFIED-DEF: define void @func() +// UNSPECIFIED-HID: define hidden void @func() +// UNSPECIFIED-EXP: define dllexport void @func() +void func() {} + +#pragma GCC visibility push(default) +// EXPLICIT-DEF: define void @pragmafunc() +// EXPLICIT-EXP: define dllexport void @pragmafunc() +void pragmafunc() {} +#pragma GCC visibility pop + +// EXPLICIT-DEF: define void @explicitfunc() +// EXPLICIT-EXP: define dllexport void @explicitfunc() +void __attribute__((visibility("default"))) explicitfunc() {} Index: clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp =================================================================== --- /dev/null +++ clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp @@ -0,0 +1,571 @@ +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=none -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-DEF,FUND-DEF %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=explicit -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-EXP,FUND-DEF %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=explicit -DFUNDAMENTAL_IS_EXPLICIT -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-DEF,EXPLICIT-EXP,FUND-EXP %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=all -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-EXP,EXPLICIT-EXP,FUND-EXP %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=all -fvisibility hidden -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-HID,EXPLICIT-EXP,FUND-HID %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -internal-isystem %S -mdefault-visibility-export-mapping=all -DFUNDAMENTAL_IS_EXPLICIT -fvisibility hidden -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=UNSPECIFIED-HID,EXPLICIT-EXP,FUND-EXP %s + +#include + +// unspecified visibility RTTI & vtable +struct s { + virtual void foo(); +}; +void s::foo() {} +// UNSPECIFIED-DEF: @_ZTV1s = unnamed_addr constant +// UNSPECIFIED-HID: @_ZTV1s = hidden unnamed_addr constant +// UNSPECIFIED-EXP: @_ZTV1s = dllexport unnamed_addr constant +// UNSPECIFIED-DEF: @_ZTS1s = constant +// UNSPECIFIED-HID: @_ZTS1s = hidden constant +// UNSPECIFIED-EXP: @_ZTS1s = dllexport constant +// UNSPECIFIED-DEF: @_ZTI1s = constant +// UNSPECIFIED-HID: @_ZTI1s = hidden constant +// UNSPECIFIED-EXP: @_ZTI1s = dllexport constant + +// explicit default visibility RTTI & vtable +struct __attribute__((type_visibility("default"))) t { + virtual void foo(); +}; +void t::foo() {} +// EXPLICIT-DEF: @_ZTV1t = unnamed_addr constant +// EXPLICIT-HID: @_ZTV1t = hidden unnamed_addr constant +// EXPLICIT-EXP: @_ZTV1t = dllexport unnamed_addr constant +// EXPLICIT-DEF: @_ZTS1t = constant +// EXPLICIT-HID: @_ZTS1t = hidden constant +// EXPLICIT-EXP: @_ZTS1t = dllexport constant +// EXPLICIT-DEF: @_ZTI1t = constant +// EXPLICIT-HID: @_ZTI1t = hidden constant +// EXPLICIT-EXP: @_ZTI1t = dllexport constant + +#ifdef FUNDAMENTAL_IS_EXPLICIT +#define TYPE_VIS __attribute__((type_visibility("default"))) +#else +#define TYPE_VIS +#endif + +// Invoke the compiler magic to emit RTTI for fundamental types. +namespace __cxxabiv1 { +class TYPE_VIS __fundamental_type_info { + __attribute__((visibility("hidden"))) virtual ~__fundamental_type_info(); +}; + +__fundamental_type_info::~__fundamental_type_info() {} + +} // namespace __cxxabiv1 + +// __cxxabiv1::__fundamental_type_info +// FUND-DEF: @_ZTVN10__cxxabiv123__fundamental_type_infoE = unnamed_addr constant +// FUND-HID: @_ZTVN10__cxxabiv123__fundamental_type_infoE = hidden unnamed_addr constant +// FUND-EXP: @_ZTVN10__cxxabiv123__fundamental_type_infoE = dllexport unnamed_addr constant +// FUND-DEF: @_ZTSN10__cxxabiv123__fundamental_type_infoE = constant +// FUND-HID: @_ZTSN10__cxxabiv123__fundamental_type_infoE = hidden constant +// FUND-EXP: @_ZTSN10__cxxabiv123__fundamental_type_infoE = dllexport constant +// FUND-DEF: @_ZTIN10__cxxabiv123__fundamental_type_infoE = constant +// FUND-HID: @_ZTIN10__cxxabiv123__fundamental_type_infoE = hidden constant +// FUND-EXP: @_ZTIN10__cxxabiv123__fundamental_type_infoE = dllexport constant + +// void +// FUND-DEF: @_ZTSv = constant +// FUND-HID: @_ZTSv = hidden constant +// FUND-EXP: @_ZTSv = dllexport constant +// FUND-DEF: @_ZTIv = constant +// FUND-HID: @_ZTIv = hidden constant +// FUND-EXP: @_ZTIv = dllexport constant +// FUND-DEF: @_ZTSPv = constant +// FUND-HID: @_ZTSPv = hidden constant +// FUND-EXP: @_ZTSPv = dllexport constant +// FUND-DEF: @_ZTIPv = constant +// FUND-HID: @_ZTIPv = hidden constant +// FUND-EXP: @_ZTIPv = dllexport constant +// FUND-DEF: @_ZTSPKv = constant +// FUND-HID: @_ZTSPKv = hidden constant +// FUND-EXP: @_ZTSPKv = dllexport constant +// FUND-DEF: @_ZTIPKv = constant +// FUND-HID: @_ZTIPKv = hidden constant +// FUND-EXP: @_ZTIPKv = dllexport constant + +// std::nullptr_t +// FUND-DEF: @_ZTSDn = constant +// FUND-HID: @_ZTSDn = hidden constant +// FUND-EXP: @_ZTSDn = dllexport constant +// FUND-DEF: @_ZTIDn = constant +// FUND-HID: @_ZTIDn = hidden constant +// FUND-EXP: @_ZTIDn = dllexport constant +// FUND-DEF: @_ZTSPDn = constant +// FUND-HID: @_ZTSPDn = hidden constant +// FUND-EXP: @_ZTSPDn = dllexport constant +// FUND-DEF: @_ZTIPDn = constant +// FUND-HID: @_ZTIPDn = hidden constant +// FUND-EXP: @_ZTIPDn = dllexport constant +// FUND-DEF: @_ZTSPKDn = constant +// FUND-HID: @_ZTSPKDn = hidden constant +// FUND-EXP: @_ZTSPKDn = dllexport constant +// FUND-DEF: @_ZTIPKDn = constant +// FUND-HID: @_ZTIPKDn = hidden constant +// FUND-EXP: @_ZTIPKDn = dllexport constant + +// bool +// FUND-DEF: @_ZTSb = constant +// FUND-HID: @_ZTSb = hidden constant +// FUND-EXP: @_ZTSb = dllexport constant +// FUND-DEF: @_ZTIb = constant +// FUND-HID: @_ZTIb = hidden constant +// FUND-EXP: @_ZTIb = dllexport constant +// FUND-DEF: @_ZTSPb = constant +// FUND-HID: @_ZTSPb = hidden constant +// FUND-EXP: @_ZTSPb = dllexport constant +// FUND-DEF: @_ZTIPb = constant +// FUND-HID: @_ZTIPb = hidden constant +// FUND-EXP: @_ZTIPb = dllexport constant +// FUND-DEF: @_ZTSPKb = constant +// FUND-HID: @_ZTSPKb = hidden constant +// FUND-EXP: @_ZTSPKb = dllexport constant +// FUND-DEF: @_ZTIPKb = constant +// FUND-HID: @_ZTIPKb = hidden constant +// FUND-EXP: @_ZTIPKb = dllexport constant + +// wchar_t +// FUND-DEF: @_ZTSw = constant +// FUND-HID: @_ZTSw = hidden constant +// FUND-EXP: @_ZTSw = dllexport constant +// FUND-DEF: @_ZTIw = constant +// FUND-HID: @_ZTIw = hidden constant +// FUND-EXP: @_ZTIw = dllexport constant +// FUND-DEF: @_ZTSPw = constant +// FUND-HID: @_ZTSPw = hidden constant +// FUND-EXP: @_ZTSPw = dllexport constant +// FUND-DEF: @_ZTIPw = constant +// FUND-HID: @_ZTIPw = hidden constant +// FUND-EXP: @_ZTIPw = dllexport constant +// FUND-DEF: @_ZTSPKw = constant +// FUND-HID: @_ZTSPKw = hidden constant +// FUND-EXP: @_ZTSPKw = dllexport constant +// FUND-DEF: @_ZTIPKw = constant +// FUND-HID: @_ZTIPKw = hidden constant +// FUND-EXP: @_ZTIPKw = dllexport constant + +// char +// FUND-DEF: @_ZTSc = constant +// FUND-HID: @_ZTSc = hidden constant +// FUND-EXP: @_ZTSc = dllexport constant +// FUND-DEF: @_ZTIc = constant +// FUND-HID: @_ZTIc = hidden constant +// FUND-EXP: @_ZTIc = dllexport constant +// FUND-DEF: @_ZTSPc = constant +// FUND-HID: @_ZTSPc = hidden constant +// FUND-EXP: @_ZTSPc = dllexport constant +// FUND-DEF: @_ZTIPc = constant +// FUND-HID: @_ZTIPc = hidden constant +// FUND-EXP: @_ZTIPc = dllexport constant +// FUND-DEF: @_ZTSPKc = constant +// FUND-HID: @_ZTSPKc = hidden constant +// FUND-EXP: @_ZTSPKc = dllexport constant +// FUND-DEF: @_ZTIPKc = constant +// FUND-HID: @_ZTIPKc = hidden constant +// FUND-EXP: @_ZTIPKc = dllexport constant + +// unsigned char +// FUND-DEF: @_ZTSh = constant +// FUND-HID: @_ZTSh = hidden constant +// FUND-EXP: @_ZTSh = dllexport constant +// FUND-DEF: @_ZTIh = constant +// FUND-HID: @_ZTIh = hidden constant +// FUND-EXP: @_ZTIh = dllexport constant +// FUND-DEF: @_ZTSPh = constant +// FUND-HID: @_ZTSPh = hidden constant +// FUND-EXP: @_ZTSPh = dllexport constant +// FUND-DEF: @_ZTIPh = constant +// FUND-HID: @_ZTIPh = hidden constant +// FUND-EXP: @_ZTIPh = dllexport constant +// FUND-DEF: @_ZTSPKh = constant +// FUND-HID: @_ZTSPKh = hidden constant +// FUND-EXP: @_ZTSPKh = dllexport constant +// FUND-DEF: @_ZTIPKh = constant +// FUND-HID: @_ZTIPKh = hidden constant +// FUND-EXP: @_ZTIPKh = dllexport constant + +// signed char +// FUND-DEF: @_ZTSa = constant +// FUND-HID: @_ZTSa = hidden constant +// FUND-EXP: @_ZTSa = dllexport constant +// FUND-DEF: @_ZTIa = constant +// FUND-HID: @_ZTIa = hidden constant +// FUND-EXP: @_ZTIa = dllexport constant +// FUND-DEF: @_ZTSPa = constant +// FUND-HID: @_ZTSPa = hidden constant +// FUND-EXP: @_ZTSPa = dllexport constant +// FUND-DEF: @_ZTIPa = constant +// FUND-HID: @_ZTIPa = hidden constant +// FUND-EXP: @_ZTIPa = dllexport constant +// FUND-DEF: @_ZTSPKa = constant +// FUND-HID: @_ZTSPKa = hidden constant +// FUND-EXP: @_ZTSPKa = dllexport constant +// FUND-DEF: @_ZTIPKa = constant +// FUND-HID: @_ZTIPKa = hidden constant +// FUND-EXP: @_ZTIPKa = dllexport constant + +// short +// FUND-DEF: @_ZTSs = constant +// FUND-HID: @_ZTSs = hidden constant +// FUND-EXP: @_ZTSs = dllexport constant +// FUND-DEF: @_ZTIs = constant +// FUND-HID: @_ZTIs = hidden constant +// FUND-EXP: @_ZTIs = dllexport constant +// FUND-DEF: @_ZTSPs = constant +// FUND-HID: @_ZTSPs = hidden constant +// FUND-EXP: @_ZTSPs = dllexport constant +// FUND-DEF: @_ZTIPs = constant +// FUND-HID: @_ZTIPs = hidden constant +// FUND-EXP: @_ZTIPs = dllexport constant +// FUND-DEF: @_ZTSPKs = constant +// FUND-HID: @_ZTSPKs = hidden constant +// FUND-EXP: @_ZTSPKs = dllexport constant +// FUND-DEF: @_ZTIPKs = constant +// FUND-HID: @_ZTIPKs = hidden constant +// FUND-EXP: @_ZTIPKs = dllexport constant + +// unsigned short +// FUND-DEF: @_ZTSt = constant +// FUND-HID: @_ZTSt = hidden constant +// FUND-EXP: @_ZTSt = dllexport constant +// FUND-DEF: @_ZTIt = constant +// FUND-HID: @_ZTIt = hidden constant +// FUND-EXP: @_ZTIt = dllexport constant +// FUND-DEF: @_ZTSPt = constant +// FUND-HID: @_ZTSPt = hidden constant +// FUND-EXP: @_ZTSPt = dllexport constant +// FUND-DEF: @_ZTIPt = constant +// FUND-HID: @_ZTIPt = hidden constant +// FUND-EXP: @_ZTIPt = dllexport constant +// FUND-DEF: @_ZTSPKt = constant +// FUND-HID: @_ZTSPKt = hidden constant +// FUND-EXP: @_ZTSPKt = dllexport constant +// FUND-DEF: @_ZTIPKt = constant +// FUND-HID: @_ZTIPKt = hidden constant +// FUND-EXP: @_ZTIPKt = dllexport constant + +// int +// FUND-DEF: @_ZTSi = constant +// FUND-HID: @_ZTSi = hidden constant +// FUND-EXP: @_ZTSi = dllexport constant +// FUND-DEF: @_ZTIi = constant +// FUND-HID: @_ZTIi = hidden constant +// FUND-EXP: @_ZTIi = dllexport constant +// FUND-DEF: @_ZTSPi = constant +// FUND-HID: @_ZTSPi = hidden constant +// FUND-EXP: @_ZTSPi = dllexport constant +// FUND-DEF: @_ZTIPi = constant +// FUND-HID: @_ZTIPi = hidden constant +// FUND-EXP: @_ZTIPi = dllexport constant +// FUND-DEF: @_ZTSPKi = constant +// FUND-HID: @_ZTSPKi = hidden constant +// FUND-EXP: @_ZTSPKi = dllexport constant +// FUND-DEF: @_ZTIPKi = constant +// FUND-HID: @_ZTIPKi = hidden constant +// FUND-EXP: @_ZTIPKi = dllexport constant + +// unsigned int +// FUND-DEF: @_ZTSj = constant +// FUND-HID: @_ZTSj = hidden constant +// FUND-EXP: @_ZTSj = dllexport constant +// FUND-DEF: @_ZTIj = constant +// FUND-HID: @_ZTIj = hidden constant +// FUND-EXP: @_ZTIj = dllexport constant +// FUND-DEF: @_ZTSPj = constant +// FUND-HID: @_ZTSPj = hidden constant +// FUND-EXP: @_ZTSPj = dllexport constant +// FUND-DEF: @_ZTIPj = constant +// FUND-HID: @_ZTIPj = hidden constant +// FUND-EXP: @_ZTIPj = dllexport constant +// FUND-DEF: @_ZTSPKj = constant +// FUND-HID: @_ZTSPKj = hidden constant +// FUND-EXP: @_ZTSPKj = dllexport constant +// FUND-DEF: @_ZTIPKj = constant +// FUND-HID: @_ZTIPKj = hidden constant +// FUND-EXP: @_ZTIPKj = dllexport constant + +// long +// FUND-DEF: @_ZTSl = constant +// FUND-HID: @_ZTSl = hidden constant +// FUND-EXP: @_ZTSl = dllexport constant +// FUND-DEF: @_ZTIl = constant +// FUND-HID: @_ZTIl = hidden constant +// FUND-EXP: @_ZTIl = dllexport constant +// FUND-DEF: @_ZTSPl = constant +// FUND-HID: @_ZTSPl = hidden constant +// FUND-EXP: @_ZTSPl = dllexport constant +// FUND-DEF: @_ZTIPl = constant +// FUND-HID: @_ZTIPl = hidden constant +// FUND-EXP: @_ZTIPl = dllexport constant +// FUND-DEF: @_ZTSPKl = constant +// FUND-HID: @_ZTSPKl = hidden constant +// FUND-EXP: @_ZTSPKl = dllexport constant +// FUND-DEF: @_ZTIPKl = constant +// FUND-HID: @_ZTIPKl = hidden constant +// FUND-EXP: @_ZTIPKl = dllexport constant + +// unsigned long +// FUND-DEF: @_ZTSm = constant +// FUND-HID: @_ZTSm = hidden constant +// FUND-EXP: @_ZTSm = dllexport constant +// FUND-DEF: @_ZTIm = constant +// FUND-HID: @_ZTIm = hidden constant +// FUND-EXP: @_ZTIm = dllexport constant +// FUND-DEF: @_ZTSPm = constant +// FUND-HID: @_ZTSPm = hidden constant +// FUND-EXP: @_ZTSPm = dllexport constant +// FUND-DEF: @_ZTIPm = constant +// FUND-HID: @_ZTIPm = hidden constant +// FUND-EXP: @_ZTIPm = dllexport constant +// FUND-DEF: @_ZTSPKm = constant +// FUND-HID: @_ZTSPKm = hidden constant +// FUND-EXP: @_ZTSPKm = dllexport constant +// FUND-DEF: @_ZTIPKm = constant +// FUND-HID: @_ZTIPKm = hidden constant +// FUND-EXP: @_ZTIPKm = dllexport constant + +// long long +// FUND-DEF: @_ZTSx = constant +// FUND-HID: @_ZTSx = hidden constant +// FUND-EXP: @_ZTSx = dllexport constant +// FUND-DEF: @_ZTIx = constant +// FUND-HID: @_ZTIx = hidden constant +// FUND-EXP: @_ZTIx = dllexport constant +// FUND-DEF: @_ZTSPx = constant +// FUND-HID: @_ZTSPx = hidden constant +// FUND-EXP: @_ZTSPx = dllexport constant +// FUND-DEF: @_ZTIPx = constant +// FUND-HID: @_ZTIPx = hidden constant +// FUND-EXP: @_ZTIPx = dllexport constant +// FUND-DEF: @_ZTSPKx = constant +// FUND-HID: @_ZTSPKx = hidden constant +// FUND-EXP: @_ZTSPKx = dllexport constant +// FUND-DEF: @_ZTIPKx = constant +// FUND-HID: @_ZTIPKx = hidden constant +// FUND-EXP: @_ZTIPKx = dllexport constant + +// unsigned long long +// FUND-DEF: @_ZTSy = constant +// FUND-HID: @_ZTSy = hidden constant +// FUND-EXP: @_ZTSy = dllexport constant +// FUND-DEF: @_ZTIy = constant +// FUND-HID: @_ZTIy = hidden constant +// FUND-EXP: @_ZTIy = dllexport constant +// FUND-DEF: @_ZTSPy = constant +// FUND-HID: @_ZTSPy = hidden constant +// FUND-EXP: @_ZTSPy = dllexport constant +// FUND-DEF: @_ZTIPy = constant +// FUND-HID: @_ZTIPy = hidden constant +// FUND-EXP: @_ZTIPy = dllexport constant +// FUND-DEF: @_ZTSPKy = constant +// FUND-HID: @_ZTSPKy = hidden constant +// FUND-EXP: @_ZTSPKy = dllexport constant +// FUND-DEF: @_ZTIPKy = constant +// FUND-HID: @_ZTIPKy = hidden constant +// FUND-EXP: @_ZTIPKy = dllexport constant + +// __int128 +// FUND-DEF: @_ZTSn = constant +// FUND-HID: @_ZTSn = hidden constant +// FUND-EXP: @_ZTSn = dllexport constant +// FUND-DEF: @_ZTIn = constant +// FUND-HID: @_ZTIn = hidden constant +// FUND-EXP: @_ZTIn = dllexport constant +// FUND-DEF: @_ZTSPn = constant +// FUND-HID: @_ZTSPn = hidden constant +// FUND-EXP: @_ZTSPn = dllexport constant +// FUND-DEF: @_ZTIPn = constant +// FUND-HID: @_ZTIPn = hidden constant +// FUND-EXP: @_ZTIPn = dllexport constant +// FUND-DEF: @_ZTSPKn = constant +// FUND-HID: @_ZTSPKn = hidden constant +// FUND-EXP: @_ZTSPKn = dllexport constant +// FUND-DEF: @_ZTIPKn = constant +// FUND-HID: @_ZTIPKn = hidden constant +// FUND-EXP: @_ZTIPKn = dllexport constant + +// unsigned __int128 +// FUND-DEF: @_ZTSo = constant +// FUND-HID: @_ZTSo = hidden constant +// FUND-EXP: @_ZTSo = dllexport constant +// FUND-DEF: @_ZTIo = constant +// FUND-HID: @_ZTIo = hidden constant +// FUND-EXP: @_ZTIo = dllexport constant +// FUND-DEF: @_ZTSPo = constant +// FUND-HID: @_ZTSPo = hidden constant +// FUND-EXP: @_ZTSPo = dllexport constant +// FUND-DEF: @_ZTIPo = constant +// FUND-HID: @_ZTIPo = hidden constant +// FUND-EXP: @_ZTIPo = dllexport constant +// FUND-DEF: @_ZTSPKo = constant +// FUND-HID: @_ZTSPKo = hidden constant +// FUND-EXP: @_ZTSPKo = dllexport constant +// FUND-DEF: @_ZTIPKo = constant +// FUND-HID: @_ZTIPKo = hidden constant +// FUND-EXP: @_ZTIPKo = dllexport constant + +// half +// FUND-DEF: @_ZTSDh = constant +// FUND-HID: @_ZTSDh = hidden constant +// FUND-EXP: @_ZTSDh = dllexport constant +// FUND-DEF: @_ZTIDh = constant +// FUND-HID: @_ZTIDh = hidden constant +// FUND-EXP: @_ZTIDh = dllexport constant +// FUND-DEF: @_ZTSPDh = constant +// FUND-HID: @_ZTSPDh = hidden constant +// FUND-EXP: @_ZTSPDh = dllexport constant +// FUND-DEF: @_ZTIPDh = constant +// FUND-HID: @_ZTIPDh = hidden constant +// FUND-EXP: @_ZTIPDh = dllexport constant +// FUND-DEF: @_ZTSPKDh = constant +// FUND-HID: @_ZTSPKDh = hidden constant +// FUND-EXP: @_ZTSPKDh = dllexport constant +// FUND-DEF: @_ZTIPKDh = constant +// FUND-HID: @_ZTIPKDh = hidden constant +// FUND-EXP: @_ZTIPKDh = dllexport constant + +// float +// FUND-DEF: @_ZTSf = constant +// FUND-HID: @_ZTSf = hidden constant +// FUND-EXP: @_ZTSf = dllexport constant +// FUND-DEF: @_ZTIf = constant +// FUND-HID: @_ZTIf = hidden constant +// FUND-EXP: @_ZTIf = dllexport constant +// FUND-DEF: @_ZTSPf = constant +// FUND-HID: @_ZTSPf = hidden constant +// FUND-EXP: @_ZTSPf = dllexport constant +// FUND-DEF: @_ZTIPf = constant +// FUND-HID: @_ZTIPf = hidden constant +// FUND-EXP: @_ZTIPf = dllexport constant +// FUND-DEF: @_ZTSPKf = constant +// FUND-HID: @_ZTSPKf = hidden constant +// FUND-EXP: @_ZTSPKf = dllexport constant +// FUND-DEF: @_ZTIPKf = constant +// FUND-HID: @_ZTIPKf = hidden constant +// FUND-EXP: @_ZTIPKf = dllexport constant + +// double +// FUND-DEF: @_ZTSd = constant +// FUND-HID: @_ZTSd = hidden constant +// FUND-EXP: @_ZTSd = dllexport constant +// FUND-DEF: @_ZTId = constant +// FUND-HID: @_ZTId = hidden constant +// FUND-EXP: @_ZTId = dllexport constant +// FUND-DEF: @_ZTSPd = constant +// FUND-HID: @_ZTSPd = hidden constant +// FUND-EXP: @_ZTSPd = dllexport constant +// FUND-DEF: @_ZTIPd = constant +// FUND-HID: @_ZTIPd = hidden constant +// FUND-EXP: @_ZTIPd = dllexport constant +// FUND-DEF: @_ZTSPKd = constant +// FUND-HID: @_ZTSPKd = hidden constant +// FUND-EXP: @_ZTSPKd = dllexport constant +// FUND-DEF: @_ZTIPKd = constant +// FUND-HID: @_ZTIPKd = hidden constant +// FUND-EXP: @_ZTIPKd = dllexport constant + +// long double +// FUND-DEF: @_ZTSe = constant +// FUND-HID: @_ZTSe = hidden constant +// FUND-EXP: @_ZTSe = dllexport constant +// FUND-DEF: @_ZTIe = constant +// FUND-HID: @_ZTIe = hidden constant +// FUND-EXP: @_ZTIe = dllexport constant +// FUND-DEF: @_ZTSPe = constant +// FUND-HID: @_ZTSPe = hidden constant +// FUND-EXP: @_ZTSPe = dllexport constant +// FUND-DEF: @_ZTIPe = constant +// FUND-HID: @_ZTIPe = hidden constant +// FUND-EXP: @_ZTIPe = dllexport constant +// FUND-DEF: @_ZTSPKe = constant +// FUND-HID: @_ZTSPKe = hidden constant +// FUND-EXP: @_ZTSPKe = dllexport constant +// FUND-DEF: @_ZTIPKe = constant +// FUND-HID: @_ZTIPKe = hidden constant +// FUND-EXP: @_ZTIPKe = dllexport constant + +// __ieee128 +// FUND-DEF: @_ZTSu9__ieee128 = constant +// FUND-HID: @_ZTSu9__ieee128 = hidden constant +// FUND-EXP: @_ZTSu9__ieee128 = dllexport constant +// FUND-DEF: @_ZTIu9__ieee128 = constant +// FUND-HID: @_ZTIu9__ieee128 = hidden constant +// FUND-EXP: @_ZTIu9__ieee128 = dllexport constant +// FUND-DEF: @_ZTSPu9__ieee128 = constant +// FUND-HID: @_ZTSPu9__ieee128 = hidden constant +// FUND-EXP: @_ZTSPu9__ieee128 = dllexport constant +// FUND-DEF: @_ZTIPu9__ieee128 = constant +// FUND-HID: @_ZTIPu9__ieee128 = hidden constant +// FUND-EXP: @_ZTIPu9__ieee128 = dllexport constant +// FUND-DEF: @_ZTSPKu9__ieee128 = constant +// FUND-HID: @_ZTSPKu9__ieee128 = hidden constant +// FUND-EXP: @_ZTSPKu9__ieee128 = dllexport constant +// FUND-DEF: @_ZTIPKu9__ieee128 = constant +// FUND-HID: @_ZTIPKu9__ieee128 = hidden constant +// FUND-EXP: @_ZTIPKu9__ieee128 = dllexport constant + +// char8_t +// FUND-DEF: @_ZTSDu = constant +// FUND-HID: @_ZTSDu = hidden constant +// FUND-EXP: @_ZTSDu = dllexport constant +// FUND-DEF: @_ZTIDu = constant +// FUND-HID: @_ZTIDu = hidden constant +// FUND-EXP: @_ZTIDu = dllexport constant +// FUND-DEF: @_ZTSPDu = constant +// FUND-HID: @_ZTSPDu = hidden constant +// FUND-EXP: @_ZTSPDu = dllexport constant +// FUND-DEF: @_ZTIPDu = constant +// FUND-HID: @_ZTIPDu = hidden constant +// FUND-EXP: @_ZTIPDu = dllexport constant +// FUND-DEF: @_ZTSPKDu = constant +// FUND-HID: @_ZTSPKDu = hidden constant +// FUND-EXP: @_ZTSPKDu = dllexport constant +// FUND-DEF: @_ZTIPKDu = constant +// FUND-HID: @_ZTIPKDu = hidden constant +// FUND-EXP: @_ZTIPKDu = dllexport constant + +// char16_t +// FUND-DEF: @_ZTSDs = constant +// FUND-HID: @_ZTSDs = hidden constant +// FUND-EXP: @_ZTSDs = dllexport constant +// FUND-DEF: @_ZTIDs = constant +// FUND-HID: @_ZTIDs = hidden constant +// FUND-EXP: @_ZTIDs = dllexport constant +// FUND-DEF: @_ZTSPDs = constant +// FUND-HID: @_ZTSPDs = hidden constant +// FUND-EXP: @_ZTSPDs = dllexport constant +// FUND-DEF: @_ZTIPDs = constant +// FUND-HID: @_ZTIPDs = hidden constant +// FUND-EXP: @_ZTIPDs = dllexport constant +// FUND-DEF: @_ZTSPKDs = constant +// FUND-HID: @_ZTSPKDs = hidden constant +// FUND-EXP: @_ZTSPKDs = dllexport constant +// FUND-DEF: @_ZTIPKDs = constant +// FUND-HID: @_ZTIPKDs = hidden constant +// FUND-EXP: @_ZTIPKDs = dllexport constant + +// char32_t +// FUND-DEF: @_ZTSDi = constant +// FUND-HID: @_ZTSDi = hidden constant +// FUND-EXP: @_ZTSDi = dllexport constant +// FUND-DEF: @_ZTIDi = constant +// FUND-HID: @_ZTIDi = hidden constant +// FUND-EXP: @_ZTIDi = dllexport constant +// FUND-DEF: @_ZTSPDi = constant +// FUND-HID: @_ZTSPDi = hidden constant +// FUND-EXP: @_ZTSPDi = dllexport constant +// FUND-DEF: @_ZTIPDi = constant +// FUND-HID: @_ZTIPDi = hidden constant +// FUND-EXP: @_ZTIPDi = dllexport constant +// FUND-DEF: @_ZTSPKDi = constant +// FUND-HID: @_ZTSPKDi = hidden constant +// FUND-EXP: @_ZTSPKDi = dllexport constant +// FUND-DEF: @_ZTIPKDi = constant +// FUND-HID: @_ZTIPKDi = hidden constant +// FUND-EXP: @_ZTIPKDi = dllexport constant Index: clang/test/CodeGenCXX/mdefault-visibility-export-mapping.cpp =================================================================== --- /dev/null +++ clang/test/CodeGenCXX/mdefault-visibility-export-mapping.cpp @@ -0,0 +1,100 @@ +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=CHECK,UNSPECIFIED-DEF,EXPLICIT-DEF %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=none -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=CHECK,UNSPECIFIED-DEF,EXPLICIT-DEF %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=explicit -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=CHECK,UNSPECIFIED-DEF,EXPLICIT-EXP %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -mdefault-visibility-export-mapping=all -S -emit-llvm -o - | \ +// RUN: FileCheck -check-prefixes=CHECK,UNSPECIFIED-EXP,EXPLICIT-EXP %s + +struct A {}; + +template +class B { +public: + T x; + B(T _x) : x(_x) {} + ~B() {} + void func(T x) {} +}; + +template +class __attribute__((visibility("default"))) C { +public: + T x; + C(T _x) : x(_x) {} + ~C() {} + void func(T x) {} +}; + +extern template class B; +extern template class C; + +// UNSPECIFIED-DEF: define void @_Z4funcv +// UNSPECIFIED-EXP: define dllexport void @_Z4funcv +void func() { + B x({}); + C y({}); + x.func({}); y.func({}); + B xi(0); + C yi(0); + xi.func(0); yi.func(0); +} + +// B::B(A) (complete object constructor) +// UNSPECIFIED-DEF: define linkonce_odr void @_ZN1BI1AEC1ES0_ +// UNSPECIFIED-EXP: define linkonce_odr dllexport void @_ZN1BI1AEC1ES0_ + +// C::C(A) (complete object constructor) +// EXPLICIT-DEF: define linkonce_odr void @_ZN1CI1AEC1ES0_ +// EXPLICIT-EXP: define linkonce_odr dllexport void @_ZN1CI1AEC1ES0_ + +// B::func(A) +// UNSPECIFIED-DEF: define linkonce_odr void @_ZN1BI1AE4funcES0_ +// UNSPECIFIED-EXP: define linkonce_odr dllexport void @_ZN1BI1AE4funcES0_ + +// C::func(A) +// EXPLICIT-DEF: define linkonce_odr void @_ZN1CI1AE4funcES0_ +// EXPLICIT-EXP: define linkonce_odr dllexport void @_ZN1CI1AE4funcES0_ + +// B::B(int) (complete object constructor) +// CHECK: declare void @_ZN1BIiEC1Ei + +// C::C(int) (complete object constructor) +// CHECK: declare void @_ZN1CIiEC1Ei + +// B::func(int) +// CHECK: declare void @_ZN1BIiE4funcEi + +// C::func(int) +// CHECK: declare void @_ZN1CIiE4funcEi + +// C::~C() (complete object destructor) +// CHECK: declare void @_ZN1CIiED1Ev + +// B::~B() (complete object destructor) +// CHECK: declare void @_ZN1BIiED1Ev + +// C::~c() (complete object destructor) +// EXPLICIT-DEF: define linkonce_odr void @_ZN1CI1AED1Ev +// EXPLICIT-EXP: define linkonce_odr dllexport void @_ZN1CI1AED1Ev + +// B::~B() (complete object destructor) +// UNSPECIFIED-DEF: define linkonce_odr void @_ZN1BI1AED1Ev +// UNSPECIFIED-EXP: define linkonce_odr dllexport void @_ZN1BI1AED1Ev + +// B::B(A) (base object constructor) +// UNSPECIFIED-DEF: define linkonce_odr void @_ZN1BI1AEC2ES0_ +// UNSPECIFIED-EXP: define linkonce_odr dllexport void @_ZN1BI1AEC2ES0_ + +// B::~B() (base object destructor) +// UNSPECIFIED-DEF: define linkonce_odr void @_ZN1BI1AED2Ev +// UNSPECIFIED-EXP: define linkonce_odr dllexport void @_ZN1BI1AED2Ev + +// C::C(A) (base object constructor) +// EXPLICIT-DEF: define linkonce_odr void @_ZN1CI1AEC2ES0_ +// EXPLICIT-EXP: define linkonce_odr dllexport void @_ZN1CI1AEC2ES0_ + +// C::~C() (base object destructor) +// EXPLICIT-DEF: define linkonce_odr void @_ZN1CI1AED2Ev +// EXPLICIT-EXP: define linkonce_odr dllexport void @_ZN1CI1AED2Ev