From 7cbf18c6f395b2133ff1fd8c44cffbe4c7c8f28f Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Tue, 16 Jul 2024 16:53:55 +0300 Subject: [PATCH] * don't create block..end_block around WebAssembly inline asm routines --- compiler/wasm32/cpupi.pas | 3 ++- compiler/wasm32/hlcgcpu.pas | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/compiler/wasm32/cpupi.pas b/compiler/wasm32/cpupi.pas index fef5224e99..865c477acb 100644 --- a/compiler/wasm32/cpupi.pas +++ b/compiler/wasm32/cpupi.pas @@ -475,7 +475,8 @@ implementation procedure tcpuprocinfo.generate_exit_label(list: tasmlist); begin - list.concat(taicpu.op_none(a_end_block)); + if not (po_assembler in current_procinfo.procdef.procoptions) then + list.concat(taicpu.op_none(a_end_block)); inherited generate_exit_label(list); end; diff --git a/compiler/wasm32/hlcgcpu.pas b/compiler/wasm32/hlcgcpu.pas index 7eff526b6f..cb76ef76ba 100644 --- a/compiler/wasm32/hlcgcpu.pas +++ b/compiler/wasm32/hlcgcpu.pas @@ -2343,21 +2343,27 @@ implementation procedure thlcgwasm.gen_entry_code(list: TAsmList); begin inherited; - list.concat(taicpu.op_none(a_block)); - list.concat(taicpu.op_none(a_block)); + if not (po_assembler in current_procinfo.procdef.procoptions) then + begin + list.concat(taicpu.op_none(a_block)); + list.concat(taicpu.op_none(a_block)); + end; end; procedure thlcgwasm.gen_exit_code(list: TAsmList); begin - list.concat(taicpu.op_none(a_end_block)); - if ts_wasm_bf_exceptions in current_settings.targetswitches then - a_label(list,tcpuprocinfo(current_procinfo).CurrRaiseLabel); - if fevalstackheight<>0 then + if not (po_assembler in current_procinfo.procdef.procoptions) then + begin + list.concat(taicpu.op_none(a_end_block)); + if ts_wasm_bf_exceptions in current_settings.targetswitches then + a_label(list,tcpuprocinfo(current_procinfo).CurrRaiseLabel); + if fevalstackheight<>0 then {$ifdef DEBUG_WASMSTACK} - list.concat(tai_comment.Create(strpnew('!!! values remaining on stack at end of block !!!'))); + list.concat(tai_comment.Create(strpnew('!!! values remaining on stack at end of block !!!'))); {$else DEBUG_WASMSTACK} - internalerror(2021091801); + internalerror(2021091801); {$endif DEBUG_WASMSTACK} + end; inherited; end;