diff options
author | Erlang/OTP <[email protected]> | 2019-05-29 13:24:45 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2019-05-29 13:24:45 +0200 |
commit | f8072d772bf73f014f6d6e994ba5a6962cfde757 (patch) | |
tree | d95eb47e34370abb720e961547f3dc4b6d416b18 /lib/compiler/src/beam_ssa_dead.erl | |
parent | df4553e703673565db79e7a8340db86615a369ea (diff) | |
parent | 528f17ad9b85c4a3a1e28428606494550eef3a1e (diff) | |
download | otp-f8072d772bf73f014f6d6e994ba5a6962cfde757.tar.gz otp-f8072d772bf73f014f6d6e994ba5a6962cfde757.tar.bz2 otp-f8072d772bf73f014f6d6e994ba5a6962cfde757.zip |
Merge branch 'bjorng_ghub/bjorn/compiler/fix-beam_ssa_dead-crash/ERL-956/OTP-15848' into maint-22
* bjorng_ghub/bjorn/compiler/fix-beam_ssa_dead-crash/ERL-956/OTP-15848:
Eliminate crash in the beam_ssa_dead compiler pass
Diffstat (limited to 'lib/compiler/src/beam_ssa_dead.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa_dead.erl | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_ssa_dead.erl b/lib/compiler/src/beam_ssa_dead.erl index bb43a550ae..86f680c964 100644 --- a/lib/compiler/src/beam_ssa_dead.erl +++ b/lib/compiler/src/beam_ssa_dead.erl @@ -436,8 +436,22 @@ get_phi_arg([{Val,From}|_], From) -> Val; get_phi_arg([_|As], From) -> get_phi_arg(As, From). eval_terminator(#b_br{bool=#b_var{}=Bool}=Br, Bs, _St) -> - Val = get_value(Bool, Bs), - beam_ssa:normalize(Br#b_br{bool=Val}); + case get_value(Bool, Bs) of + #b_literal{val=Val}=Lit -> + case is_boolean(Val) of + true -> + beam_ssa:normalize(Br#b_br{bool=Lit}); + false -> + %% Non-boolean literal. This means that this `br` + %% terminator will never actually be reached with + %% these bindings. (There must be a previous two-way + %% branch that branches the other way when Bool + %% is bound to a non-boolean literal.) + none + end; + #b_var{}=Var -> + beam_ssa:normalize(Br#b_br{bool=Var}) + end; eval_terminator(#b_br{bool=#b_literal{}}=Br, _Bs, _St) -> beam_ssa:normalize(Br); eval_terminator(#b_switch{arg=Arg,fail=Fail,list=List}=Sw, Bs, St) -> |