summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-28 17:30:52 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-28 23:41:42 -0800
commite11e5f143419b049f2c93a4b361a668b57a77fc0 (patch)
treebf73defd1b9acd449efd7ffe9e1ecdab4a951522 /6/simp.c
parent07f5aa5bbf9445c1ff188a6f75a6fa162119cc35 (diff)
downloadmc-e11e5f143419b049f2c93a4b361a668b57a77fc0.tar.gz
Fix union alignment.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/6/simp.c b/6/simp.c
index 145ddfc..f150d8e 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1155,7 +1155,7 @@ static Node *simpucon(Simp *s, Node *n, Node *dst)
Node *r;
Type *ty;
Ucon *uc;
- size_t i;
+ size_t i, o;
/* find the ucon we're constructing here */
ty = tybase(n->expr.type);
@@ -1185,7 +1185,8 @@ static Node *simpucon(Simp *s, Node *n, Node *dst)
if (!uc->etype)
return tmp;
elt = rval(s, n->expr.args[1], NULL);
- u = addk(u, Wordsz);
+ o = alignto(Wordsz, uc->etype);
+ u = addk(u, o);
if (isstacktype(uc->etype)) {
elt = addr(s, elt, uc->etype);
sz = disp(n->loc, tysize(uc->etype));
@@ -1200,11 +1201,13 @@ static Node *simpucon(Simp *s, Node *n, Node *dst)
static Node *simpuget(Simp *s, Node *n, Node *dst)
{
Node *u, *p, *l;
+ size_t o;
if (!dst)
dst = temp(s, n);
u = rval(s, n->expr.args[0], NULL);
- p = addk(addr(s, u, exprtype(n)), Wordsz);
+ o = alignto(Wordsz, exprtype(n));
+ p = addk(addr(s, u, exprtype(n)), o);
l = assign(s, dst, load(p));
append(s, l);
return dst;