[silgen] Add a doxygen doc above FormalEvaluationScope. #8118
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.
[silgen] Add a doxygen doc above FormalEvaluationScope.
I added a general description, but more importantly, I added a note about a
quirk in our current implementation that existed before my current changes.
Specifically:
All formal access contain a pointer to a cleanup in the normal cleanup
stack. This is to ensure that when SILGen calls Cleanups.emitBranchAndCleanups
(and other special cleanup code along error edges), writebacks are properly
created. What is key to notice is that all of these cleanup emission types are
non-destructive. Contrast this with normal scope popping. In such a case, the
scope pop is destructive. This means that any pointers from the formal access to
the cleanup stack is now invalid.
rdar://30955427
As a side note, in a future PR I am going to add some asserts so that if this issue comes up, we blow up when creating the formal access, rather than when we pop the formal evaluation scope. It makes it easier to solve these problems.
Perhaps, we should consider completely splitting these stacks... Hmmm...