Skip to content

Commit b13f5b6

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 b13f5b6

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

src/arm-codegen.c

Lines changed: 1 addition & 1 deletion
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) {

src/parser.c

Lines changed: 10 additions & 6 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) {
@@ -4481,10 +4488,8 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
44814488
} else {
44824489
read_expr(parent, &bb);
44834490
read_ternary_operation(parent, &bb);
4484-
4485-
var_t *expr_result = opstack_pop();
4486-
4487-
var_t *rhs = expr_result;
4491+
4492+
var_t *rhs = opstack_pop();
44884493
if (!var->ptr_level && var->array_size == 0)
44894494
rhs = scalarize_array_literal(parent, &bb, rhs,
44904495
var->type);
@@ -4581,8 +4586,7 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
45814586
} else {
45824587
read_expr(parent, &bb);
45834588
read_ternary_operation(parent, &bb);
4584-
var_t *expr_result = opstack_pop();
4585-
var_t *rhs = expr_result;
4589+
var_t *rhs = opstack_pop();
45864590
if (!nv->ptr_level && nv->array_size == 0)
45874591
rhs = scalarize_array_literal(parent, &bb, rhs,
45884592
nv->type);

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)