Fix passing of a padded struct to a function

This commit is contained in:
Alexey Prokhin
2011-02-26 20:16:01 +03:00
parent 20e6c65200
commit 70aee84c70
4 changed files with 22 additions and 18 deletions

View File

@@ -115,22 +115,24 @@ void ReturnStatement::toIR(IRState* p)
else
{
LLValue* v;
DValue* dval = exp->toElem(p);
// call postblit if necessary
callPostblitHelper(loc, exp, dval->getRVal());
if (!exp && (p->topfunc() == p->mainFunc))
v = LLConstant::getNullValue(p->mainFunc->getReturnType());
else
// do abi specific transformations on the return value
#if DMDV2
v = p->func()->type->fty.putRet(exp->type, exp->toElem(p), p->func()->type->isref);
v = p->func()->type->fty.putRet(exp->type, dval, p->func()->type->isref);
#else
v = p->func()->type->fty.putRet(exp->type, exp->toElem(p));
v = p->func()->type->fty.putRet(exp->type, dval);
#endif
if (Logger::enabled())
Logger::cout() << "return value is '" <<*v << "'\n";
// call postblit if necessary
callPostblitHelper(loc, exp, v);
IrFunction* f = p->func();
// Hack around LDC assuming structs and static arrays are in memory:
// If the function returns a struct or a static array, and the return