From afd5d2e518e23231604a1cac37b70695e10a63fa Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Tue, 13 Jan 2026 18:27:50 +0100 Subject: drop dead preds in fixphis It is possible that GVN removes some dead blocks, this could lead to odd - but probably harmless - phi args appearing in the IL. This patch cleans things up during fillcfg(). --- cfg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cfg.c b/cfg.c index d3860df..de142f4 100644 --- a/cfg.c +++ b/cfg.c @@ -16,19 +16,22 @@ newblk() static void fixphis(Fn *f) { - Blk *b; + Blk *b, *bp; Phi *p; uint n, n0; for (b=f->start; b; b=b->link) { assert(b->id < f->nblk); for (p=b->phi; p; p=p->link) { - for (n=n0=0; nnarg; n++) - if (p->blk[n]->id != -1u) { - p->blk[n0] = p->blk[n]; + for (n=n0=0; nnarg; n++) { + bp = p->blk[n]; + if (bp->id != -1u) + if (bp->s1 == b || bp->s2 == b) { + p->blk[n0] = bp; p->arg[n0] = p->arg[n]; n0++; } + } assert(n0 > 0); p->narg = n0; } -- cgit v1.2.3