diff --git a/compiler/jvm/njvmcal.pas b/compiler/jvm/njvmcal.pas index 1d0f998bf6..3ec17c7246 100644 --- a/compiler/jvm/njvmcal.pas +++ b/compiler/jvm/njvmcal.pas @@ -36,7 +36,7 @@ interface tjvmcallnode = class(tcgcallnode) protected procedure set_result_location(realresdef: tstoreddef); override; - procedure release_unused_return_value_cpu;override; + procedure do_release_unused_return_value;override; procedure extra_post_call_code; override; end; @@ -62,7 +62,7 @@ implementation end; - procedure tjvmcallnode.release_unused_return_value_cpu; + procedure tjvmcallnode.do_release_unused_return_value; begin case resultdef.size of 0: diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas index 6ea30e5a8d..fa11523ef4 100644 --- a/compiler/ncgcal.pas +++ b/compiler/ncgcal.pas @@ -81,7 +81,7 @@ interface { if an unused return value is in another location than a LOC_REFERENCE, this method will be called to perform the necessary cleanups. By default it does not do anything } - procedure release_unused_return_value_cpu;virtual; + procedure do_release_unused_return_value;virtual; public procedure pass_generate_code;override; destructor destroy;override; @@ -316,9 +316,16 @@ implementation end; - procedure tcgcallnode.release_unused_return_value_cpu; + procedure tcgcallnode.do_release_unused_return_value; begin - { do nothing } + case location.loc of + LOC_REFERENCE : + begin + if is_managed_type(resultdef) then + hlcg.g_finalize(current_asmdata.CurrAsmList,resultdef,location.reference); + tg.ungetiftemp(current_asmdata.CurrAsmList,location.reference); + end; + end; end; @@ -437,20 +444,11 @@ implementation tree is generated, because that converts the temp from persistent to normal } if not(cnf_return_value_used in callnodeflags) then begin - case location.loc of - LOC_REFERENCE : - begin - if is_managed_type(resultdef) then - hlcg.g_finalize(current_asmdata.CurrAsmList,resultdef,location.reference); - tg.ungetiftemp(current_asmdata.CurrAsmList,location.reference); - end; - else - release_unused_return_value_cpu; - end; + do_release_unused_return_value; if (retloc.intsize<>0) then paramanager.freecgpara(current_asmdata.CurrAsmList,retloc); location_reset(location,LOC_VOID,OS_NO); - end; + end; end; diff --git a/compiler/x86/nx86cal.pas b/compiler/x86/nx86cal.pas index 4fec24fc02..fa0437300d 100644 --- a/compiler/x86/nx86cal.pas +++ b/compiler/x86/nx86cal.pas @@ -36,7 +36,7 @@ interface tx86callnode = class(tcgcallnode) protected - procedure release_unused_return_value_cpu;override; + procedure do_release_unused_return_value;override; end; @@ -51,7 +51,7 @@ implementation TX86CALLNODE *****************************************************************************} - procedure tx86callnode.release_unused_return_value_cpu; + procedure tx86callnode.do_release_unused_return_value; begin case location.loc of LOC_FPUREGISTER : @@ -59,7 +59,9 @@ implementation { release FPU stack } emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG); tcgx86(cg).dec_fpu_stack; - end; + end + else + inherited do_release_unused_return_value; end; end;