-
Notifications
You must be signed in to change notification settings - Fork 10.5k
embedded: fix specialization of associated conformance entries in witness tables #79908
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
embedded: fix specialization of associated conformance entries in witness tables #79908
Conversation
… in a release-built compiler
…ness tables When creating a specialized witness table, we need to get the right specialized conformance. In IRGen don't emit associated conformance witness table entries if the protocol is not a class protocol. In this case the associated type can never be used to create an existential. Therefore such a witness table entry is never used at runtime in embedded swift. Fixes a compiler crash rdar://146448091
@swift-ci smoke test |
@@ -959,6 +959,13 @@ namespace { | |||
} | |||
|
|||
void addAssociatedConformance(const AssociatedConformance &req) { | |||
if (req.getAssociation()->getASTContext().LangOpts.hasFeature(Feature::Embedded) && |
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.
It might be better to push this check up to SILWitnessVisitor, which already includes this check for example:
// ObjC protocols do not have witnesses.
if (!Lowering::TypeConverter::protocolRequiresWitnessTable(requirement))
continue;
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 will not work because the FragileWitnessTableBuilder needs to pull the witness table entry before returning.
@@ -1775,7 +1790,10 @@ class AccessorConformanceInfo : public ConformanceInfo { | |||
if (IGM.Context.LangOpts.hasFeature(Feature::Embedded)) { | |||
// In Embedded Swift associated-conformance entries simply point to the witness table | |||
// of the associated conformance. | |||
llvm::Constant *witnessEntry = IGM.getAddrOfWitnessTable(associatedConformance.getConcrete()); | |||
ProtocolConformanceRef assocConf = |
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.
Is it possible for assocConf to differ from associatedConformance above?
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.
Yes, because ConformanceInContext
is not the same as SILWT->getConformance()
.
(I tried that first and it didn't work).
@@ -3734,7 +3752,7 @@ llvm::Value *irgen::emitWitnessTableRef(IRGenFunction &IGF, | |||
|
|||
// In Embedded Swift, only class-bound wtables are allowed. | |||
if (srcType->getASTContext().LangOpts.hasFeature(Feature::Embedded)) { |
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.
IGF.IGM.Context
is cleaner IMO
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.
agreed. I will change it next time I work on this code
When creating a specialized witness table, we need to get the right specialized conformance.
In IRGen don't emit associated conformance witness table entries if the protocol is not a class protocol.
In this case the associated type can never be used to create an existential. Therefore such a witness table entry is never used at runtime in embedded swift.
Fixes a compiler crash
rdar://146448091