summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-01-16 19:23:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-01-16 19:23:42 +0000
commit654542a5ed9063a48f952a2f18e4a692aa3b54dc (patch)
tree25b1d2d812ba440c6c9ba41d3eb36b2a75271de5 /clang/lib/CodeGen/MicrosoftCXXABI.cpp
parent100f8f60c396ffc6cf5beac64b55e157dd6d22ed (diff)
downloadbcm5719-llvm-654542a5ed9063a48f952a2f18e4a692aa3b54dc.tar.gz
bcm5719-llvm-654542a5ed9063a48f952a2f18e4a692aa3b54dc.zip
Add comdats to the RTTI variables in the microsoft abi.
llvm-svn: 226303
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 7fe5ec5a738..1402b5263b6 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2856,6 +2856,8 @@ llvm::GlobalVariable *MSRTTIBuilder::getClassHierarchyDescriptor() {
auto CHD = new llvm::GlobalVariable(Module, Type, /*Constant=*/true, Linkage,
/*Initializer=*/nullptr,
MangledName.c_str());
+ if (CHD->isWeakForLinker())
+ CHD->setComdat(CGM.getModule().getOrInsertComdat(CHD->getName()));
// Initialize the base class ClassHierarchyDescriptor.
llvm::Constant *Fields[] = {
@@ -2889,6 +2891,8 @@ MSRTTIBuilder::getBaseClassArray(SmallVectorImpl<MSRTTIClass> &Classes) {
auto *BCA = new llvm::GlobalVariable(
Module, ArrType,
/*Constant=*/true, Linkage, /*Initializer=*/nullptr, MangledName.c_str());
+ if (BCA->isWeakForLinker())
+ BCA->setComdat(CGM.getModule().getOrInsertComdat(BCA->getName()));
// Initialize the BaseClassArray.
SmallVector<llvm::Constant *, 8> BaseClassArrayData;
@@ -2929,6 +2933,8 @@ MSRTTIBuilder::getBaseClassDescriptor(const MSRTTIClass &Class) {
auto BCD = new llvm::GlobalVariable(Module, Type, /*Constant=*/true, Linkage,
/*Initializer=*/nullptr,
MangledName.c_str());
+ if (BCD->isWeakForLinker())
+ BCD->setComdat(CGM.getModule().getOrInsertComdat(BCD->getName()));
// Initialize the BaseClassDescriptor.
llvm::Constant *Fields[] = {
@@ -2988,6 +2994,8 @@ MSRTTIBuilder::getCompleteObjectLocator(const VPtrInfo *Info) {
if (!ABI.isImageRelative())
FieldsRef = FieldsRef.drop_back();
COL->setInitializer(llvm::ConstantStruct::get(Type, FieldsRef));
+ if (COL->isWeakForLinker())
+ COL->setComdat(CGM.getModule().getOrInsertComdat(COL->getName()));
return COL;
}
@@ -3019,13 +3027,14 @@ llvm::Constant *MicrosoftCXXABI::getAddrOfRTTIDescriptor(QualType Type) {
llvm::ConstantDataArray::getString(CGM.getLLVMContext(), TypeInfoString)};
llvm::StructType *TypeDescriptorType =
getTypeDescriptorType(TypeInfoString);
- return llvm::ConstantExpr::getBitCast(
- new llvm::GlobalVariable(
- CGM.getModule(), TypeDescriptorType, /*Constant=*/false,
- getLinkageForRTTI(Type),
- llvm::ConstantStruct::get(TypeDescriptorType, Fields),
- MangledName.c_str()),
- CGM.Int8PtrTy);
+ auto *Var = new llvm::GlobalVariable(
+ CGM.getModule(), TypeDescriptorType, /*Constant=*/false,
+ getLinkageForRTTI(Type),
+ llvm::ConstantStruct::get(TypeDescriptorType, Fields),
+ MangledName.c_str());
+ if (Var->isWeakForLinker())
+ Var->setComdat(CGM.getModule().getOrInsertComdat(Var->getName()));
+ return llvm::ConstantExpr::getBitCast(Var, CGM.Int8PtrTy);
}
/// \brief Gets or a creates a Microsoft CompleteObjectLocator.
OpenPOWER on IntegriCloud