From 67653869df33ce9038d5faad8f07561b1dfd14fb Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 13 Oct 2025 22:45:11 +0200 Subject: cfg: fix rpo dead blocks --- cfg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cfg.c') diff --git a/cfg.c b/cfg.c index 73c7559..d9aa409 100644 --- a/cfg.c +++ b/cfg.c @@ -22,11 +22,15 @@ sortrpo(struct function *fn) startbbvisit(); fn->entry->id = 0; - markvisited(fn->entry); - if (fn->entry->s1) porec(&rpo, fn->entry->s1); - if (fn->entry->s2) porec(&rpo, fn->entry->s2); - *--rpo = fn->entry; + porec(&rpo, fn->entry); ndead = rpo - rpobuf; + for (struct block *blk = fn->entry; ndead > 0; blk = blk->lnext) { + if (!wasvisited(blk)) { + blk->lnext = blk->lprev = NULL; + freeblk(fn, blk); + --ndead; + } + } for (i = 1, ++rpo; rpo < rpoend; ++rpo, ++i) { rpo[-1]->lnext = rpo[0]; rpo[0]->lprev = rpo[-1]; @@ -34,10 +38,6 @@ sortrpo(struct function *fn) } fn->entry->lprev = rpo[-1]; rpo[-1]->lnext = fn->entry; - for (rpo = rpobuf; ndead > 0; --ndead) { - (*rpo)->lnext = (*rpo)->lprev = NULL; - freeblk(fn, *rpo); - } } /* vim:set ts=3 sw=3 expandtab: */ -- cgit v1.2.3