Mercurial > projects > ldc
diff gen/tocall.cpp @ 454:283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Fixed some wrong argument handling code when setting parameter attributes.
Updated the tango unittest script in the tango patch, does not work yet, all modules don't compile...
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 02 Aug 2008 02:54:57 +0200 |
parents | cc40db549aea |
children | b975f29b7256 |
line wrap: on
line diff
--- a/gen/tocall.cpp Sat Aug 02 01:23:53 2008 +0200 +++ b/gen/tocall.cpp Sat Aug 02 02:54:57 2008 +0200 @@ -213,6 +213,13 @@ LLFunctionType::param_iterator argbegin = callableTy->param_begin(); LLFunctionType::param_iterator argiter = argbegin; + // parameter attributes + llvm::PAListPtr palist; + + // return attrs + if (tf->llvmRetAttrs) + palist = palist.addAttr(0, tf->llvmRetAttrs); + // handle implicit arguments std::vector<LLValue*> args; @@ -222,6 +229,7 @@ LLValue* retvar = new llvm::AllocaInst(argiter->get()->getContainedType(0), ".rettmp", gIR->topallocapoint()); ++argiter; args.push_back(retvar); + palist = palist.addAttr(1, llvm::ParamAttr::StructRet); } // then comes a context argument... @@ -261,10 +269,6 @@ } // handle the rest of the arguments based on param passing style - llvm::PAListPtr palist; - - if (tf->llvmRetAttrs) - palist = palist.addAttr(0, tf->llvmRetAttrs); // variadic instrinsics need some custom casts if (va_intrinsic) @@ -296,7 +300,7 @@ Argument* fnarg = Argument::getNth(tf->parameters, i); DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); LLValue* arg = argval->getRVal(); - if (fnarg) + if (fnarg) // can fnarg ever be null in this block? { if (arg->getType() != callableTy->getParamType(j)) arg = DtoBitCast(arg, callableTy->getParamType(j));