commit 4c3c80e7e17e13ffc5a73d2563156d823c800b63
parent 7432b0a64761aa07f95ad19761c61bf11db428e9
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Mon, 27 Feb 2017 11:54:55 -0500
minor tweaks to simpljmp pass
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/cfg.c b/cfg.c
@@ -285,9 +285,10 @@ uffind(Blk **pb, Blk **uf, Fn *fn)
Blk **pb1;
pb1 = &uf[(*pb)->id];
- if (*pb1 != *pb)
+ if (*pb1) {
uffind(pb1, uf, fn);
- *pb = *pb1;
+ *pb = *pb1;
+ }
}
/* requires rpo and no phis, breaks cfg */
@@ -297,12 +298,9 @@ simpljmp(Fn *fn)
Blk **uf; /* union-find */
Blk *b;
- uint n;
int c;
- uf = alloc(fn->nblk * sizeof uf[0]);
- for (n=0; n<fn->nblk; n++)
- uf[n] = fn->rpo[n];
+ uf = emalloc(fn->nblk * sizeof uf[0]);
for (b=fn->start; b; b=b->link) {
assert(!b->phi);
if (b->nins == 0)
@@ -321,4 +319,5 @@ simpljmp(Fn *fn)
b->s2 = 0;
}
}
+ free(uf);
}