diff options
| author | 2025-12-20 17:59:40 +0100 | |
|---|---|---|
| committer | 2025-12-20 19:31:50 +0100 | |
| commit | e6fbab42185f4fb4e3a3b1e3e93eaa5d3d81b7c7 (patch) | |
| tree | dba8dd1a91f532dd104dc1299b32e79babacb499 /x86_64 | |
| parent | a5009ae762541c29e9a123bf70877261db4ff628 (diff) | |
backend: unify pass memory allocation strategies
It was all over the place for temporary data structures used by
individual passes. Now there is an arena specifically for that, which is
nicer.
Diffstat (limited to 'x86_64')
| -rw-r--r-- | x86_64/emit.c | 6 | ||||
| -rw-r--r-- | x86_64/isel.c | 3 |
2 files changed, 2 insertions, 7 deletions
diff --git a/x86_64/emit.c b/x86_64/emit.c index 3fc93b0..2786e22 100644 --- a/x86_64/emit.c +++ b/x86_64/emit.c @@ -738,7 +738,6 @@ static struct blkaddr { uint relreloc; }; } *blkaddr; -static uint nblkaddr; static void Xjcc(uchar **pcode, enum cc cc, struct block *dst) @@ -1356,10 +1355,7 @@ emitbin(struct function *fn) } while ((blk = blk->lprev) != fn->entry); } - if (nblkaddr < fn->nblk) { - blkaddr = xrealloc(blkaddr, (nblkaddr = fn->nblk) * sizeof *blkaddr); - } - memset(blkaddr, 0, nblkaddr * sizeof *blkaddr); + blkaddr = allocz(fn->passarena, fn->nblk * sizeof *blkaddr, 0); blk = fn->entry; do { diff --git a/x86_64/isel.c b/x86_64/isel.c index 2b087cd..bc49d03 100644 --- a/x86_64/isel.c +++ b/x86_64/isel.c @@ -627,7 +627,7 @@ x86_64_isel(struct function *fn) struct block *blk = fn->entry; fn->stksiz = 0; - stkslots = xcalloc((nstkslots = ninstr) * sizeof *stkslots); + stkslots = allocz(fn->passarena, (nstkslots = ninstr) * sizeof *stkslots, 0); do { int i; for (i = 0; i < blk->phi.n; ++i) { @@ -649,7 +649,6 @@ x86_64_isel(struct function *fn) } seljmp(fn, blk); } while ((blk = blk->lnext) != fn->entry); - free(stkslots); if (ccopt.dbg.i) { bfmt(ccopt.dbgout, "<< After isel >>\n"); |