Repository navigation
-mm=own: a move in a scope released on the unwind leg empties the moved-from slot - #771
Merged
Merged
Conversation
…ed-from slot Under own, `const b = a` (or a value moved out of an await's slot) in the body of a TryOp was "moved here on some paths only": the scope's release in the cleanup landing pad is reached from before the move and after it, and no release can go on an unwind edge (spec 30's edge releases need a branch). On Itanium every function body with a typed `catch` is wrapped in such a TryOp, so on Linux this hit any move at the top level of such a function - DefaultLib's promise.ts (`const awaited = await Promise.all([...])` beside a `try/catch`) failed the v0.0-pre-alpha114 release under own on every ubuntu runner. An explicit `try` body failed on Windows too. The slot of a hoisted owned local starts null (VariableOpLowering) and a release of null does nothing, so the move now stores an empty value into the slot right after it, and the handler's release stays: it frees the value only on the paths that unwind before the move. Only when the read, the taker and rc's retain are in one non-handler block with no call between them, and the taker is not a call (one that may throw having taken the value or not). Test: 00own_move_in_unwound_scope.ts, run under every model, plus an --emit=llvm check for the Windows and Linux triples on any host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The v0.0-pre-alpha114 release (run 42096924048) failed DefaultLib's
promise.tsunder-mm=ownon every ubuntu runner:Not a regression and not await-specific. Under own, a local moved to another one (
const b = a, or the value moved out of an await's slot) in the body of aTryOpis rejected: the scope's release in the cleanup landing pad is reached from before the move and after it, and spec 30's edge releases can't go on an unwind edge. On Itanium every function body that holds a typedcatchis wrapped in such aTryOp, so on Linux any move at the top level of such a function fails. An explicittry { const b = a; ... }failed on Windows too.Fix
A hoisted owned local's slot starts null (VariableOpLowering) and a release of null does nothing. So when the only release a move can't settle is in an exception handler, the move now stores an empty value (
ts.Default) into the moved-from slot right after it and leaves the handler's release in place. That release then frees the value only on paths that unwind before the move. Applied only when the read, the taker and rc's retain are in one non-handler block with no call between them, and the taker isn't a call (a call may throw having taken the value or not). Everything else still gets the existing diagnostic.Tests
00own_move_in_unwound_scope.ts: a move in atrywith throws before and after it, a move beside a typedcatch, an await beside a catch, theawait Promise.all([...])shape, and a throw out of the function after the move. Each runs 1000 times. Registered for compile and JIT, default model and own, and in the rc/none corpus.test-compile-own-move-in-unwound-scope-{x86_64-pc-windows-msvc,x86_64-unknown-linux-gnu}:--emit=llvmfor both triples on any host, so Windows CI also covers the Itanium wrapping.promise.ts(PR more no default opts finished #65 version) now compiles under own for both triples.🤖 Generated with Claude Code