Skip to content

Commit

Permalink
Fix inconsistent use_list update
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Feb 25, 2025
1 parent ca93e78 commit d7ec1d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ir_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
use_list = &ctx->use_lists[merge];
if (use_list->count > 1) {
n++;
for (k = 0, p = &ctx->use_edges[use_list->refs]; k < use_list->count; k++, p++) {
for (k = 0, p = &ctx->use_edges[use_list->refs]; k < use_list->count;) {
use = *p;
use_insn = &ctx->ir_base[use];
if (use_insn->op == IR_PHI) {
Expand All @@ -379,7 +379,11 @@ static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
for (j = 2; j <= n; j++) {
ir_insn_set_op(use_insn, j, IR_UNUSED);
}
ir_use_list_remove_all(ctx, merge, use);
ir_use_list_remove_one(ctx, merge, use);
p = &ctx->use_edges[use_list->refs + k];
} else {
k++;
p++;
}
}
}
Expand Down

0 comments on commit d7ec1d5

Please sign in to comment.