Convert struct arg to integer when passing inreg to make sure LLVM doesn't

ignore the attribute!
This commit is contained in:
Christian Kamm
2009-02-04 18:39:33 +01:00
parent c1aeab8c07
commit c3cdcab8d2
4 changed files with 17 additions and 11 deletions

View File

@@ -370,15 +370,16 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
LLValue* arg = argval->getRVal();
int j = tf->reverseParams ? beg + n - i - 1 : beg + i;
// 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);
assert((fnarg->llvmAttrs & llvm::Attribute::InReg) && isaStruct(tf->structInregArg));
arg = DtoBitCast(arg, getPtrToType(callableTy->getParamType(j)));
arg = DtoLoad(arg);
}
int j = tf->reverseParams ? beg + n - i - 1 : beg + i;
// parameter type mismatch, this is hard to get rid of
if (arg->getType() != callableTy->getParamType(j))
{