aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_pre_codegen.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-12-05 12:36:47 +0100
committerBjörn Gustavsson <[email protected]>2018-12-05 12:49:45 +0100
commit235bf91dc47888e16224e4a25e636cc741173d7f (patch)
tree09e482e4950f922ce32b452f0870643d8fe9059b /lib/compiler/src/beam_ssa_pre_codegen.erl
parent09b620eae7ebb623d7e62cbcab28c06e65d90008 (diff)
downloadotp-235bf91dc47888e16224e4a25e636cc741173d7f.tar.gz
otp-235bf91dc47888e16224e4a25e636cc741173d7f.tar.bz2
otp-235bf91dc47888e16224e4a25e636cc741173d7f.zip
beam_ssa_pre_codegen: Fix an internal consistency failure
The following function: is_two_tuple(Arg) -> case is_tuple(Arg) of false -> false; true -> tuple_size(Arg) == 2 end. would cause an internal consistency failure: Internal consistency check failed - please report this bug. Instruction: {bif,tuple_size,{f,0},[{x,0}],{z,0}} Error: {invalid_store,{z,0},{integer,[]}}:
Diffstat (limited to 'lib/compiler/src/beam_ssa_pre_codegen.erl')
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index 32232e9b9f..56fe9b4793 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -1994,13 +1994,15 @@ reserve_zregs(Blocks, Intervals, Res) ->
beam_ssa:fold_rpo(F, [0], Res, Blocks).
reserve_zreg([#b_set{op={bif,tuple_size},dst=Dst},
- #b_set{op={bif,'=:='},args=[Dst,Val]}], _Last, ShortLived, A0) ->
- case Val of
- #b_literal{val=Arity} when Arity bsr 32 =:= 0 ->
+ #b_set{op={bif,'=:='},args=[Dst,Val]}], Last, ShortLived, A0) ->
+ case {Val,Last} of
+ {#b_literal{val=Arity},#b_br{}} when Arity bsr 32 =:= 0 ->
%% These two instructions can be combined to a test_arity
%% instruction provided that the arity variable is short-lived.
reserve_zreg_1(Dst, ShortLived, A0);
- _ ->
+ {_,_} ->
+ %% Either the arity is too big, or the boolean value from
+ %% '=:=' will be returned.
A0
end;
reserve_zreg([#b_set{op={bif,tuple_size},dst=Dst}],