mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-27 14:32:08 +00:00
Fixed: a register from a return statement's value would not be freed
This commit is contained in:
parent
aa2ca77412
commit
e93b64f249
1 changed files with 5 additions and 4 deletions
|
@ -4757,6 +4757,8 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
|
|||
|
||||
ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build)
|
||||
{
|
||||
ExpEmit out(0, REGT_NIL);
|
||||
|
||||
// If we return nothing, use a regular RET opcode.
|
||||
// Otherwise just return the value we're given.
|
||||
if (Value == nullptr)
|
||||
|
@ -4765,11 +4767,11 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build)
|
|||
}
|
||||
else
|
||||
{
|
||||
ExpEmit ret = Value->Emit(build);
|
||||
out = Value->Emit(build);
|
||||
|
||||
// Check if it is a function call that simplified itself
|
||||
// into a tail call in which case we don't emit anything.
|
||||
if (!ret.Final)
|
||||
if (!out.Final)
|
||||
{
|
||||
if (Value->ValueType == TypeVoid)
|
||||
{ // Nothing is returned.
|
||||
|
@ -4777,12 +4779,11 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build)
|
|||
}
|
||||
else
|
||||
{
|
||||
build->Emit(OP_RET, RET_FINAL, ret.RegType | (ret.Konst ? REGT_KONST : 0), ret.RegNum);
|
||||
build->Emit(OP_RET, RET_FINAL, out.RegType | (out.Konst ? REGT_KONST : 0), out.RegNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExpEmit out;
|
||||
out.Final = true;
|
||||
return out;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue