Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate crash in beam_ssa_bool #6190

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/compiler/src/beam_ssa_bool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,11 @@ pre_opt_terminator(#b_switch{arg=Arg0}=Sw0, Sub, Blocks) ->
pre_opt_sw(#b_switch{arg=Arg,fail=Fail}=Sw, False, True, Sub, Blocks) ->
case Sub of
#{Arg:={true_or_any,PhiL}} ->
#{Fail:=FailBlk,False:=FalseBlk,PhiL:=PhiBlk} = Blocks,
#{Fail := FailBlk,False := FalseBlk} = Blocks,
PhiBlk = case Blocks of
#{PhiL := PhiBlk0} -> PhiBlk0;
#{} -> none
end,
case {FailBlk,FalseBlk,PhiBlk} of
{#b_blk{is=[],last=#b_br{succ=PhiL,fail=PhiL}},
#b_blk{is=[],last=#b_br{succ=PhiL,fail=PhiL}},
Expand Down
11 changes: 11 additions & 0 deletions lib/compiler/test/guard_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,7 @@ beam_bool_SUITE(_Config) ->
beam_ssa_bool_coverage(),
bad_map_in_guard(),
gh_6164(),
gh_6184(),
ok.

before_and_inside_if() ->
Expand Down Expand Up @@ -3076,6 +3077,16 @@ do_gh_6164(V1) ->
end
end.

gh_6184() ->
{'EXIT',{function_clause,_}} = catch do_gh_6184(id(true), id({a,b,c})),
{'EXIT',{function_clause,_}} = catch do_gh_6184(true, true),
{'EXIT',{function_clause,_}} = catch do_gh_6184({a,b,c}, {x,y,z}),

ok.

do_gh_6184(V1, V2) when (false and is_tuple(V2)) andalso (V1 orelse V2) ->
V2 orelse V2.

-record(bad_map_in_guard, {name}).
bad_map_in_guard() ->
error = bad_map_in_guard_1().
Expand Down