mirror of https://github.com/microsoft/clang.git
Revert r332028; see PR37545 for details.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332879 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
487e38f4cd
commit
00947e546d
|
@ -3006,10 +3006,20 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
|
||||||
|
|
||||||
/// Return the linkage that the type info and type info name constants
|
/// Return the linkage that the type info and type info name constants
|
||||||
/// should have for the given type.
|
/// should have for the given type.
|
||||||
static std::pair<llvm::GlobalVariable::LinkageTypes,
|
static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
|
||||||
llvm::GlobalVariable::LinkageTypes>
|
QualType Ty) {
|
||||||
getTypeInfoLinkage(CodeGenModule &CGM, QualType Ty) {
|
// Itanium C++ ABI 2.9.5p7:
|
||||||
llvm::GlobalValue::LinkageTypes TypeLinkage = [&]() {
|
// In addition, it and all of the intermediate abi::__pointer_type_info
|
||||||
|
// structs in the chain down to the abi::__class_type_info for the
|
||||||
|
// incomplete class type must be prevented from resolving to the
|
||||||
|
// corresponding type_info structs for the complete class type, possibly
|
||||||
|
// by making them local static objects. Finally, a dummy class RTTI is
|
||||||
|
// generated for the incomplete type that will not resolve to the final
|
||||||
|
// complete class RTTI (because the latter need not exist), possibly by
|
||||||
|
// making it a local static object.
|
||||||
|
if (ContainsIncompleteClassType(Ty))
|
||||||
|
return llvm::GlobalValue::InternalLinkage;
|
||||||
|
|
||||||
switch (Ty->getLinkage()) {
|
switch (Ty->getLinkage()) {
|
||||||
case NoLinkage:
|
case NoLinkage:
|
||||||
case InternalLinkage:
|
case InternalLinkage:
|
||||||
|
@ -3034,7 +3044,7 @@ getTypeInfoLinkage(CodeGenModule &CGM, QualType Ty) {
|
||||||
ShouldUseExternalRTTIDescriptor(CGM, Ty))
|
ShouldUseExternalRTTIDescriptor(CGM, Ty))
|
||||||
return llvm::GlobalValue::ExternalLinkage;
|
return llvm::GlobalValue::ExternalLinkage;
|
||||||
// MinGW always uses LinkOnceODRLinkage for type info.
|
// MinGW always uses LinkOnceODRLinkage for type info.
|
||||||
if (RD->isCompleteDefinition() && RD->isDynamicClass() &&
|
if (RD->isDynamicClass() &&
|
||||||
!CGM.getContext()
|
!CGM.getContext()
|
||||||
.getTargetInfo()
|
.getTargetInfo()
|
||||||
.getTriple()
|
.getTriple()
|
||||||
|
@ -3044,20 +3054,8 @@ getTypeInfoLinkage(CodeGenModule &CGM, QualType Ty) {
|
||||||
|
|
||||||
return llvm::GlobalValue::LinkOnceODRLinkage;
|
return llvm::GlobalValue::LinkOnceODRLinkage;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Invalid linkage!");
|
llvm_unreachable("Invalid linkage!");
|
||||||
}();
|
|
||||||
// Itanium C++ ABI 2.9.5p7:
|
|
||||||
// In addition, it and all of the intermediate abi::__pointer_type_info
|
|
||||||
// structs in the chain down to the abi::__class_type_info for the
|
|
||||||
// incomplete class type must be prevented from resolving to the
|
|
||||||
// corresponding type_info structs for the complete class type, possibly
|
|
||||||
// by making them local static objects. Finally, a dummy class RTTI is
|
|
||||||
// generated for the incomplete type that will not resolve to the final
|
|
||||||
// complete class RTTI (because the latter need not exist), possibly by
|
|
||||||
// making it a local static object.
|
|
||||||
if (ContainsIncompleteClassType(Ty))
|
|
||||||
return {llvm::GlobalValue::InternalLinkage, TypeLinkage};
|
|
||||||
return {TypeLinkage, TypeLinkage};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
|
llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
|
||||||
|
@ -3084,25 +3082,23 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
|
||||||
return GetAddrOfExternalRTTIDescriptor(Ty);
|
return GetAddrOfExternalRTTIDescriptor(Ty);
|
||||||
|
|
||||||
// Emit the standard library with external linkage.
|
// Emit the standard library with external linkage.
|
||||||
llvm::GlobalVariable::LinkageTypes InfoLinkage, NameLinkage;
|
llvm::GlobalVariable::LinkageTypes Linkage;
|
||||||
if (IsStdLib)
|
if (IsStdLib)
|
||||||
InfoLinkage = NameLinkage = llvm::GlobalValue::ExternalLinkage;
|
Linkage = llvm::GlobalValue::ExternalLinkage;
|
||||||
else {
|
else
|
||||||
auto LinkagePair = getTypeInfoLinkage(CGM, Ty);
|
Linkage = getTypeInfoLinkage(CGM, Ty);
|
||||||
InfoLinkage = LinkagePair.first;
|
|
||||||
NameLinkage = LinkagePair.second;
|
|
||||||
}
|
|
||||||
// Add the vtable pointer.
|
// Add the vtable pointer.
|
||||||
BuildVTablePointer(cast<Type>(Ty));
|
BuildVTablePointer(cast<Type>(Ty));
|
||||||
|
|
||||||
// And the name.
|
// And the name.
|
||||||
llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, NameLinkage);
|
llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
|
||||||
llvm::Constant *TypeNameField;
|
llvm::Constant *TypeNameField;
|
||||||
|
|
||||||
// If we're supposed to demote the visibility, be sure to set a flag
|
// If we're supposed to demote the visibility, be sure to set a flag
|
||||||
// to use a string comparison for type_info comparisons.
|
// to use a string comparison for type_info comparisons.
|
||||||
ItaniumCXXABI::RTTIUniquenessKind RTTIUniqueness =
|
ItaniumCXXABI::RTTIUniquenessKind RTTIUniqueness =
|
||||||
CXXABI.classifyRTTIUniqueness(Ty, NameLinkage);
|
CXXABI.classifyRTTIUniqueness(Ty, Linkage);
|
||||||
if (RTTIUniqueness != ItaniumCXXABI::RUK_Unique) {
|
if (RTTIUniqueness != ItaniumCXXABI::RUK_Unique) {
|
||||||
// The flag is the sign bit, which on ARM64 is defined to be clear
|
// The flag is the sign bit, which on ARM64 is defined to be clear
|
||||||
// for global pointers. This is very ARM64-specific.
|
// for global pointers. This is very ARM64-specific.
|
||||||
|
@ -3208,7 +3204,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
|
||||||
llvm::Module &M = CGM.getModule();
|
llvm::Module &M = CGM.getModule();
|
||||||
llvm::GlobalVariable *GV =
|
llvm::GlobalVariable *GV =
|
||||||
new llvm::GlobalVariable(M, Init->getType(),
|
new llvm::GlobalVariable(M, Init->getType(),
|
||||||
/*Constant=*/true, InfoLinkage, Init, Name);
|
/*Constant=*/true, Linkage, Init, Name);
|
||||||
|
|
||||||
// If there's already an old global variable, replace it with the new one.
|
// If there's already an old global variable, replace it with the new one.
|
||||||
if (OldGV) {
|
if (OldGV) {
|
||||||
|
@ -3239,20 +3235,19 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
|
||||||
|
|
||||||
// Give the type_info object and name the formal visibility of the
|
// Give the type_info object and name the formal visibility of the
|
||||||
// type itself.
|
// type itself.
|
||||||
auto computeVisibility = [&](llvm::GlobalValue::LinkageTypes Linkage) {
|
llvm::GlobalValue::VisibilityTypes llvmVisibility;
|
||||||
if (llvm::GlobalValue::isLocalLinkage(Linkage))
|
if (llvm::GlobalValue::isLocalLinkage(Linkage))
|
||||||
// If the linkage is local, only default visibility makes sense.
|
// If the linkage is local, only default visibility makes sense.
|
||||||
return llvm::GlobalValue::DefaultVisibility;
|
llvmVisibility = llvm::GlobalValue::DefaultVisibility;
|
||||||
else if (RTTIUniqueness == ItaniumCXXABI::RUK_NonUniqueHidden)
|
else if (RTTIUniqueness == ItaniumCXXABI::RUK_NonUniqueHidden)
|
||||||
return llvm::GlobalValue::HiddenVisibility;
|
llvmVisibility = llvm::GlobalValue::HiddenVisibility;
|
||||||
else
|
else
|
||||||
return CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
|
llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
|
||||||
};
|
|
||||||
|
|
||||||
TypeName->setVisibility(computeVisibility(NameLinkage));
|
TypeName->setVisibility(llvmVisibility);
|
||||||
CGM.setDSOLocal(TypeName);
|
CGM.setDSOLocal(TypeName);
|
||||||
|
|
||||||
GV->setVisibility(computeVisibility(InfoLinkage));
|
GV->setVisibility(llvmVisibility);
|
||||||
CGM.setDSOLocal(GV);
|
CGM.setDSOLocal(GV);
|
||||||
|
|
||||||
if (CGM.getTriple().isWindowsItaniumEnvironment()) {
|
if (CGM.getTriple().isWindowsItaniumEnvironment()) {
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | \
|
// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-BOTH
|
||||||
// RUN: FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-BOTH \
|
// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITH-HIDDEN -check-prefix=CHECK-BOTH %s
|
||||||
// RUN: -DLINKONCE_VIS_CONSTANT='linkonce_odr constant'
|
|
||||||
// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | \
|
|
||||||
// RUN: FileCheck %s -check-prefix=CHECK-WITH-HIDDEN -check-prefix=CHECK-BOTH \
|
|
||||||
// RUN: -DLINKONCE_VIS_CONSTANT='linkonce_odr hidden constant'
|
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
// CHECK-BOTH: _ZTSP1C = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSP1C = internal constant
|
||||||
// CHECK-BOTH: _ZTS1C = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTS1C = internal constant
|
||||||
// CHECK-BOTH: _ZTI1C = internal constant
|
// CHECK-BOTH: _ZTI1C = internal constant
|
||||||
// CHECK-BOTH: _ZTIP1C = internal constant
|
// CHECK-BOTH: _ZTIP1C = internal constant
|
||||||
// CHECK-BOTH: _ZTSPP1C = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSPP1C = internal constant
|
||||||
// CHECK-BOTH: _ZTIPP1C = internal constant
|
// CHECK-BOTH: _ZTIPP1C = internal constant
|
||||||
// CHECK-BOTH: _ZTSM1Ci = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSM1Ci = internal constant
|
||||||
// CHECK-BOTH: _ZTIM1Ci = internal constant
|
// CHECK-BOTH: _ZTIM1Ci = internal constant
|
||||||
// CHECK-BOTH: _ZTSPM1Ci = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSPM1Ci = internal constant
|
||||||
// CHECK-BOTH: _ZTIPM1Ci = internal constant
|
// CHECK-BOTH: _ZTIPM1Ci = internal constant
|
||||||
// CHECK-BOTH: _ZTSM1CS_ = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSM1CS_ = internal constant
|
||||||
// CHECK-BOTH: _ZTIM1CS_ = internal constant
|
// CHECK-BOTH: _ZTIM1CS_ = internal constant
|
||||||
// CHECK-BOTH: _ZTSM1CPS_ = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSM1CPS_ = internal constant
|
||||||
// CHECK-BOTH: _ZTIM1CPS_ = internal constant
|
// CHECK-BOTH: _ZTIM1CPS_ = internal constant
|
||||||
// CHECK-BOTH: _ZTSM1A1C = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSM1A1C = internal constant
|
||||||
// CHECK-BOTH: _ZTS1A = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK: _ZTS1A = linkonce_odr constant
|
||||||
// CHECK-BOTH: _ZTI1A = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-WITH-HIDDEN: _ZTS1A = linkonce_odr hidden constant
|
||||||
|
// CHECK: _ZTI1A = linkonce_odr constant
|
||||||
|
// CHECK-WITH-HIDDEN: _ZTI1A = linkonce_odr hidden constant
|
||||||
// CHECK-BOTH: _ZTIM1A1C = internal constant
|
// CHECK-BOTH: _ZTIM1A1C = internal constant
|
||||||
// CHECK-BOTH: _ZTSM1AP1C = [[LINKONCE_VIS_CONSTANT]]
|
// CHECK-BOTH: _ZTSM1AP1C = internal constant
|
||||||
// CHECK-BOTH: _ZTIM1AP1C = internal constant
|
// CHECK-BOTH: _ZTIM1AP1C = internal constant
|
||||||
|
|
||||||
// CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
|
// CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
|
||||||
|
@ -54,12 +52,6 @@
|
||||||
// CHECK: _ZTSFvvE = linkonce_odr constant
|
// CHECK: _ZTSFvvE = linkonce_odr constant
|
||||||
// CHECK: _ZTIFvvE = linkonce_odr constant
|
// CHECK: _ZTIFvvE = linkonce_odr constant
|
||||||
// CHECK: _ZTIPFvvE = linkonce_odr constant
|
// CHECK: _ZTIPFvvE = linkonce_odr constant
|
||||||
// CHECK: _ZTSPN12_GLOBAL__N_12DIE = internal constant
|
|
||||||
// CHECK: _ZTSN12_GLOBAL__N_12DIE = internal constant
|
|
||||||
// CHECK: _ZTIN12_GLOBAL__N_12DIE = internal constant
|
|
||||||
// CHECK: _ZTIPN12_GLOBAL__N_12DIE = internal constant
|
|
||||||
// CHECK: _ZTSMN12_GLOBAL__N_12DIEFvvE = internal constant
|
|
||||||
// CHECK: _ZTIMN12_GLOBAL__N_12DIEFvvE = internal constant
|
|
||||||
// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
|
// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
|
||||||
// CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant
|
// CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant
|
||||||
// CHECK: _ZTSA10_i = linkonce_odr constant
|
// CHECK: _ZTSA10_i = linkonce_odr constant
|
||||||
|
@ -107,10 +99,9 @@ void t1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// D and DI are inside an anonymous namespace, so all type information related
|
// D is inside an anonymous namespace, so all type information related to D should have
|
||||||
// to both should have internal linkage.
|
// internal linkage.
|
||||||
struct D { };
|
struct D { };
|
||||||
struct DI;
|
|
||||||
|
|
||||||
// E is also inside an anonymous namespace.
|
// E is also inside an anonymous namespace.
|
||||||
enum E { };
|
enum E { };
|
||||||
|
@ -136,9 +127,6 @@ const std::type_info &t2() {
|
||||||
// internal linkage.
|
// internal linkage.
|
||||||
(void)typeid(void (*)() throw (D));
|
(void)typeid(void (*)() throw (D));
|
||||||
|
|
||||||
(void)typeid(DI *);
|
|
||||||
(void)typeid(void (DI::*)());
|
|
||||||
|
|
||||||
(void)typeid(E);
|
(void)typeid(E);
|
||||||
|
|
||||||
return typeid(getD());
|
return typeid(getD());
|
||||||
|
|
Loading…
Reference in New Issue