diff options
| author | Roland Paterson-Jones <[email protected]> | 2024-11-19 11:29:16 +0200 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2025-03-14 09:47:05 +0100 |
| commit | 9e36cbe4d8f8c9ff3d739ff9ead2a4a4988c0904 (patch) | |
| tree | 733105ea25be975c2d1c6db38a0f540b5f681507 /cfg.c | |
| parent | ecfdac4f00a81dd57ffcbe11142e8619b1f2ee67 (diff) | |
Combine fillrpo() and fillpreds() into fillcfg().
Remove edgedel() calls from fillrpo().
Call new prunephis() from fillpreds().
[Curiously this never seems to do anything even tho edgedel()
is no longer called from fillrpo()]
One remaining fillpreds() call in parse.c typecheck - seems
like it will still work the same.
defensive; fillcfg() combining fillrpo() and fillpreds() - problem after simpljmp() - think it is cos fillrpo() is still doing edgedel() which should now be covered by fillpreds()
comment out edgedel() in fillrpo() - fillcfg() no longer asserts after simpljmp() but seems like prunephis() never triggers???
static fillrpo(); remove edgedel() from fillrpo()
replace fillrpo() and/or fillpreds() with fillcfg()
Diffstat (limited to 'cfg.c')
| -rw-r--r-- | cfg.c | 44 |
1 files changed, 40 insertions, 4 deletions
@@ -11,6 +11,34 @@ newblk() return b; } +/* TODO - this never seems to do anything??? */ +static void +prunephis(Fn *f) +{ + Blk *b; + Phi *p, **pp; + uint na, na0; + + for (b = f->start; b; b = b->link) { + assert(b->id < f->nblk); + for (pp = &b->phi; (*pp);) { + p = *pp; + for (na = na0 = 0; na < p->narg; na++) + if (p->blk[na]->id != -1u) { + p->blk[na0] = p->blk[na]; + p->arg[na0] = p->arg[na]; + na0++; + } + if (na0 == 0) { + *pp = p->link; + } else { + p->narg = na0; + pp = &p->link; + } + } + } +} + void edgedel(Blk *bs, Blk **pbd) { @@ -53,7 +81,7 @@ addpred(Blk *bp, Blk *bc) bc->pred[bc->npred-1] = bp; } -/* fill predecessors information in blocks */ +/* fill predecessors information in blocks; prune dead phi refs */ void fillpreds(Fn *f) { @@ -67,6 +95,8 @@ fillpreds(Fn *f) if (b->s2 && b->s2 != b->s1) addpred(b, b->s2); } + /* TODO - this never seems to do anything??? */ + prunephis(f); } static void @@ -89,7 +119,7 @@ porec(Blk *b, uint *npo) } /* fill the rpo information; prune dead blks */ -void +static void fillrpo(Fn *f) { Blk *b, **p; @@ -104,8 +134,6 @@ fillrpo(Fn *f) f->rpo = vnew(f->nblk, sizeof f->rpo[0], PFn); for (p=&f->start; (b=*p);) { if (b->id == -1u) { - edgedel(b, &b->s1); - edgedel(b, &b->s2); *p = b->link; } else { b->id = f->nblk-b->id-1; /* po -> rpo */ @@ -115,6 +143,14 @@ fillrpo(Fn *f) } } +/* fill rpo, preds; prune dead blks, prune dead blk refs from phis */ +void +fillcfg(Fn *f) +{ + fillrpo(f); + fillpreds(f); +} + /* for dominators computation, read * "A Simple, Fast Dominance Algorithm" * by K. Cooper, T. Harvey, and K. Kennedy. |
