From e9dacd97e2866f6abf67e939a6c8bb949a3b2e36 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Thu, 6 Jan 2011 17:07:44 +0300 Subject: [PATCH] Fixed passing of structs and static arrays into functions. Not sure if it is correct, though. --- gen/functions.cpp | 5 ++++- ir/irfunction.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 90c699ee..02dbe2e6 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -752,8 +752,11 @@ void DtoDefineFunction(FuncDeclaration* fd) bool refout = vd->storage_class & (STCref | STCout); bool lazy = vd->storage_class & STClazy; - +#if DMDV2 + if (!refout) +#else if (!refout && (!f->fty.args[i]->byref || lazy)) +#endif { // alloca a stack slot for this first class value arg const LLType* argt; diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 518c85eb..575edffc 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -86,7 +86,12 @@ void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval) return; } - DtoStore(val->getRVal(), lval); + LLValue *rval = val->getRVal(); +#if DMDV2 + if (DtoIsPassedByRef(val->type)) + rval = DtoLoad(rval); +#endif + DtoStore(rval, lval); } //////////////////////////////////////////////////////////////////////////////