Follow the D ABI and pass the last arg in a register if it is a struct that fits.

This commit is contained in:
Christian Kamm
2009-02-03 21:46:46 +01:00
parent aa2cd42536
commit bbcea86cf2
4 changed files with 54 additions and 20 deletions

View File

@@ -370,6 +370,13 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
LLValue* arg = argval->getRVal();
// if it's a struct inreg arg, load first to pass as first-class value
if (tf->structInregArg && i == (tf->reverseParams ? n - 1 : 0))
{
assert(fnarg->llvmAttrs & llvm::Attribute::InReg);
arg = DtoLoad(arg);
}
int j = tf->reverseParams ? beg + n - i - 1 : beg + i;
// parameter type mismatch, this is hard to get rid of
@@ -395,7 +402,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
// reverse the relevant params as well as the param attrs
if (tf->reverseParams)
{
std::reverse(args.begin() + tf->reverseIndex, args.end());
std::reverse(args.begin() + tf->firstRealArg, args.end());
std::reverse(attrptr.begin(), attrptr.end());
}