Blk::pred is a vector

Scratching an itch - avoid unnecesary re-allocation in fillpred()
which is called often in the optimisation chain.
This commit is contained in:
Roland Paterson-Jones 2024-10-16 09:14:43 +02:00 committed by Quentin Carbonneaux
parent c16f7eafca
commit 024dffac8b

11
cfg.c
View File

@ -45,10 +45,11 @@ edgedel(Blk *bs, Blk **pbd)
static void static void
addpred(Blk *bp, Blk *bc) addpred(Blk *bp, Blk *bc)
{ {
if (!bc->pred) { if (bc->pred)
bc->pred = alloc(bc->npred * sizeof bc->pred[0]); vgrow(&bc->pred, bc->npred);
bc->visit = 0; else
} bc->pred = vnew(bc->npred, sizeof bc->pred[0], PFn);
assert(bc->visit < bc->npred);
bc->pred[bc->visit++] = bp; bc->pred[bc->visit++] = bp;
} }
@ -60,7 +61,7 @@ fillpreds(Fn *f)
for (b=f->start; b; b=b->link) { for (b=f->start; b; b=b->link) {
b->npred = 0; b->npred = 0;
b->pred = 0; b->visit = 0;
} }
for (b=f->start; b; b=b->link) { for (b=f->start; b; b=b->link) {
if (b->s1) if (b->s1)