-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Tiny bit more progress on IRGen support for subclass existentials #8788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19eb8d2
497336c
6580e50
61e0c55
ff20d06
ea01582
2cd6a03
03373a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,32 +277,28 @@ llvm::Value *irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, | |
const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) { | ||
assert(isExemplarArchetype(archetype) && "lowering non-exemplary archetype"); | ||
|
||
LayoutConstraint LayoutInfo = archetype->getLayoutConstraint(); | ||
auto layout = archetype->getLayoutConstraint(); | ||
|
||
// If the archetype is class-constrained, use a class pointer | ||
// representation. | ||
if (archetype->requiresClass() || | ||
(LayoutInfo && LayoutInfo->isRefCounted())) { | ||
ReferenceCounting refcount; | ||
llvm::PointerType *reprTy; | ||
(layout && layout->isRefCounted())) { | ||
auto refcount = getReferenceCountingForType(IGM, CanType(archetype)); | ||
|
||
if (!IGM.ObjCInterop) { | ||
refcount = ReferenceCounting::Native; | ||
reprTy = IGM.RefCountedPtrTy; | ||
} else { | ||
refcount = ReferenceCounting::Unknown; | ||
reprTy = IGM.UnknownRefCountedPtrTy; | ||
} | ||
llvm::PointerType *reprTy; | ||
|
||
// If the archetype has a superclass constraint, it has at least the | ||
// retain semantics of its superclass, and it can be represented with | ||
// the supertype's pointer type. | ||
if (Type super = archetype->getSuperclass()) { | ||
ClassDecl *superClass = super->getClassOrBoundGenericClass(); | ||
refcount = getReferenceCountingForClass(IGM, superClass); | ||
|
||
if (auto super = archetype->getSuperclass()) { | ||
auto &superTI = IGM.getTypeInfoForUnlowered(super); | ||
reprTy = cast<llvm::PointerType>(superTI.StorageType); | ||
} else { | ||
if (refcount == ReferenceCounting::Native) { | ||
reprTy = IGM.RefCountedPtrTy; | ||
} else { | ||
reprTy = IGM.UnknownRefCountedPtrTy; | ||
} | ||
} | ||
|
||
// As a hack, assume class archetypes never have spare bits. There's a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that would work and be a bit more optimal. If we don't already, we should also check the |
||
|
@@ -320,9 +316,9 @@ const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) { | |
|
||
// If the archetype is trivial fixed-size layout-constrained, use a fixed size | ||
// representation. | ||
if (LayoutInfo && LayoutInfo->isFixedSizeTrivial()) { | ||
Size size(LayoutInfo->getTrivialSizeInBytes()); | ||
Alignment align(LayoutInfo->getTrivialSizeInBytes()); | ||
if (layout && layout->isFixedSizeTrivial()) { | ||
Size size(layout->getTrivialSizeInBytes()); | ||
Alignment align(layout->getTrivialSizeInBytes()); | ||
auto spareBits = | ||
SpareBitVector::getConstant(size.getValueInBits(), false); | ||
// Get an integer type of the required size. | ||
|
@@ -336,7 +332,7 @@ const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) { | |
// If the archetype is a trivial layout-constrained, use a POD | ||
// representation. This type is not loadable, but it is known | ||
// to be a POD. | ||
if (LayoutInfo && LayoutInfo->isAddressOnlyTrivial()) { | ||
if (layout && layout->isAddressOnlyTrivial()) { | ||
// TODO: Create NonFixedSizeArchetypeTypeInfo and return it. | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion isn't valid; this code runs even when type-checking fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a test case in mind I can try? I'll address this in an upcoming patch along with the other stuff above about spare bits.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think even just the obvious thing would crash: