Skip to content

Commit f8d3ace

Browse files
committed
Fix IR test failure
Regenerate ARM IR snapshots to reflect the corrected lowering. Restore ARM/RISC-V codegen files to original structure after earlier brace experiment. Treat zero-length array compound literals as constant zero during lowering so scalar uses don't load garbage.
1 parent 0845910 commit f8d3ace

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/arm-codegen.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
450450
fatal("Unsupported truncation operation with invalid target size");
451451
}
452452
return;
453-
case OP_sign_ext: {
453+
case OP_sign_ext:
454454
/* Decode source size from upper 16 bits */
455455
int source_size = (rm >> 16) & 0xFFFF;
456456
if (source_size == 2) {
@@ -459,7 +459,6 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
459459
/* For other cases, use byte extension (original behavior) */
460460
emit(__sxtb(__AL, rd, rn, 0));
461461
}
462-
}
463462
return;
464463
case OP_cast:
465464
/* Generic cast operation - for now, just move the value */

src/parser.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,12 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
21082108
add_insn(parent, *bb, OP_allocat, compound_var, NULL, NULL, 0,
21092109
NULL);
21102110
parse_array_compound_literal(compound_var, parent, bb, true);
2111+
2112+
if (compound_var->array_size == 0) {
2113+
compound_var->init_val = 0;
2114+
add_insn(parent, *bb, OP_load_constant, compound_var, NULL,
2115+
NULL, 0, NULL);
2116+
}
21112117
opstack_push(compound_var);
21122118
consumed_close_brace = true;
21132119
} else if (cast_ptr_level > 0) {

tests/snapshots/fib-arm.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/snapshots/hello-arm.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)