aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-04-11 22:49:19 +0200
committerlemon <lsof@mailbox.org>2026-04-11 22:49:19 +0200
commitd40371b615b560d8726fd4fdaf7d35abc959e0e9 (patch)
tree6e302f213c3e44fecccc032e79ea9f2d13c5c177 /src/ir.c
parent757b5735f44e9a9454f12612ec00c38d81f5f32c (diff)
backend: fix memory leak from not calling deluses() after replcuses in some places
Diffstat (limited to 'src/ir.c')
-rw-r--r--src/ir.c11
1 files changed, 5 insertions, 6 deletions
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;
}
}