Skip to content

Preliminary SILGen support for address-only typed throws #69430

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
merged 6 commits into from
Oct 28, 2023

Conversation

slavapestov
Copy link
Contributor

If the thrown error type is address-only, our function type has an indirect error result. Handle this in type lowering and SILGen prolog/epilog emission.

Next steps are introducing a zero-operand throw_addr instruction to exit out of a block after initializing the thrown error result, and setting up a stack-allocated box to receive the indirect error result from a try_apply, all the conversions and re-abstraction support, etc.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

AbstractionPattern::getErrorConvention(TypeConverter &TC) const {
// Tuples should be destructured.
if (isTuple()) {
return Destructured;
Copy link
Member

Choose a reason for hiding this comment

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

We ban tuple types from being thrown up in the type checker now, and even if we allowed them there... I think we'd still pass them indirectly here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I’ll remove this. It was just a copy and paste

@@ -713,6 +713,15 @@ bool SILModuleConventions::isPassedIndirectlyInSIL(SILType type, SILModule &M) {
return false;
}

bool SILModuleConventions::isThrownIndirectlyInSIL(SILType type, SILModule &M) {
if (SILModuleConventions(M).loweredAddresses) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (SILModuleConventions(M).loweredAddresses) {
if (SILModuleConventions(M).useLoweredAddresses()) {

@slavapestov slavapestov force-pushed the silgen-typed-throws-wip branch from 52d69a9 to 581776b Compare October 27, 2023 21:38
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

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