@@ -806,6 +806,8 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
806
806
(returnTy == Tstruct && !isaPointer (retllval)) ||
807
807
(returnTy == Tsarray && isaArray (retllval));
808
808
809
+ bool retValIsAlloca = false ;
810
+
809
811
// Ignore ABI for intrinsics
810
812
if (!intrinsic && !retinptr)
811
813
{
@@ -817,6 +819,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
817
819
LLValue* mem = DtoRawAlloca (DtoType (dReturnType), 0 );
818
820
irFty.getRet (dReturnType, &dretval, mem);
819
821
retllval = mem;
822
+ retValIsAlloca = true ;
820
823
storeReturnValueOnStack = false ;
821
824
}
822
825
else
@@ -834,6 +837,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
834
837
LLValue* mem = DtoRawAlloca (retllval->getType (), 0 );
835
838
DtoStore (retllval, mem);
836
839
retllval = mem;
840
+ retValIsAlloca = true ;
837
841
}
838
842
839
843
// repaint the type if necessary
@@ -967,7 +971,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
967
971
// if we are returning through a pointer arg
968
972
// or if we are returning a reference
969
973
// make sure we provide a lvalue back!
970
- if (retinptr || (tf->isref && returnTy != Tvoid))
974
+ if (retinptr || (tf->isref && returnTy != Tvoid) || retValIsAlloca )
971
975
return new DVarValue (resulttype, retllval);
972
976
973
977
return new DImValue (resulttype, retllval);
0 commit comments