mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-14 10:53:14 +01:00
Follow the D ABI and pass the last arg in a register if it is a struct that fits.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user