wcc: module-imported array indexed-load via cg_dotbase_addr (#128b)
Fix segfault-class memory corruption on `module.array[i]` indexed-read where both stages emitted MOVQ-not-LEAQ on the module-qualified base plus wrong stride. Extends the #135 cg_dotbase_addr/dotbaseaddr helper to handle the SK_USE module-ident-base case: when bt is NULL/ty_err and let_islet(base.str) resolves to TY_ARRAY, emit LEAQ base(SB),dst instead of MOVQ. Wwstage parallel via letvartnode/N_TARRAY check. Stride fix via let_var_type fallback in cgindex when n.lhs.kind==N_DOT. Use-site fix per #135 precedent (Option B); preserves cgdot's MOVQ semantics for the whole-array-assign defensive case (zero current consumers). Test 915 carries 3 module-u16 indexed-read rows (strconv.left_shift_table[0/2/4]) + 2 local-array controls; the strconv.left_shift_table[2]:u32 probe segfaulted (exit 139) pre-fix and exits cleanly post-fix. Broader width-variation rows (u8/u32/i32 module-imported) deferred as informational enhancement. Test 915 skips its inline cs==ww .s cmp on needs_import rows (line 217-222) since `ww build` only drives cstage; reviewer externally verified byte-id on /tmp/k128probe.combined.ww (driver-expanded form, no imports). Future enhancement: 915 could read the driver-emitted combined.ww and add a cmp leg there. Bootstrap NEUTRAL (zero current module.array[i] consumers; strconv decimal.ww uses IDENT-base from within package). 178/178 incl. 990-997 + combined_ww_fresh green. Sibling bugs #137 (chained N_DOT) / #141 (variadic-gather esz==2) / #142 (wwstage primsize-on-alias) properly deferred to backlog.
This commit is contained in:
6
Makefile
6
Makefile
@@ -337,6 +337,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_sar_shr_run \
|
||||
$(BIN)/test_def_mangle_run \
|
||||
$(BIN)/test_arr_u16_store_run \
|
||||
$(BIN)/test_arr_module_index_run \
|
||||
$(BIN)/test_f64cgen_run \
|
||||
$(BIN)/test_f64crossmod_run \
|
||||
$(BIN)/test_tuprecv_run \
|
||||
@@ -1135,6 +1136,11 @@ $(BIN)/test_arr_u16_store_run: test/wcc/914_arr_u16_store_run.c $(BIN)/ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_arr_module_index_run: test/wcc/915_arr_module_index_run.c $(BIN)/ww \
|
||||
$(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_f64cgen_run: test/wcc/951_f64cgen_run.c $(BIN)/ww $(BIN)/w6c \
|
||||
$(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user