Skip to content

Commit 0a20869

Browse files
committed
Properly mark stack slot for struct return as lvalue
1 parent 4bc39fe commit 0a20869

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gen/tocall.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
806806
(returnTy == Tstruct && !isaPointer(retllval)) ||
807807
(returnTy == Tsarray && isaArray(retllval));
808808

809+
bool retValIsAlloca = false;
810+
809811
// Ignore ABI for intrinsics
810812
if (!intrinsic && !retinptr)
811813
{
@@ -817,6 +819,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
817819
LLValue* mem = DtoRawAlloca(DtoType(dReturnType), 0);
818820
irFty.getRet(dReturnType, &dretval, mem);
819821
retllval = mem;
822+
retValIsAlloca = true;
820823
storeReturnValueOnStack = false;
821824
}
822825
else
@@ -834,6 +837,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
834837
LLValue* mem = DtoRawAlloca(retllval->getType(), 0);
835838
DtoStore(retllval, mem);
836839
retllval = mem;
840+
retValIsAlloca = true;
837841
}
838842

839843
// repaint the type if necessary
@@ -967,7 +971,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
967971
// if we are returning through a pointer arg
968972
// or if we are returning a reference
969973
// make sure we provide a lvalue back!
970-
if (retinptr || (tf->isref && returnTy != Tvoid))
974+
if (retinptr || (tf->isref && returnTy != Tvoid) || retValIsAlloca)
971975
return new DVarValue(resulttype, retllval);
972976

973977
return new DImValue(resulttype, retllval);

0 commit comments

Comments
 (0)