diff --git a/src/arm-codegen.c b/src/arm-codegen.c index c2f2fae5..62432db8 100644 --- a/src/arm-codegen.c +++ b/src/arm-codegen.c @@ -41,16 +41,13 @@ void cfg_flatten() flatten_ir = add_ph2_ir(OP_define); flatten_ir->src0 = fn->func->stack_size; - int flag = 0; basic_block_t *bb; for (bb = fn->bbs; bb; bb = bb->rpo_next) { bb->elf_offset = elf_offset; - if (!flag) { + if (bb == fn->bbs) /* save ra, sp */ elf_offset += 16; - flag = 1; - } ph2_ir_t *inst; for (inst = bb->ph2_ir_list.head; inst; inst = inst->next) { diff --git a/src/riscv-codegen.c b/src/riscv-codegen.c index cc99645f..5dac87d7 100644 --- a/src/riscv-codegen.c +++ b/src/riscv-codegen.c @@ -41,16 +41,13 @@ void cfg_flatten() flatten_ir = add_ph2_ir(OP_define); flatten_ir->src0 = fn->func->stack_size; - int flag = 0; basic_block_t *bb; for (bb = fn->bbs; bb; bb = bb->rpo_next) { bb->elf_offset = elf_offset; - if (!flag) { + if (bb == fn->bbs) /* save ra, sp */ elf_offset += 8; - flag = 1; - } ph2_ir_t *inst; for (inst = bb->ph2_ir_list.head; inst; inst = inst->next) {