Skip to content

[silgen] When emitting a top level error, destroy the error after we … #20033

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

Conversation

gottesmm
Copy link
Contributor

…have logged it.

This is not strictly necessary since we are going to be exiting the program, but
the ownership verifier thinks that the error is leaked otherwise.

rdar://29791263

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@jrose-apple
Copy link
Contributor

Can we put the destroy after the call to errorInMain? Or make errorInMain return Never?

@gottesmm
Copy link
Contributor Author

@jrose-apple the destroy is after the call to errorInMain... This is an error path so I am not sure if it is worth optimizing out the destroy. That being said, I could use an end_lifetime and we could just leak it using that.

@jrose-apple
Copy link
Contributor

Oops, not sure how I misread that! Okay, so we're not paying the run time cost…but we might still be paying in code size.

@gottesmm
Copy link
Contributor Author

Ok. I can make that change. I don't think the code-size impact is large... but why not save some if we can.

…r we have logged it.

This is not strictly necessary since we are going to be exiting the program, but
the ownership verifier thinks that the error is leaked otherwise. By using the
end_lifetime we avoid having a small increase in code-size since it is a no-op
after ownership is removed.

rdar://29791263
@gottesmm gottesmm force-pushed the pr-aef61f8fa8d192698e4fe42ceef1bc68d72337e8 branch from 5996adf to 88979f9 Compare October 26, 2018 01:34
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

4 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test os x platform

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test os x platform

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Can we encode that the program is ending in SIL somehow instead?

@gottesmm
Copy link
Contributor Author

@jckarter That feels like a larger design question to me. I think the simplest way that one could do that is to have a privileged return value. But I think we would need to discuss that and I am not sure if that should hold up this PR.

@gottesmm
Copy link
Contributor Author

I talked with @jckarter offline. He is ok with my merging this and filing an SR with his enhancement proposal. It is here: https://bugs.swift.org/browse/SR-9114.

@gottesmm gottesmm merged commit f8e2723 into swiftlang:master Oct 29, 2018
@gottesmm gottesmm deleted the pr-aef61f8fa8d192698e4fe42ceef1bc68d72337e8 branch October 29, 2018 21:39
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.

3 participants