Just disable the hidden-visibility optimization for now by hiding it behind
a -cc1 option. The Darwin linker complains about mixed visibility when linking
gcc-built objects with clang-built objects, and the optimization isn't really
that valuable. Platforms with less ornery linkers can feel free to enable this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110979 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp
index 6917141..a3ab6ba 100644
--- a/lib/CodeGen/CGRTTI.cpp
+++ b/lib/CodeGen/CGRTTI.cpp
@@ -11,9 +11,11 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/Type.h"
-#include "clang/AST/RecordLayout.h"
#include "CodeGenModule.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/AST/Type.h"
+#include "clang/Frontend/CodeGenOptions.h"
+
using namespace clang;
using namespace CodeGen;
@@ -623,10 +625,13 @@
// GCC only relies on the uniqueness of the type names, not the
// type_infos themselves, so we can emit these as hidden symbols.
+ // But don't do this if we're worried about strict visibility
+ // compatibility.
if (const RecordType *RT = dyn_cast<RecordType>(Ty))
CGM.setTypeVisibility(GV, cast<CXXRecordDecl>(RT->getDecl()),
/*ForRTTI*/ true);
- else if (Linkage == llvm::GlobalValue::WeakODRLinkage)
+ else if (CGM.getCodeGenOpts().HiddenWeakVTables &&
+ Linkage == llvm::GlobalValue::WeakODRLinkage)
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 494176a..22701c2 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -2465,6 +2465,9 @@
const ThunkInfo &Thunk, llvm::Function *Fn) {
CGM.setGlobalVisibility(Fn, MD);
+ if (!CGM.getCodeGenOpts().HiddenWeakVTables)
+ return;
+
// If the thunk has weak/linkonce linkage, but the function must be
// emitted in every translation unit that references it, then we can
// emit its thunks with hidden visibility, since its thunks must be
@@ -2491,7 +2494,7 @@
case TSK_ExplicitSpecialization:
case TSK_ImplicitInstantiation:
- if (!CGM.getCodeGenOpts().EmitWeakTemplatesHidden)
+ if (!CGM.getCodeGenOpts().HiddenWeakTemplateVTables)
return;
break;
}
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 6283b74..1715042 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -225,6 +225,9 @@
bool IsForRTTI) const {
setGlobalVisibility(GV, RD);
+ if (!CodeGenOpts.HiddenWeakVTables)
+ return;
+
// We want to drop the visibility to hidden for weak type symbols.
// This isn't possible if there might be unresolved references
// elsewhere that rely on this symbol being visible.
@@ -260,7 +263,7 @@
// to deal with mixed-visibility symbols.
case TSK_ExplicitSpecialization:
case TSK_ImplicitInstantiation:
- if (!CodeGenOpts.EmitWeakTemplatesHidden)
+ if (!CodeGenOpts.HiddenWeakTemplateVTables)
return;
break;
}