From bd3307a3e98e75b7cce5aa130719022a00323e0f Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 23 Nov 2025 17:10:30 +0100 Subject: amd64: va_arg for small aggregates --- amd64/sysv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'amd64/sysv.c') diff --git a/amd64/sysv.c b/amd64/sysv.c index 9d356a1..712652a 100644 --- a/amd64/sysv.c +++ b/amd64/sysv.c @@ -205,7 +205,7 @@ vastart(struct function *fn, struct block *blk, int *curi) /* set ap->fp_offset */ dst = insertinstr(blk, i++, mkinstr(Oadd, KPTR, ap, mkref(RICON, 4))); insertinstr(blk, i++, mkinstr(Ostore32, 0, dst, mkref(RICON, 6*8 + fpr0*16))); - *curi = i; + *curi = i-1; } static void @@ -270,7 +270,13 @@ vaarg(struct function *fn, struct block *blk, int *curi) merge->ins.p[0] = var; phi = insertphi(merge, KPTR); memcpy(phitab.p[instrtab[phi.i].l.i], phiargs, sizeof phiargs); - instrtab[var] = mkinstr(cls[0] == KI32 ? Oloads32 : Oloadi64, cls[0], phi); + if (!ty.isagg) { + instrtab[var] = mkinstr(cls[0] == KI32 ? Oloads32 : Oloadi64, cls[0], phi); + } else { + instrtab[var] = mkalloca(8, 8); + tmp = insertinstr(merge, 1, mkinstr(Oloadi64, KI64, phi)); + insertinstr(merge, 2, mkinstr(Ostore64, 0, mkref(RTMP, var), tmp)); + } fn->prop &= ~FNUSE; } else { assert(!"nyi"); -- cgit v1.2.3