From bc4f3fdbbde6547f4523a92010da824dee7ab8bc Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Fri, 17 Mar 2023 17:34:55 +0300 Subject: [PATCH] Separate the split at CALL_T and loop --- src/aeso_fcode_to_fate.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index 768e5ba..3c349bc 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -1892,7 +1892,8 @@ tweak_returns(Code) -> Code. %% -- Split basic blocks at CALL instructions -- %% Calls can only return to a new basic block. Also splits at JUMPIF instructions. - +%% Split at CALL_T and JUMP only when DBG_RETURN op is enabled + split_calls({Ref, Code}) -> split_calls(Ref, Code, [], []). @@ -1905,9 +1906,11 @@ split_calls(Ref, [I | Code], Acc, Blocks) when element(1, I) == 'CALL'; element(1, I) == 'CREATE'; element(1, I) == 'CLONE'; element(1, I) == 'CLONE_G'; - element(1, I) == 'jumpif'; - element(1, I) == 'CALL_T' andalso Code =/= []; - I == loop andalso Code =/= [] -> + element(1, I) == 'jumpif' -> + split_calls(make_ref(), Code, [], [{Ref, lists:reverse([I | Acc])} | Blocks]); +split_calls(Ref, [I | Code = ['DBG_RETURN' | _]], Acc, Blocks) + when element(1, I) == 'CALL_T'; + I == loop -> split_calls(make_ref(), Code, [], [{Ref, lists:reverse([I | Acc])} | Blocks]); split_calls(Ref, [{'ABORT', _} = I | _Code], Acc, Blocks) -> lists:reverse([{Ref, lists:reverse([I | Acc])} | Blocks]);