From 0ce9966c235d92553842c33587bb3ded1d3dbaba Mon Sep 17 00:00:00 2001 From: Roland Paterson-Jones Date: Wed, 23 Oct 2024 09:15:30 +0200 Subject: Re-use (vgrow) b->ins vector in backend xxx_abi() fn's. Removes last re-allocation of b->ins. --- amd64/sysv.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'amd64') diff --git a/amd64/sysv.c b/amd64/sysv.c index 8a1fd2a..fd10bfd 100644 --- a/amd64/sysv.c +++ b/amd64/sysv.c @@ -656,9 +656,9 @@ void amd64_sysv_abi(Fn *fn) { Blk *b; - Ins *i, *i0, *ip; + Ins *i, *i0; RAlloc *ral; - int n, fa; + int n0, n1, ioff, fa; for (b=fn->start; b; b=b->link) b->visit = 0; @@ -668,12 +668,13 @@ amd64_sysv_abi(Fn *fn) if (!ispar(i->op)) break; fa = selpar(fn, b->ins, i); - n = b->nins - (i - b->ins) + (&insb[NIns] - curi); - i0 = vnew(n, sizeof(Ins), PFn); - ip = icpy(ip = i0, curi, &insb[NIns] - curi); - ip = icpy(ip, i, &b->ins[b->nins] - i); - b->nins = n; - b->ins = i0; + n0 = &insb[NIns] - curi; + ioff = i - b->ins; + n1 = b->nins - ioff; + vgrow(&b->ins, n0+n1); + icpy(b->ins+n0, b->ins+ioff, n1); + icpy(b->ins, curi, n0); + b->nins = n0+n1; /* lower calls, returns, and vararg instructions */ ral = 0; -- cgit v1.2.3