Skip to content

Guaranteed ownership transforming terminators #10759

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

@gottesmm gottesmm commented Jul 5, 2017

This PR teaches the ownership-verifier how to handle guaranteed arguments with values provided by a switch_enum or a checked_cast_br.

The specific properties that the verifier checks is that the argument's ownership kind is the same as the ownership of the terminators argument. For the owned case, we verify the users of the argument separately from the users of the operand. But in the case of guaranteed parameters, we add the end_borrow_argument instruction of the guaranteed argument to the "must live" set of the terminator's operand. This means that the guaranteed value must live as long as the argument does implying that all uses of the guaranteed argument must be within that liveness region.

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 5, 2017

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 5, 2017

Messed up. This is going to fail. 1 sec.

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 5, 2017

Interesting. Turns out if you forget to end a borrow, the error is that you are leaking. I think I can improve that error.

gottesmm added 2 commits July 5, 2017 01:07
This is needed to ensure that SILGenPattern propagates values at +0 instead of
+1.

I also improved our handling of terminators in general when it comes to having
"borrowed" arguments. The basic verification requirement is that the
end_borrow_argument is treated as a use of the parent borrow. This ensures that
the borrowed argument can not extend the lifetime of the borrowed value without
the verifier triggering.

rdar://31880847
@gottesmm gottesmm force-pushed the guaranteed_ownership_transforming_terminators branch from fe00037 to 69393d5 Compare July 5, 2017 08:20
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 5, 2017

@swift-ci smoke test and merge

1 similar comment
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 5, 2017

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 3ccc69a into swiftlang:master Jul 5, 2017
@gottesmm gottesmm deleted the guaranteed_ownership_transforming_terminators branch July 5, 2017 08:57
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