Skip to content

Commit 08f1e29

Browse files
committed
Update driver snapshots after decay tests.
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. Fix coding style for parser.c according to cubic's suggestion. Ignore comment modification in tests/driver.sh
1 parent accfedf commit 08f1e29

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,7 @@ var_t *scalarize_array_literal(block_t *parent,
13551355
scalar->init_val = array_var->init_val;
13561356

13571357
add_insn(parent, *bb, OP_read, scalar, array_var, NULL, elem_size, NULL);
1358+
13581359
return scalar;
13591360
}
13601361
void read_inner_var_decl(var_t *vd, bool anon, bool is_param)
@@ -2107,6 +2108,12 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
21072108
add_insn(parent, *bb, OP_allocat, compound_var, NULL, NULL, 0,
21082109
NULL);
21092110
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+
}
21102117
opstack_push(compound_var);
21112118
consumed_close_brace = true;
21122119
} 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/fib-riscv.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.

tests/snapshots/hello-riscv.json

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

0 commit comments

Comments
 (0)