comparison 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
comparison
equal deleted inserted replaced
1041:9dca7182aa75 1042:45af482e3832
682 assert(vd); 682 assert(vd);
683 683
684 IrLocal* irloc = vd->ir.irLocal; 684 IrLocal* irloc = vd->ir.irLocal;
685 assert(irloc); 685 assert(irloc);
686 686
687 // let the abi transform the argument back first
688 LLValue* argvalue = f->fty->getParam(vd->type, i, irloc->value);
689
690 #if DMDV2 687 #if DMDV2
691 if (vd->nestedrefs.dim) 688 if (vd->nestedrefs.dim)
692 #else 689 #else
693 if (vd->nestedref) 690 if (vd->nestedref)
694 #endif 691 #endif
699 bool refout = vd->storage_class & (STCref | STCout); 696 bool refout = vd->storage_class & (STCref | STCout);
700 bool lazy = vd->storage_class & STClazy; 697 bool lazy = vd->storage_class & STClazy;
701 698
702 if (!refout && (!f->fty->args[i]->byref || lazy)) 699 if (!refout && (!f->fty->args[i]->byref || lazy))
703 { 700 {
704 LLValue* a = argvalue; 701 // alloca a stack slot for this first class value arg
705 LLValue* v = DtoAlloca(a->getType(), vd->ident->toChars()); 702 LLValue* mem = DtoAlloca(DtoType(vd->type), vd->ident->toChars());
706 DtoStore(a,v); 703
707 irloc->value = v; 704 // let the abi transform the argument back first
705 DImValue arg_dval(vd->type, irloc->value);
706 f->fty->getParam(vd->type, i, &arg_dval, mem);
707
708 // set the arg var value to the alloca
709 irloc->value = mem;
708 } 710 }
711
709 if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout) 712 if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout)
710 DtoDwarfLocalVariable(irloc->value, vd); 713 DtoDwarfLocalVariable(irloc->value, vd);
711 } 714 }
712 } 715 }
713 716