diff gen/statements.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 6bb04dbee21f
line wrap: on
line diff
--- a/gen/statements.cpp	Wed Mar 04 16:13:16 2009 +0100
+++ b/gen/statements.cpp	Wed Mar 04 17:24:25 2009 +0100
@@ -68,6 +68,8 @@
             // emit dbg line
             if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
 
+            // FIXME: is there ever a case where a sret return needs to be rewritten for the ABI?
+
             // get return pointer
             DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg);
             DValue* e = exp->toElem(p);
@@ -88,12 +90,9 @@
         else
         {
             if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
-            DValue* e = exp->toElem(p);
-            LLValue* v = e->getRVal();
-            delete e;
 
             // do abi specific transformations on the return value
-            v = p->func()->type->fty->putRet(exp->type, v);
+            LLValue* v = p->func()->type->fty->putRet(exp->type, exp->toElem(p));
 
             if (Logger::enabled())
                 Logger::cout() << "return value is '" <<*v << "'\n";