Skip to content

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jul 31, 2024

Explanation: [region-isolation] Fix handling of coroutine apply results.

In this part of the code, we are attempting to merge all of the operands into
the same region and then assigning all non-Sendable results of the function to
that same region. The problem that was occuring here was a thinko due to the
control flow of the code here not separating nicely the case of whether or not
we had operands or not. Previously this did not matter, since we just used the
first result in such a case... but since we changed to assign to the first
operand element in some cases, it matters now. To fix this, I split the confused
logic into two different easy to follow control paths... one if we have operands
and one where we do not have an operand. In the case where we have a first
operand, we merge our elements into its region. If we do not have any operands,
then we just perform one large region assign fresh.

This was not exposed by code that used non-coroutines since in SIL only
coroutines today have multiple results.

Without this change, in such a cases, we will crash.

Radars:

  • rdar://132767643

Original PRs:

Risk: Low. What this change, we only change the behavior specifically for apply like things that have multiple results. Today the only instruction with this property begin_apply, so that is the only case that we could break by accepting this change (that is we could only break the case that is already broken).

gottesmm added 2 commits July 31, 2024 13:03
In this part of the code, we are attempting to merge all of the operands into
the same region and then assigning all non-Sendable results of the function to
that same region. The problem that was occuring here was a thinko due to the
control flow of the code here not separating nicely the case of whether or not
we had operands or not. Previously this did not matter, since we just used the
first result in such a case... but since we changed to assign to the first
operand element in some cases, it matters now. To fix this, I split the confused
logic into two different easy to follow control paths... one if we have operands
and one where we do not have an operand. In the case where we have a first
operand, we merge our elements into its region. If we do not have any operands,
then we just perform one large region assign fresh.

This was not exposed by code that used non-coroutines since in SIL only
coroutines today have multiple results.

rdar://132767643
(cherry picked from commit 541863d)
@gottesmm gottesmm requested a review from a team as a code owner July 31, 2024 20:03
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm enabled auto-merge July 31, 2024 20:04
@gottesmm
Copy link
Contributor Author

Original: #75590

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm merged commit 777dac5 into swiftlang:release/6.0 Aug 1, 2024
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