-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Generic metadata prespecialization: enums #29345
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
Generic metadata prespecialization: enums #29345
Conversation
@swift-ci please smoke test |
@swift-ci please test windows platform |
lib/IRGen/GenMeta.cpp
Outdated
@@ -3789,10 +3806,34 @@ namespace { | |||
|
|||
return flags; | |||
} | |||
}; | |||
|
|||
// FIXME: Without this template typealias, the following errors are produced |
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.
Interesting, is there a radar for this?
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.
Unfortunately, I wasn't able to minimally recreate the problem, but rdar://problem/58884416 covers this.
@@ -684,11 +684,6 @@ bool irgen::isNominalGenericContextTypeMetadataAccessTrivial( | |||
return false; |
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 this is too conservative. nominal.isResilient(..., ResilienceExpansion::Minimal) ignores the module argument and returns true if the module is resilient.
But if its resilient and defined in the same module, you can still pre-specialize it. The resilience means the metadata is opaque across module boundaries, not within the module itself.
I can't comment on unchanged lines in the diff, but about this part:
Can you change this to use the same predicates as the code for emitting witness table references, where it decides if it should reference a witness table directly or call an accessor function? I think |
|
||
// CHECK: @"$s4main5ValueOySiGWV" = linkonce_odr hidden constant %swift.enum_vwtable { i8* bitcast ({{(%swift.opaque\* \(\[[0-9]+ x i8\]\*, \[[0-9]+ x i8\]\*, %swift.type\*\)\* @"\$[a-zA-Z0-9_]+" to i8\*|i8\* \(i8\*, i8\*, %swift.type\*\)\* @__swift_memcpy[0-9]+_[0-9]+ to i8\*)}}), i8* bitcast (void (i8*, %swift.type*)* @__swift_noop_void_return to i8*), i8* bitcast (i8* (i8*, i8*, %swift.type*)* @__swift_memcpy{{[0-9]+}}_{{[0-9]+}} to i8*), i8* bitcast (i8* (i8*, i8*, %swift.type*)* @__swift_memcpy{{[0-9]+}}_{{[0-9]+}} to i8*), i8* bitcast (i8* (i8*, i8*, %swift.type*)* @__swift_memcpy{{[0-9]+}}_{{[0-9]+}} to i8*), i8* bitcast (i8* (i8*, i8*, %swift.type*)* @__swift_memcpy{{[0-9]+}}_{{[0-9]+}} to i8*), i8* bitcast (i32 (%swift.opaque*, i32, %swift.type*)* @"$s4main5ValueOySiGwet" to i8*), i8* bitcast (void (%swift.opaque*, i32, i32, %swift.type*)* @"$s4main5ValueOySiGwst" to i8*), [[INT]] [[ALIGNMENT]], [[INT]] [[ALIGNMENT]], i32 {{[0-9]+}}, i32 0, i8* bitcast (i32 (%swift.opaque*, %swift.type*)* @"$s4main5ValueOySiGwug" to i8*), i8* bitcast (void (%swift.opaque*, %swift.type*)* @"$s4main5ValueOySiGwup" to i8*), i8* bitcast (void (%swift.opaque*, i32, %swift.type*)* @"$s4main5ValueOySiGwui" to i8*) }, align [[ALIGNMENT]] | ||
// CHECK: @"$s4main5ValueOySiGMf" = internal constant <{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i64 }> <{ i8** getelementptr inbounds (%swift.enum_vwtable, %swift.enum_vwtable* @"$s4main5ValueOySiGWV", i32 0, i32 0), [[INT]] 513, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5ValueOMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i64 3 }>, align [[ALIGNMENT]] | ||
enum Value<First> { |
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.
Can you add some tests that use protocol conformances, both the supported and unsupported cases?
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, I'm in the process of writing more.
a745581
to
7e8d20c
Compare
@swift-ci please test |
Build failed |
Build failed |
7e8d20c
to
568d6da
Compare
@swift-ci please test linux platform |
@swift-ci please test windows platform |
Build failed |
@swift-ci please clean test linux platform |
@swift-ci please clean test windows platform |
Build failed |
568d6da
to
a8b7f6c
Compare
@swift-ci please clean test linux platform |
1 similar comment
@swift-ci please clean test linux platform |
Build failed |
@slavapestov, thanks for pointing me at that! Is this along the lines of what you have in mind? b716235 |
a8b7f6c
to
40bc9fe
Compare
@swift-ci please test |
Build failed |
Build failed |
f554099
to
324f52a
Compare
Build failed |
cca4be0
to
63cd291
Compare
@swift-ci please test |
@swift-ci please test windows platform |
Build failed |
Build failed |
d957ebd
to
521d8cb
Compare
@swift-ci please test |
@swift-ci please test windows platform |
Build failed |
Build failed |
Extracted implementation of SpecializedGenericStructMetadataBuilder into SpecializedGenericNominalMetadataBuilderBase, a CRTP with a template template argument for the CRTP superclass and a template argument for the implementation. That new type is now subclassed by SpecializedGenericStructMetadataBuilder. Additionally, this new type is also subclassed by the newly added SpecializedGenericEnumMetadataBuilder which is responsible for build the prespecialization of generic enum metadata. rdar://problem/56960887
07954ac
to
76eaa6d
Compare
@swift-ci please test |
@swift-ci please test windows platform |
Build failed |
Build failed |
76eaa6d
to
a2e5db2
Compare
@swift-ci please test |
Build failed |
Build failed |
When a specialized usage of a generic enum occurs in the same module where the enum was defined, directly reference the prespecialized metadata. rdar://problem/56994321
a2e5db2
to
40e17d9
Compare
@swift-ci please test |
Build failed |
Build failed |
Continuing the work started in #28610 , prespecializes generic metadata for enums under limited circumstances. Specifically, prespecialization only occurs for usages within the same module where the type itself is defined and for specializations all of whose type arguments are themselves concrete types.