diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 241780a0..2e52a725 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -141,8 +141,28 @@ void DtoBuildDVarArgList(std::vector& args, std::vectortype->ty != Ttuple); vtypes.push_back(DtoType(argexp->type)); size_t sz = getTypePaddedSize(vtypes.back()); - if (sz < PTRSIZE) - vtypes.back() = DtoSize_t(); + size_t asz = (sz + PTRSIZE - 1) & ~(PTRSIZE -1); + if (sz != asz) + { + if (sz < PTRSIZE) + { + vtypes.back() = DtoSize_t(); + } + else + { + // ok then... so we build some type that is big enough + // and aligned to PTRSIZE + std::vector gah; + gah.reserve(asz/PTRSIZE); + size_t gah_sz = 0; + while (gah_sz < asz) + { + gah.push_back(DtoSize_t()); + gah_sz += PTRSIZE; + } + vtypes.back() = LLStructType::get(gah, true); + } + } } const LLStructType* vtype = LLStructType::get(vtypes);