Repository navigation
Conversation
The C path bound a WITH alias to its designator's address, which a sub-byte field or packed element does not have: an internal CG error for a static bit offset, an "unaligned address" runtime error for a dynamic one. The alias now keeps the designator's base, with its alignment, and its static and dynamic bits (CG.Split_bit_address, Variable.SetBitLValue), and keeps the designator's packed type (Variable.SetRepType) so loads and stores through it cover only its bits. New test p314. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # m3-sys/m3tests/src/m3makefile
Member
Author
|
@RodneyBates, could you review this one too? It's the same packed-address machinery in It overlaps with The parts I'd most like a second pair of eyes on:
p314 covers sub-byte fields, fields of bit-packed record fields, and packed array elements at constant and run-time subscripts, including aliases used from a nested procedure. 🤖 Generated with Claude Code |
Resolve the m3tests list (p314 beside master's p315) and follow #1356's rename of ValRec.temp_bits to bits_is_temp in Split_bit_address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
WITH x = dover a designator that does not start on a byte (a sub-byte field, a field of a bit-packed record field, or a packed array element) fails under the C backend on master:The language allows both: a WITH over a writable designator aliases it. The C path binds the alias to the designator's address (
Expr.CompileAddress, thenVariable.SetLValue), and such a designator has none.CG already represents bit addresses on its stack, and its packed loads and stores handle them; only storing one as a pointer fails. So the alias now keeps the designator's base, with that base's alignment, plus its bits:
CG.Split_bit_addressturns an address that may not be byte-aligned into its base, its static bit offset and (pushed) its dynamic bits. A byte-aligned address is handled asCheck_byte_alignedhandled it, so other WITHs compile as before.Variable.SetBitLValuerecords the bits on the alias (dynamic bits in a local of their own, up-level if the alias is), andLoad/LoadLValueadd them back, so packed loads and stores through the alias choose the same containers as through the designator.Variable.SetRepType), so a load or store through it covers only the designator's bits, not the stripped type's (a store throughWITH x = r.b,b5 bits, would otherwise write 8).New test p314 covers sub-byte fields; a bit-packed record field at a dynamic index (evaluated once); packed elements at every dynamic index; a byte-crossing element at a static index; a byte-aligned element whose neighbour must survive; object fields; an alias used from a nested procedure; and that neighbouring bits are preserved throughout. Master cannot compile it; with this change it prints
ok. Otherwise the full m3tests suite on ARM64_DARWIN gives exactly master's results.Its dynamic indexes use element sizes that divide a byte: elements that cross a byte at a dynamic index are wrong on master independently of WITH, fixed in #1328.
The MSIR branch solves the same problem the same way (
bitLocMSIR: the base evaluated once, plus a bit location).🤖 Generated with Claude Code