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().
This commit is contained in:
Quentin Carbonneaux 2026-01-13 18:27:50 +01:00
parent e8365dd0a2
commit afd5d2e518

11
cfg.c
View File

@ -16,19 +16,22 @@ newblk()
static void static void
fixphis(Fn *f) fixphis(Fn *f)
{ {
Blk *b; Blk *b, *bp;
Phi *p; Phi *p;
uint n, n0; uint n, n0;
for (b=f->start; b; b=b->link) { for (b=f->start; b; b=b->link) {
assert(b->id < f->nblk); assert(b->id < f->nblk);
for (p=b->phi; p; p=p->link) { for (p=b->phi; p; p=p->link) {
for (n=n0=0; n<p->narg; n++) for (n=n0=0; n<p->narg; n++) {
if (p->blk[n]->id != -1u) { bp = p->blk[n];
p->blk[n0] = p->blk[n]; if (bp->id != -1u)
if (bp->s1 == b || bp->s2 == b) {
p->blk[n0] = bp;
p->arg[n0] = p->arg[n]; p->arg[n0] = p->arg[n];
n0++; n0++;
} }
}
assert(n0 > 0); assert(n0 > 0);
p->narg = n0; p->narg = n0;
} }