From 80ed24a4f651f83e5b5cf48dd9b9086a84b17d25 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Mon, 3 Jun 2019 10:30:25 +0200 Subject: [PATCH] Fix bug in basic block generation (JUMPIF ends a basic block) --- src/aeso_fcode_to_fate.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index a30dd1e..213ab2c 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -1361,7 +1361,7 @@ tweak_returns(['RETURN' | Code = [{'ABORT', _} | _]]) -> Code; tweak_returns(Code) -> Code. %% -- Split basic blocks at CALL instructions -- -%% Calls can only return to a new basic block. +%% Calls can only return to a new basic block. Also splits at JUMPIF instructions. split_calls({Ref, Code}) -> split_calls(Ref, Code, [], []). @@ -1370,7 +1370,8 @@ split_calls(Ref, [], Acc, Blocks) -> lists:reverse([{Ref, lists:reverse(Acc)} | Blocks]); split_calls(Ref, [I | Code], Acc, Blocks) when element(1, I) == 'CALL'; element(1, I) == 'CALL_R'; - element(1, I) == 'CALL_GR' -> + element(1, I) == 'CALL_GR'; + element(1, I) == 'jumpif' -> split_calls(make_ref(), Code, [], [{Ref, lists:reverse([I | Acc])} | Blocks]); split_calls(Ref, [I | Code], Acc, Blocks) -> split_calls(Ref, Code, [I | Acc], Blocks). -- 2.30.2