Skip to content

Commit

Permalink
fixup: compiler alias analysis: Avoid redundant database changes
Browse files Browse the repository at this point in the history
Forgotten cases when a variable is first created and then immediately
set to aliased.
  • Loading branch information
frej committed Aug 2, 2024
1 parent 902574c commit 66280c7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/compiler/src/beam_ssa_alias.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1123,29 +1123,25 @@ aa_bif(Dst, element, [#b_literal{val=Idx},Tuple], SS, _AAS)
%% point in trying to provide aa_tuple_extraction/5 with type
%% information.
aa_tuple_extraction(Dst, Tuple, #b_literal{val=Idx-1}, #{}, SS);
aa_bif(Dst, element, [#b_literal{},Tuple], SS0, _AAS) ->
aa_bif(Dst, element, [#b_literal{},Tuple], SS, _AAS) ->
%% This BIF will fail, but in order to avoid any later transforms
%% making use of uniqueness, conservatively alias.
SS = beam_ssa_ss:add_var(Dst, unique, SS0),
aa_set_aliased([Dst,Tuple], SS);
aa_bif(Dst, element, [#b_var{},Tuple], SS0, _AAS) ->
SS = beam_ssa_ss:add_var(Dst, unique, SS0),
aa_bif(Dst, element, [#b_var{},Tuple], SS, _AAS) ->
aa_set_aliased([Dst,Tuple], SS);
aa_bif(Dst, hd, [Pair], SS0, _AAS) ->
aa_bif(Dst, hd, [Pair], SS, _AAS) ->
%% The hd bif is always rewritten to a get_hd instruction when the
%% argument is known to be a pair. Therefore this code is only
%% reached when the type of Pair is unknown, thus there is no
%% point in trying to provide aa_pair_extraction/5 with type
%% information.
SS = beam_ssa_ss:add_var(Dst, unique, SS0),
aa_pair_extraction(Dst, Pair, hd, SS);
aa_bif(Dst, tl, [Pair], SS0, _AAS) ->
aa_bif(Dst, tl, [Pair], SS, _AAS) ->
%% The tl bif is always rewritten to a get_tl instruction when the
%% argument is known to be a pair. Therefore this code is only
%% reached when the type of Pair is unknown, thus there is no
%% point in trying to provide aa_pair_extraction/5 with type
%% information.
SS = beam_ssa_ss:add_var(Dst, unique, SS0),
aa_pair_extraction(Dst, Pair, tl, SS);
aa_bif(Dst, map_get, [_Key,Map], SS, AAS) ->
aa_map_extraction(Dst, Map, SS, AAS);
Expand Down

0 comments on commit 66280c7

Please sign in to comment.