-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: Note use of types in conditional requirements of protocol conformances #32213
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
IRGen: Note use of types in conditional requirements of protocol conformances #32213
Conversation
@swift-ci Please test |
lib/IRGen/GenProto.cpp
Outdated
@@ -2114,6 +2114,46 @@ static bool isConstantWitnessTable(SILWitnessTable *wt) { | |||
return true; | |||
} | |||
|
|||
static void noteUseOfTypeMetadataInConditionalRequirements( |
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.
Why isn't this handled by emitting those mangled names in the witness table?
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 is the witness table:
private enum E {
}
private protocol P {
associatedtype AT
}
private struct S<A, B> {
init()
}
extension S : P where A == E {
typealias AT = B
}
sil_witness_table private <A, B where A == E> S<A, B>: P module ProtoCrash {
associated_type AT: B
}
Which mangled names are you referring to?
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.
Here is the ordering of code:
// Emit the module contents.
irgen.emitGlobalTopLevel(linkerDirectives);
...
// Okay, emit any definitions that we suddenly need.
irgen.emitLazyDefinitions();
// Register our info with the runtime if needed.
if (Opts.UseJIT) {
IGM.emitBuiltinReflectionMetadata();
IGM.emitRuntimeRegistration();
} else {
// Emit protocol conformances into a section we can recognize at runtime.
// In JIT mode these are manually registered above.
IGM.emitSwiftProtocols();
IGM.emitProtocolConformances();
IGM.emitProtocolConformances will create typerefs (which note the use of type metadata) but this is too late because we already have emitted the lazy metadata definitions.
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.
Does it work if you emit the lazy definitions after protocol conformances?
We might need a loop to pump this until it stops adding new lazy definitions. I'm thinking of a case where emitting conditional requirements triggers lazy metadata emission, which triggers emitting another witness table, and so on.
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 moved emission of individual protocol conformances into witness table emission which happens before emitting lazy definitions (and as part of lazy definition emission).
Build failed |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test windows |
@swift-ci Please test source compatibility |
It is possible that the only mention of metadata happens as part of protocol conformannce emission. This ordering makes sure we emit this metadata. SR-12891 rdar://63819461
d4ae4a7
to
7997183
Compare
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test |
@swift-ci Please test |
Build failed |
Build failed |
It is possible for the only mention of a conditional requirement to appear in
the protocol conformance record which is too late for lazy metadata type
emission.
SR-12891
rdar://63819461