-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: Clean up types of outlined existential buffer operations #27101
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: Clean up types of outlined existential buffer operations #27101
Conversation
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
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 feel like IGM should have a utility function like GetOpaqueExistentialBufferAddress
that will construct the bitcast properly (or perhaps have a type constructor) since the pattern repeats so often. Doing that in a follow up is fine.
lib/IRGen/GenExistential.cpp
Outdated
@@ -1355,6 +1357,36 @@ createErrorExistentialTypeInfo(IRGenModule &IGM, | |||
refcounting); | |||
} | |||
|
|||
llvm::Type *TypeConverter::getExistentialType(unsigned numWitnessTables) { | |||
auto &type = OpaqueExistentialTypes[numWitnessTables]; |
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.
Could you please use the explicit type here. The reference makes this confusing - the reference indicates that the value is non-null, and the type check on the next line doesn't make sense until you realise that the value that you have a reference to is a pointer.
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.
Done.
@swift-ci please test Windows platform |
The uniquing key for these was just the number of witness tables, but the function itself referenced the specific existential type it was instantiated with. Everything still worked because getOrCreateHelperFunction() would bitcast an existing function to the correct type, and in practice the layout of an existential type only depends on the number of witness tables. However on master-next, other changes were made that stripped off the bitcasts. This would result in assertions or LLVM verifier failures when multiple existential types were used in a single translation unit. Fixes <rdar://problem/54780404>.
3495f2d
to
bc1aa97
Compare
@swift-ci Please smoke test |
@swift-ci Please test Windows platform |
1 similar comment
@swift-ci Please test Windows platform |
The uniquing key for these was just the number of witness tables,
but the function itself referenced the specific existential type
it was instantiated with.
Everything still worked because getOrCreateHelperFunction() would
bitcast an existing function to the correct type, and in practice
the layout of an existential type only depends on the number of
witness tables.
However on master-next, other changes were made that stripped
off the bitcasts. This would result in assertions or LLVM
verifier failures when multiple existential types were used in
a single translation unit.
Fixes rdar://problem/54780404.