summary refs log tree commit diff
path: root/arm64
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-03-17 10:57:09 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-03-17 10:57:09 +0100
commitbf2a90ef7c183e9e0442d14d6f74fb6d5f79c6bb (patch)
tree47f42ddf38f84b8e78acc828033a47a7dd64d553 /arm64
parentcec9855fa0c8d9566d4c9755ef7677f49634bc60 (diff)
downloadroux-bf2a90ef7c183e9e0442d14d6f74fb6d5f79c6bb.tar.gz
fix return for big aggregates
The recent changes in arm and riscv
typclass() set ngp to 1 when a struct
is returned via a caller-provided
buffer.  This interacts bogusly with
selret() that ends up declaring a gp
register live when none is set in
the returning sequence.

The fix is simply to set cty to zero
(all registers dead) in case a caller-
provided buffer is used.
Diffstat (limited to 'arm64')
-rw-r--r--arm64/abi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arm64/abi.c b/arm64/abi.c
index 396c704..b2b5973 100644
--- a/arm64/abi.c
+++ b/arm64/abi.c
@@ -183,12 +183,14 @@ selret(Blk *b, Fn *fn)
 
 	if (j == Jretc) {
 		typclass(&cr, &typ[fn->retty], gpreg, fpreg);
-		cty = (cr.nfp << 2) | cr.ngp;
 		if (cr.class & Cptr) {
 			assert(rtype(fn->retr) == RTmp);
 			blit0(fn->retr, r, cr.t->size, fn);
-		} else
+			cty = 0;
+		} else {
 			ldregs(cr.reg, cr.cls, cr.nreg, r, fn);
+			cty = (cr.nfp << 2) | cr.ngp;
+		}
 	} else {
 		k = j - Jretw;
 		if (KBASE(k) == 0) {