Skip to content

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

Merged

Conversation

slavapestov
Copy link
Contributor

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.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

Copy link
Member

@compnerd compnerd left a 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.

@@ -1355,6 +1357,36 @@ createErrorExistentialTypeInfo(IRGenModule &IGM,
refcounting);
}

llvm::Type *TypeConverter::getExistentialType(unsigned numWitnessTables) {
auto &type = OpaqueExistentialTypes[numWitnessTables];
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@compnerd
Copy link
Member

@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>.
@slavapestov slavapestov force-pushed the outlined-existential-operations-fix branch from 3495f2d to bc1aa97 Compare September 10, 2019 18:01
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test Windows platform

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test Windows platform

@slavapestov slavapestov merged commit 9748a5a into swiftlang:master Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants