ref: 75e90d91c0c50fb64812e61c21da8cbc8f1d3e5e
parent: d710ee583d7591cfaba91d7ee39676dbcae1a116
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 28 06:44:06 EST 2015
Fix alignment in argument passing. The alignment of a compound type is equal to the maximum alignment of its members, so your array shouldn't be aligned. When setting up arguments, though, I was accidentally using the size of the type instead of the alignment. Fixes #30
--- a/6/isel.c
+++ b/6/isel.c
@@ -415,6 +415,7 @@
dp = inr(s, to);
i = 0;
+ align = 8;
if (align == 0)
align = 8;
if (sz <= 128) { /* arbitrary threshold; should be tuned */
@@ -933,7 +934,7 @@
nargs = countargs(fn->type);
for (i = 0; i < fn->nargs; i++) {
arg = fn->args[i];
- argoff = align(argoff, min(size(arg), Ptrsz));
+ argoff = alignto(argoff, decltype(arg));
if (i >= nargs)
vararg = 1;
if (stacknode(arg)) {
--- /dev/null
+++ b/test/arraypass.myr
@@ -1,0 +1,12 @@
+use std
+
+const keq = {a, b
+ std.put("{}\n", b[0])
+}
+
+const main = {args : byte[:][:]
+ var k : byte[5]
+
+ k = [1,2,3,4,5]
+ keq(k, k)
+}
--- a/test/tests
+++ b/test/tests
@@ -115,6 +115,7 @@
F matchmixed
B bigliteral P 34359738368
B arraylit-ni E 2
+B arraypass P 1
B livearraylit E 21
# B arraylit E 3 ## BUGGERED
B structlit E 42