Merge pull request #73 from aeternity/PT-162805991-fate-state
The state is always live to prevent bad optimizations
This commit is contained in:
commit
098dac65e2
@ -40,6 +40,8 @@
|
||||
-define(a, {stack, 0}).
|
||||
-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), (
|
||||
Op =:= 'STORE' 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 => 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, {i, Ann, _}) -> live_in(R, Ann);
|
||||
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(_, []) -> false.
|
||||
|
||||
live_out(R, _) when ?IsState(R) -> true;
|
||||
live_out(R, #{ live_out := LiveOut }) -> ordsets:is_element(R, LiveOut).
|
||||
|
||||
%% -- Optimizations --
|
||||
|
Loading…
x
Reference in New Issue
Block a user