summary refs log tree commit diff
path: root/arm64/abi.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-03-14 09:59:14 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-03-14 10:04:24 +0100
commit905e9cef302727fdaacd7069826ff448c2d88361 (patch)
tree983a38802630dcbdc6dfb8108cbdc4dbb9c980ea /arm64/abi.c
parentc7842d84da65bcaf2d3c82aa69fb3ec930c7369f (diff)
downloadroux-905e9cef302727fdaacd7069826ff448c2d88361.tar.gz
arm64/abi: fix big aggregates passed on the stack
The riscv test abi8.ssa caught a bug
in the arm backend. It turns out we
were using the wrong class when loading
pointers to aggregates from the stack.

The fix is simple and mirrors what is
done in the riscv abi.
Diffstat (limited to 'arm64/abi.c')
-rw-r--r--arm64/abi.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/arm64/abi.c b/arm64/abi.c
index 6ed393d..b6b4612 100644
--- a/arm64/abi.c
+++ b/arm64/abi.c
@@ -100,6 +100,9 @@ typclass(Class *c, Typ *t, int *gp, int *fp)
 		 * memory */
 		c->class |= Cptr;
 		c->size = 8;
+		c->ngp = 1;
+		*c->reg = *gp;
+		*c->cls = Kl;
 		return;
 	}
 
@@ -230,14 +233,7 @@ argsclass(Ins *i0, Ins *i1, Class *carg, Ref *env)
 		case Oparc:
 		case Oargc:
 			typclass(c, &typ[i->arg[0].val], gp, fp);
-			if (c->class & Cptr) {
-				if (ngp > 0) {
-					ngp--;
-					*c->reg = *gp++;
-					*c->cls = Kl;
-					break;
-				}
-			} else if (c->ngp <= ngp) {
+			if (c->ngp <= ngp) {
 				if (c->nfp <= nfp) {
 					ngp -= c->ngp;
 					nfp -= c->nfp;