aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-06-10 17:21:52 +0200
committerJohn Högberg <[email protected]>2019-06-10 17:26:55 +0200
commita726c015867beffe15cc20ee22e32778678e8fdf (patch)
treefc51318cfa6b66815108a31e62d2e495e0093154 /lib/compiler/src
parentabbe8d424676a473bcebdf3b97996ac7a5a70f16 (diff)
downloadotp-a726c015867beffe15cc20ee22e32778678e8fdf.tar.gz
otp-a726c015867beffe15cc20ee22e32778678e8fdf.tar.bz2
otp-a726c015867beffe15cc20ee22e32778678e8fdf.zip
beam_ssa_type: Fix incorrect bitstring unit determination
The compiler would treat the "Unit" of bs_init instructions as the unit of the result instead of the required unit of the input, causing is_binary checks to be wrongly optimized away.
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_ssa_type.erl11
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl
index 57fd7fec60..68920e7dd3 100644
--- a/lib/compiler/src/beam_ssa_type.erl
+++ b/lib/compiler/src/beam_ssa_type.erl
@@ -840,15 +840,8 @@ type({bif,Bif}, Args, Ts, _Ds) ->
Type ->
Type
end;
-type(bs_init, [#b_literal{val=Type}|Args], _Ts, _Ds) ->
- case {Type,Args} of
- {new,[_,#b_literal{val=Unit}]} ->
- {binary,Unit};
- {append,[_,_,#b_literal{val=Unit}]} ->
- {binary,Unit};
- {private_append,[_,_,#b_literal{val=Unit}]} ->
- {binary,Unit}
- end;
+type(bs_init, _Args, _Ts, _Ds) ->
+ {binary, 1};
type(bs_extract, [Ctx], Ts, _Ds) ->
#t_bs_match{type=Type} = get_type(Ctx, Ts),
Type;