codegen: fix bitcast of union values with inline_roots#61027
Merged
Conversation
vtjnash
reviewed
Feb 13, 2026
Member
vtjnash
left a comment
There was a problem hiding this comment.
Look correct, though not very DRY
a13b356 to
94f38c0
Compare
When a union type contains members with mixed GC-pointer and non-pointer fields (e.g. a struct with both Vector and Int64 fields), codegen uses "split representation" where non-pointer data lives in v.V and GC roots are stored separately in v.inline_roots. The generic_bitcast codegen handler called ispointer()/data_pointer() which assert inline_roots.empty(), causing an assertion failure. Handle the inline_roots case before falling through to ispointer() by loading directly from v.V via maybe_decay_tracked(). This is correct because the dynamic runtime checks emitted earlier in the function (isprimitivetype + size match) guarantee that only primitive types with no GC pointers reach the load. Co-Authored-By: Claude Opus 4.6 <[email protected]>
94f38c0 to
1abe05f
Compare
Member
|
does this need backport? |
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.
Summary
inline_roots).generic_bitcastcalledispointer()/data_pointer()which assertinline_roots.empty(), causing an assertion failure.inline_rootscase by loading directly fromv.Vbefore falling through toispointer(). The dynamic runtime checks (isprimitivetype + size match) already guarantee only primitive types reach the load.Test plan
test/intrinsics.jlthat exercisesCore.Intrinsics.bitcaston a union containing a struct with GC-pointer fields (split representation).This PR was written with the assistance of generative AI (Claude).
🤖 Generated with Claude Code