aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir/cfg.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-23 19:30:45 +0200
committerlemon <lsof@mailbox.org>2025-10-23 19:30:51 +0200
commit4fc6339f04958150c538bf97bf721f58e0084ffb (patch)
treef66fe5203552287f0386c6459d1f0a4bce4bf22f /ir/cfg.c
parented989e2a0855e175442b0f5e73bb3fa4833efecd (diff)
ir bugfixes
Diffstat (limited to 'ir/cfg.c')
-rw-r--r--ir/cfg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ir/cfg.c b/ir/cfg.c
index d9aa409..df428d1 100644
--- a/ir/cfg.c
+++ b/ir/cfg.c
@@ -24,8 +24,11 @@ sortrpo(struct function *fn)
fn->entry->id = 0;
porec(&rpo, fn->entry);
ndead = rpo - rpobuf;
- for (struct block *blk = fn->entry; ndead > 0; blk = blk->lnext) {
+ for (struct block *blk = fn->entry->lprev, *next; ndead > 0; blk = next) {
+ next = blk->lprev;
if (!wasvisited(blk)) {
+ for (int i = 0; i < blk->npred; ++i)
+ assert(!wasvisited(blkpred(blk, i)));
blk->lnext = blk->lprev = NULL;
freeblk(fn, blk);
--ndead;