Skip to content

[5.9] SILCombine: correctly set the [stack] flag when replacing alloc_ref_dynamic with alloc_ref #66816

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

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

eeckstein
Copy link
Contributor

  • Explanation: This is a fix for a SIL verifier crash. When optimizing alloc_ref_dynamic instructions in SILCombine, the [stack] attribute was not set correctly. Beside a verifier crash, this also results in a memory leak in the compiled code (if the verifier is disabled, like in no-assert compiler builds). Interestingly, this bug is in the compiler since 7 years. It's surprising that it didn't show up earlier.

  • Scope: Although the alloc_ref_dynamic instruction is used in the stdlib's array and dictionary code, it is obviously very rare that this optimizer bug really shows up.

  • Issue: SIL verification failure when evaluating $0 in certain closures. #66312

  • Risk: Low. The change is small. Some variants of the peephole optimization are disabled now in case of an alloc_ref_dynamic [stack]. In the remaining cases, the [stack] attribute is set correctly. These are the cases where the verifier would have crashed before.

  • Testing: With a regression test

  • Reviewer: @nate-chandler

  • Main branch PR: SILCombine: correctly set the [stack] flag when replacing alloc_ref_dynamic with alloc_ref #66800

…f_dynamic` with `alloc_ref`

Fixes a verifier crash.

swiftlang#66312
@eeckstein eeckstein requested a review from a team as a code owner June 21, 2023 17:57
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit e018d48 into swiftlang:release/5.9 Jun 22, 2023
@eeckstein eeckstein deleted the fix-allocref-combine-5.9 branch June 22, 2023 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants