Skip to content

Commit e4f8905

Browse files
committed
Merge branch 'frej/fix-alias-analysis-error-for-maint-27/OTP-19178' into maint
* frej/fix-alias-analysis-error-for-maint-27/OTP-19178: compiler alias analysis: Fix bug in status of map extracts
2 parents fa954b7 + 0785e84 commit e4f8905

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/compiler/src/beam_ssa_alias.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ aa_derive_from(_Dst, [], _, State0) ->
660660
aa_derive_from(Dst, Parent, Types, State0) ->
661661
aa_derive_from1(Dst, Parent, Types, State0).
662662

663+
aa_derive_from1(#b_var{}=Dst, #b_literal{val=Val}, _, State) when is_map(Val) ->
664+
aa_set_aliased(Dst, State);
663665
aa_derive_from1(#b_var{}, #b_literal{}, _, State) ->
664666
State;
665667
aa_derive_from1(Dst, Parent, Types, State) ->

lib/compiler/test/beam_ssa_check_SUITE_data/alias.erl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
not_transformable3/1,
5959
not_transformable4/1,
6060
not_transformable5/1,
61+
not_transformable6/0,
6162

6263
bad_get_status_by_type/0,
6364
stacktrace0/0,
@@ -635,6 +636,17 @@ not_transformable5b([H|T], Acc) ->
635636
not_transformable5b([], Acc) ->
636637
Acc.
637638

639+
%% Check that anything extracted from a map is aliased. This is
640+
%% required as otherwise the destructive update pass could try to
641+
%% update a literal.
642+
not_transformable6() ->
643+
%ssa% () when post_ssa_opt ->
644+
%ssa% E = get_map_element(...),
645+
%ssa% _ = bs_create_bin(append, _, E, ...) { aliased => [E], first_fragment_dies => true }.
646+
M = #{a=> <<>>},
647+
#{a:=X} = M,
648+
<<X/binary, 17:8>>.
649+
638650
%% Reproducer for a bug in beam_ssa_alias:aa_get_status_by_type/2
639651
%% where it would return the wrong alias/uniqe status for certain
640652
%% combinations of returned types.

0 commit comments

Comments
 (0)