Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  compiler alias analysis: Fix bug in status of map extracts
  • Loading branch information
jhogberg committed Aug 7, 2024
2 parents 401748c + e4f8905 commit d5b148a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/compiler/src/beam_ssa_alias.erl
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ aa_derive_from(_Dst, [], _, State0) ->
aa_derive_from(Dst, Parent, Types, State0) ->
aa_derive_from1(Dst, Parent, Types, State0).

aa_derive_from1(#b_var{}=Dst, #b_literal{val=Val}, _, State) when is_map(Val) ->
aa_set_aliased(Dst, State);
aa_derive_from1(#b_var{}, #b_literal{}, _, State) ->
State;
aa_derive_from1(Dst, Parent, Types, State) ->
Expand Down
12 changes: 12 additions & 0 deletions lib/compiler/test/beam_ssa_check_SUITE_data/alias.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
not_transformable3/1,
not_transformable4/1,
not_transformable5/1,
not_transformable6/0,

bad_get_status_by_type/0,
stacktrace0/0,
Expand Down Expand Up @@ -635,6 +636,17 @@ not_transformable5b([H|T], Acc) ->
not_transformable5b([], Acc) ->
Acc.

%% Check that anything extracted from a map is aliased. This is
%% required as otherwise the destructive update pass could try to
%% update a literal.
not_transformable6() ->
%ssa% () when post_ssa_opt ->
%ssa% E = get_map_element(...),
%ssa% _ = bs_create_bin(append, _, E, ...) { aliased => [E], first_fragment_dies => true }.
M = #{a=> <<>>},
#{a:=X} = M,
<<X/binary, 17:8>>.

%% Reproducer for a bug in beam_ssa_alias:aa_get_status_by_type/2
%% where it would return the wrong alias/uniqe status for certain
%% combinations of returned types.
Expand Down

0 comments on commit d5b148a

Please sign in to comment.