Skip to content

6.0: [SILCombine] Handle indirect error in apply(convert_function). #73424

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

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented May 3, 2024

Explanation: Fix a compiler crash caused by misoptimizing certain applies.

Typed throws involves returning errors indirectly on throwing paths. There is a simplification performed by SILCombine for applys whose operand is a convert_function. Among other things, it creates unchecked_addr_casts of the indirect results and parameters. It does this by iterating over all the operands of the apply. In the case of a function with an @indirect_error result, that result appears in the operand list. This simplification was not accounting for it, however. So both incorrect casts and an invalid apply were created.

Here, this is fixed by iterating over the indirect error as well.

Scope: Affects code using typed throws such as via stdlib calls.
Issue:rdar://127468646
Original PR: #73408
Risk: Low. Adds handling for indirect errors in a instruction simplification that already handles other indirect returns.
Testing: Added regression test.
Reviewer: Andrew Trick ( @atrick )

Some clients need to access their parent transformation.
Previously, only the indirect results and the parameters were handled.
However, the indirect error doesn't show up in the list of indirect
results (or in the list of parameters).  But it sure does show up in the
list of arguments.  Here, that argument too is handled.

rdar://127452206
@nate-chandler nate-chandler requested a review from a team as a code owner May 3, 2024 19:00
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler requested a review from tbkka May 3, 2024 19:45
@nate-chandler nate-chandler enabled auto-merge May 4, 2024 20:15
@nate-chandler nate-chandler merged commit 5c3ec6b into swiftlang:release/6.0 May 6, 2024
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar127452206 branch May 6, 2024 15:38
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