diff options
| author | 2026-02-18 18:18:12 +0100 | |
|---|---|---|
| committer | 2026-02-18 18:19:18 +0100 | |
| commit | 3ac9b17e1aca31a2c01c0887272b50741d43ad76 (patch) | |
| tree | d07b8c9e5dac41a8dae81ed0dc681a8cc250fcca | |
| parent | cc9348c999f20eaa55afde61724923f66bfa199b (diff) | |
ir/rpo: sanity checks
| -rw-r--r-- | ir/cfg.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -1,12 +1,14 @@ #include "ir.h" static void -porec(struct block ***rpo, struct block *b) +porec(int *nblk, struct block ***rpo, struct block *b) { if (wasvisited(b)) return; + assert(*nblk > 0 && "nblk bad"); + --*nblk; markvisited(b); - if (b->s2) porec(rpo, b->s2); - if (b->s1) porec(rpo, b->s1); + if (b->s2) porec(nblk, rpo, b->s2); + if (b->s1) porec(nblk, rpo, b->s1); *--*rpo = b; } @@ -23,7 +25,8 @@ sortrpo(struct function *fn) startbbvisit(); fn->entry->id = 0; - porec(&rpo, fn->entry); + int nblk = fn->nblk; + porec(&nblk, &rpo, fn->entry); ndead = rpo - rpobuf; if (ndead > 0) for (blk = fn->entry->lprev; blk != fn->entry; blk = next) { next = blk->lprev; |