Merge pull request #73 from aeternity/PT-162805991-fate-state

The state is always live to prevent bad optimizations
This commit is contained in:
Tobias Lindahl 2019-05-28 09:59:22 +02:00 committed by GitHub
commit 098dac65e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,8 @@
-define(a, {stack, 0}). -define(a, {stack, 0}).
-define(s, {var, -1}). %% TODO: until we have state support in FATE -define(s, {var, -1}). %% TODO: until we have state support in FATE
-define(IsState(X), (is_tuple(X) andalso tuple_size(X) =:= 2 andalso element(1, X) =:= var andalso element(2, X) < 0)).
-define(IsOp(Op), ( -define(IsOp(Op), (
Op =:= 'STORE' orelse Op =:= 'STORE' orelse
Op =:= 'ADD' orelse Op =:= 'ADD' orelse
@ -807,6 +809,7 @@ swap_instrs({i, #{ live_in := Live1 }, I}, {i, #{ live_in := Live2, live_out :=
{{i, #{ live_in => Live1, live_out => Live2_ }, J}, {{i, #{ live_in => Live1, live_out => Live2_ }, J},
{i, #{ live_in => Live2_, live_out => Live3 }, I}}. {i, #{ live_in => Live2_, live_out => Live3 }, I}}.
live_in(R, _) when ?IsState(R) -> true;
live_in(R, #{ live_in := LiveIn }) -> ordsets:is_element(R, LiveIn); live_in(R, #{ live_in := LiveIn }) -> ordsets:is_element(R, LiveIn);
live_in(R, {i, Ann, _}) -> live_in(R, Ann); live_in(R, {i, Ann, _}) -> live_in(R, Ann);
live_in(R, [I = {i, _, _} | _]) -> live_in(R, I); live_in(R, [I = {i, _, _} | _]) -> live_in(R, I);
@ -816,6 +819,7 @@ live_in(R, [{switch, A, _, Alts, Def} | _]) ->
live_in(_, missing) -> false; live_in(_, missing) -> false;
live_in(_, []) -> false. live_in(_, []) -> false.
live_out(R, _) when ?IsState(R) -> true;
live_out(R, #{ live_out := LiveOut }) -> ordsets:is_element(R, LiveOut). live_out(R, #{ live_out := LiveOut }) -> ordsets:is_element(R, LiveOut).
%% -- Optimizations -- %% -- Optimizations --