summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-10-07 14:48:04 -0700
committerOri Bernstein <ori@eigenstate.org>2017-10-07 14:50:20 -0700
commit3f5b9c674dc0f3e9e43d17acf1b7cfbb409b89d1 (patch)
treea15fc0b51c6dcabc58f88e46c5208d5495d2936d
parent0c0c4f2f6b3606ab6387b92cef21e166bc9c075b (diff)
downloadmc-3f5b9c674dc0f3e9e43d17acf1b7cfbb409b89d1.tar.gz
Correctly pad small alignments.
Negative padding shouldn't happen.
-rw-r--r--6/blob.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/6/blob.c b/6/blob.c
index 46072a1..8e2671e 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -255,15 +255,17 @@ blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
static size_t
blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
- size_t sz, pad;
+ size_t sz, align;
Ucon *uc;
sz = 4;
uc = finducon(exprtype(n), n->expr.args[0]);
b(seq, mkblobi(Bti32, uc->id));
+ align = 1;
if (n->expr.nargs > 1) {
- pad = tyalign(exprtype(n->expr.args[1])) - sz;
- sz += blobpad(seq, pad);
+ align = tyalign(exprtype(n->expr.args[1]));
+ if (align > sz)
+ sz += blobpad(seq, align - sz);
sz += blobrec(seq, globls, strtab, n->expr.args[1]);
}
sz += blobpad(seq, size(n) - sz);