diff --git a/ir_emit.c b/ir_emit.c index d5606fc..aa43eeb 100644 --- a/ir_emit.c +++ b/ir_emit.c @@ -270,11 +270,11 @@ int ir_match(ir_ctx *ctx) if (!ctx->prev_ref) { ctx->prev_ref = ir_mem_malloc(ctx->insns_count * sizeof(ir_ref)); + prev = 0; for (b = 1, bb = ctx->cfg_blocks + b; b <= ctx->cfg_blocks_count; b++, bb++) { if (bb->flags & IR_BB_UNREACHABLE) { continue; } - prev = 0; for (i = bb->start, insn = ctx->ir_base + i; i < bb->end;) { ctx->prev_ref[i] = prev; n = ir_operands_count(ctx, insn); diff --git a/ir_ra.c b/ir_ra.c index 9c3c287..18f0e48 100644 --- a/ir_ra.c +++ b/ir_ra.c @@ -57,6 +57,7 @@ int ir_assign_virtual_registers(ir_ctx *ctx) } vregs = ir_mem_calloc(ctx->insns_count, sizeof(ir_ref)); n = 1; + prev = 0; for (b = 1, bb = ctx->cfg_blocks + b; b <= ctx->cfg_blocks_count; b++, bb++) { if (bb->flags & IR_BB_UNREACHABLE) { continue; @@ -65,7 +66,7 @@ int ir_assign_virtual_registers(ir_ctx *ctx) /* skip first instruction */ insn = ctx->ir_base + i; - ctx->prev_ref[i] = 0; + ctx->prev_ref[i] = prev; prev = i; n = ir_operands_count(ctx, insn); n = 1 + (n >> 2); // support for multi-word instructions like MERGE and PHI