aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir/cfg.c
diff options
context:
space:
mode:
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;