diff gen/functions.cpp @ 1042:45af482e3832

Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 04 Mar 2009 17:24:25 +0100
parents 9167d492cbc2
children a91d6fc600cd
line wrap: on
line diff
--- a/gen/functions.cpp	Wed Mar 04 16:13:16 2009 +0100
+++ b/gen/functions.cpp	Wed Mar 04 17:24:25 2009 +0100
@@ -684,9 +684,6 @@
             IrLocal* irloc = vd->ir.irLocal;
             assert(irloc);
 
-            // let the abi transform the argument back first
-            LLValue* argvalue = f->fty->getParam(vd->type, i, irloc->value);
-
         #if DMDV2
             if (vd->nestedrefs.dim)
         #else
@@ -701,11 +698,17 @@
 
             if (!refout && (!f->fty->args[i]->byref || lazy))
             {
-                LLValue* a = argvalue;
-                LLValue* v = DtoAlloca(a->getType(), vd->ident->toChars());
-                DtoStore(a,v);
-                irloc->value = v;
+                // alloca a stack slot for this first class value arg
+                LLValue* mem = DtoAlloca(DtoType(vd->type), vd->ident->toChars());
+
+                // let the abi transform the argument back first
+                DImValue arg_dval(vd->type, irloc->value);
+                f->fty->getParam(vd->type, i, &arg_dval, mem);
+
+                // set the arg var value to the alloca
+                irloc->value = mem;
             }
+
             if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout)
                 DtoDwarfLocalVariable(irloc->value, vd);
         }