selfhost: fix 4B array load/store width + 8B uninit zero-init
This commit is contained in:
@@ -345,6 +345,24 @@ probe_ww_compile(const char *bin)
|
||||
" dec(&c); dec(&c); dec(&c);\n"
|
||||
" return c.x;\n"
|
||||
"};", 2 },
|
||||
/* Uninit `[8]u8` local — raw size 8B, C cgen zero-inits via
|
||||
* `MOVQ $0, off(BP)`. Pre-fix the wwstage left the slot
|
||||
* holding stack junk and `buf[0]` returned non-zero. */
|
||||
{ "fn main() i32 = {\n"
|
||||
" let buf: [8]u8;\n"
|
||||
" return buf[0]: i32;\n"
|
||||
"};", 0 },
|
||||
/* [N]i32 indexed write + read: MOVL store, MOVSXD load.
|
||||
* Pre-fix the wwstage emitted MOVQ in both directions —
|
||||
* overwrites adjacent slots and loads the wrong width.
|
||||
* arr[0..3] = -7, 3, 11, sum = 7. */
|
||||
{ "fn main() i32 = {\n"
|
||||
" let arr: [3]i32;\n"
|
||||
" arr[0] = 0 - 7;\n"
|
||||
" arr[1] = 3;\n"
|
||||
" arr[2] = 11;\n"
|
||||
" return arr[0] + arr[1] + arr[2];\n"
|
||||
"};", 7 },
|
||||
/* Hare-style for-range over a slice: `for (let b .. s)`.
|
||||
* Allocates `.rgi`/`.rgl` scratch slots, walks i=0..s.len
|
||||
* loading s.ptr[i] into the binding. esz=1 here so the
|
||||
|
||||
Reference in New Issue
Block a user