End lifetime and deallocating deinits #7858
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains two commits:
b4923b2. This commit adds a new SIL instruction called end_lifetime. It is the destroying use equivalent of fix_lifetime. Its intent is to enable SILGen to in certain cases lie about ownership to the verifier to fix some corner cases. It is eliminated when the ownership model eliminator runs.
0e89d6e. This uses end_lifetime to special case the lifetime of self in destructors. Specifically:
a. Self is passed into deallocating deinits at +1.
b. Destroying deinits take in self as a +0 value that is then returned at +1.
This means that the lifetime of self can not be modeled statically in a
deallocating deinit without analyzing the body of the destroying deinit
(something that violates semantic sil). Thus we add an artifical destroy of
self before the actual destroy of self so that the verifier can understand
that self is being properly balanced.
rdar://29791263