diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-12-28 11:44:06 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-12-28 11:44:32 -0800 |
commit | 75e90d91c0c50fb64812e61c21da8cbc8f1d3e5e (patch) | |
tree | bb54318881e64c7a3c8ebcacf6559e4cba00e741 /6/isel.c | |
parent | d710ee583d7591cfaba91d7ee39676dbcae1a116 (diff) | |
download | mc-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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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)) { |