summaryrefslogtreecommitdiff
path: root/6/isel.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-28 11:44:06 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-28 11:44:32 -0800
commit75e90d91c0c50fb64812e61c21da8cbc8f1d3e5e (patch)
treebb54318881e64c7a3c8ebcacf6559e4cba00e741 /6/isel.c
parentd710ee583d7591cfaba91d7ee39676dbcae1a116 (diff)
downloadmc-75e90d91c0c50fb64812e61c21da8cbc8f1d3e5e.tar.gz
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
Diffstat (limited to '6/isel.c')
-rw-r--r--6/isel.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/6/isel.c b/6/isel.c
index 20f3b82..e4c97c8 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -415,6 +415,7 @@ static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size
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 @@ void addarglocs(Isel *s, Func *fn)
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)) {