From d40371b615b560d8726fd4fdaf7d35abc959e0e9 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 11 Apr 2026 22:49:19 +0200 Subject: backend: fix memory leak from not calling deluses() after replcuses in some places --- src/ir.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ir.c') diff --git a/src/ir.c b/src/ir.c index f34cfaf..c32ff4d 100644 --- a/src/ir.c +++ b/src/ir.c @@ -541,9 +541,9 @@ void replcuses(Ref from, Ref to) { assert(from.t == RTMP); - for (IRUse *use = instruse[from.i], *next; use; use = next) { + for (IRUse *use, *next = instruse[from.i]; (use = next);) { Ref *u; - int n, j; + int n; next = use->next; if (use->u == from.i) continue; if (use->u == USERJUMP) { @@ -556,15 +556,14 @@ replcuses(Ref from, Ref to) n = use->blk->npred; if (use->blk->phi.n == 0) continue; /* shouldn't happen */ } else { - u = &instrtab[use->u].l; - n = 2; + u = instrtab[use->u].oper; + n = opnoper[instrtab[use->u].op]; } - for (j = 0; j < n; ++j) { + for (int j = 0; j < n; ++j) { if (u[j].bits == from.bits) { u[j].bits = to.bits; adduse(use->blk, use->u, to); - next = use; break; } } -- cgit v1.2.3