Repository navigation
-mm=own: no CSE ahead of inference; two equal concatenations are two owners - #756
Merged
Merged
Conversation
…owners Under --opt (on for --emit=jit) CSE was added to the FuncOp pipeline that runs before own's inference. It merged two equal allocations, e.g. `const s1 = "Hel" + "lo"` and `const s2 = "Hel" + "lo"`, into one value with two named owners, and inference refused it: "'this value' takes a second reference". CSE after inference would leave two releases of one allocation, so under own it does not run; rc, gc and none keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Oct 30, 2026
The merges of #754 and #756 each added their test to the own `foreach` lists without dropping the line it replaced, so `tslang/test/tester/CMakeLists.txt` closed the list early and CMake failed to configure ("Parse error. Expected "(", got identifier with text "own_callback_cast""). Both lists now hold each name once: own_equal_strings_into_any, the spec 72/73 tests and own_rest_keeps_declared. 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.
CSE before own inference merges two allocations into one owned value.
Under
--opt(which--emit=jitturns on; AOT emits leave it off by default),transform.cppaddedcreateCSEPass()tooptPM, the FuncOp nest that runs before own's inference. CSE treats a string concatenation as pure, sobecame one value with two named
constowners, and inference stopped with'this value' takes a second reference. Boxing intoanywas never the problem: the retain merely sits on theCast -> any. One const alone always compiled.Fix: under own, CSE does not run. Running it after inference instead would turn the two owners into two releases of one allocation, a double free. rc, gc and none keep CSE: their retains and releases stay paired.
Test:
own/own_equal_strings_into_any.tscovers two equal concatenations each boxed into ananyargument once, plus a loop where both are read after a churn. It runs under own (jit and compile, plus the no-counting check) and under rc/gc/none. Without the fix, the own JIT run fails with the error above.Full release ctest: 100% passed, 0 failed out of 6458.
🤖 Generated with Claude Code