Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions clang/lib/CodeGen/CGBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,10 +2590,6 @@ const BlockByrefInfo &CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
if (it != BlockByrefInfos.end())
return it->second;

llvm::StructType *byrefType =
llvm::StructType::create(getLLVMContext(),
"struct.__block_byref_" + D->getNameAsString());

QualType Ty = D->getType();

CharUnits size;
Expand Down Expand Up @@ -2658,7 +2654,9 @@ const BlockByrefInfo &CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
}
types.push_back(varTy);

byrefType->setBody(types, packed);
llvm::StructType *byrefType = llvm::StructType::create(
getLLVMContext(), types, "struct.__block_byref_" + D->getNameAsString(),
packed);

BlockByrefInfo info;
info.Type = byrefType;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,8 +1509,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
GetSectionBounds(StringRef Section) {
if (CGM.getTriple().isOSBinFormatCOFF()) {
if (emptyStruct == nullptr) {
emptyStruct = llvm::StructType::create(VMContext, ".objc_section_sentinel");
emptyStruct->setBody({}, /*isPacked*/true);
emptyStruct = llvm::StructType::create(
VMContext, {}, ".objc_section_sentinel", /*isPacked=*/true);
}
auto ZeroInit = llvm::Constant::getNullValue(emptyStruct);
auto Sym = [&](StringRef Prefix, StringRef SecSuffix) {
Expand Down
57 changes: 27 additions & 30 deletions clang/lib/CodeGen/CGObjCMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5835,15 +5835,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
// struct _objc_protocol_extension *
ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(ProtocolExtensionTy);

// Handle recursive construction of Protocol and ProtocolList types

ProtocolTy =
llvm::StructType::create(VMContext, "struct._objc_protocol");

ProtocolListTy =
llvm::StructType::create(VMContext, "struct._objc_protocol_list");
ProtocolListTy->setBody(llvm::PointerType::getUnqual(ProtocolListTy), LongTy,
llvm::ArrayType::get(ProtocolTy, 0));
// Handle construction of Protocol and ProtocolList types

// struct _objc_protocol {
// struct _objc_protocol_extension *isa;
Expand All @@ -5852,9 +5844,16 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
// struct _objc_method_description_list *instance_methods;
// struct _objc_method_description_list *class_methods;
// }
ProtocolTy->setBody(ProtocolExtensionPtrTy, Int8PtrTy,
llvm::PointerType::getUnqual(ProtocolListTy),
MethodDescriptionListPtrTy, MethodDescriptionListPtrTy);
ProtocolTy = llvm::StructType::create(
{ProtocolExtensionPtrTy, Int8PtrTy,
llvm::PointerType::getUnqual(VMContext), MethodDescriptionListPtrTy,
MethodDescriptionListPtrTy},
"struct._objc_protocol");

ProtocolListTy =
llvm::StructType::create({llvm::PointerType::getUnqual(VMContext), LongTy,
llvm::ArrayType::get(ProtocolTy, 0)},
"struct._objc_protocol_list");

// struct _objc_protocol_list *
ProtocolListPtrTy = llvm::PointerType::getUnqual(ProtocolListTy);
Expand Down Expand Up @@ -5886,8 +5885,6 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
"struct._objc_class_extension", IntTy, Int8PtrTy, PropertyListPtrTy);
ClassExtensionPtrTy = llvm::PointerType::getUnqual(ClassExtensionTy);

ClassTy = llvm::StructType::create(VMContext, "struct._objc_class");

// struct _objc_class {
// Class isa;
// Class super_class;
Expand All @@ -5902,10 +5899,12 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
// char *ivar_layout;
// struct _objc_class_ext *ext;
// };
ClassTy->setBody(llvm::PointerType::getUnqual(ClassTy),
llvm::PointerType::getUnqual(ClassTy), Int8PtrTy, LongTy,
LongTy, LongTy, IvarListPtrTy, MethodListPtrTy, CachePtrTy,
ProtocolListPtrTy, Int8PtrTy, ClassExtensionPtrTy);
ClassTy = llvm::StructType::create(
{llvm::PointerType::getUnqual(VMContext),
llvm::PointerType::getUnqual(VMContext), Int8PtrTy, LongTy, LongTy,
LongTy, IvarListPtrTy, MethodListPtrTy, CachePtrTy, ProtocolListPtrTy,
Int8PtrTy, ClassExtensionPtrTy},
"struct._objc_class");

ClassPtrTy = llvm::PointerType::getUnqual(ClassTy);

Expand Down Expand Up @@ -5988,13 +5987,9 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// const struct _prop_list_t * class_properties;
// }

// Holder for struct _protocol_list_t *
ProtocolListnfABITy =
llvm::StructType::create(VMContext, "struct._objc_protocol_list");

ProtocolnfABITy = llvm::StructType::create(
"struct._protocol_t", ObjectPtrTy, Int8PtrTy,
llvm::PointerType::getUnqual(ProtocolListnfABITy), MethodListnfABIPtrTy,
llvm::PointerType::getUnqual(VMContext), MethodListnfABIPtrTy,
MethodListnfABIPtrTy, MethodListnfABIPtrTy, MethodListnfABIPtrTy,
PropertyListPtrTy, IntTy, IntTy, Int8PtrPtrTy, Int8PtrTy,
PropertyListPtrTy);
Expand All @@ -6006,8 +6001,9 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// long protocol_count; // Note, this is 32/64 bit
// struct _protocol_t *[protocol_count];
// }
ProtocolListnfABITy->setBody(LongTy,
llvm::ArrayType::get(ProtocolnfABIPtrTy, 0));
ProtocolListnfABITy = llvm::StructType::create(
{LongTy, llvm::ArrayType::get(ProtocolnfABIPtrTy, 0)},
"struct._objc_protocol_list");

// struct _objc_protocol_list*
ProtocolListnfABIPtrTy = llvm::PointerType::getUnqual(ProtocolListnfABITy);
Expand Down Expand Up @@ -6067,11 +6063,12 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// struct class_ro_t *ro;
// }

ClassnfABITy = llvm::StructType::create(VMContext, "struct._class_t");
ClassnfABITy->setBody(llvm::PointerType::getUnqual(ClassnfABITy),
llvm::PointerType::getUnqual(ClassnfABITy), CachePtrTy,
llvm::PointerType::getUnqual(ImpnfABITy),
llvm::PointerType::getUnqual(ClassRonfABITy));
ClassnfABITy = llvm::StructType::create(
{llvm::PointerType::getUnqual(VMContext),
llvm::PointerType::getUnqual(VMContext), CachePtrTy,
llvm::PointerType::getUnqual(ImpnfABITy),
llvm::PointerType::getUnqual(ClassRonfABITy)},
"struct._class_t");

// LLVM for struct _class_t *
ClassnfABIPtrTy = llvm::PointerType::getUnqual(ClassnfABITy);
Expand Down
12 changes: 5 additions & 7 deletions clang/lib/CodeGen/MicrosoftCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,31 +529,29 @@ class MicrosoftCXXABI : public CGCXXABI {
if (ClassHierarchyDescriptorType)
return ClassHierarchyDescriptorType;
// Forward-declare RTTIClassHierarchyDescriptor to break a cycle.
ClassHierarchyDescriptorType = llvm::StructType::create(
CGM.getLLVMContext(), "rtti.ClassHierarchyDescriptor");
llvm::Type *FieldTypes[] = {CGM.IntTy, CGM.IntTy, CGM.IntTy,
getImageRelativeType(CGM.UnqualPtrTy)};
ClassHierarchyDescriptorType->setBody(FieldTypes);
ClassHierarchyDescriptorType =
llvm::StructType::create(FieldTypes, "rtti.ClassHierarchyDescriptor");
return ClassHierarchyDescriptorType;
}

llvm::StructType *getCompleteObjectLocatorType() {
if (CompleteObjectLocatorType)
return CompleteObjectLocatorType;
CompleteObjectLocatorType = llvm::StructType::create(
CGM.getLLVMContext(), "rtti.CompleteObjectLocator");
llvm::Type *FieldTypes[] = {
CGM.IntTy,
CGM.IntTy,
CGM.IntTy,
getImageRelativeType(CGM.Int8PtrTy),
getImageRelativeType(CGM.UnqualPtrTy),
getImageRelativeType(CompleteObjectLocatorType),
getImageRelativeType(CGM.VoidTy),
};
llvm::ArrayRef<llvm::Type *> FieldTypesRef(FieldTypes);
if (!isImageRelative())
FieldTypesRef = FieldTypesRef.drop_back();
CompleteObjectLocatorType->setBody(FieldTypesRef);
CompleteObjectLocatorType =
llvm::StructType::create(FieldTypesRef, "rtti.CompleteObjectLocator");
return CompleteObjectLocatorType;
}

Expand Down
Loading