aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_utils.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-05-31 12:44:13 +0200
committerBjörn Gustavsson <[email protected]>2016-05-31 12:44:13 +0200
commit52f65fe8a1d4ccb31d2c38d1923ccb73a9059a92 (patch)
tree35903a83c15ea8ca9bb4b7b1fa75e6fc0ebdfc3f /lib/compiler/src/beam_utils.erl
parent0e40609c64538a58466de8cddf2a7f0aebaf65ef (diff)
parentb1b27719d713c0e62d3242bbf1da0600ea0a651f (diff)
downloadotp-52f65fe8a1d4ccb31d2c38d1923ccb73a9059a92.tar.gz
otp-52f65fe8a1d4ccb31d2c38d1923ccb73a9059a92.tar.bz2
otp-52f65fe8a1d4ccb31d2c38d1923ccb73a9059a92.zip
Merge branch 'bjorn/compiler/misc'
* bjorn/compiler/misc: Eliminate unsafe use of Y registers beam_validator: Add is_bitstring/1 as a safe BIF beam_validator: Remove uncovered line Teach beam_utils:is_pure_test/1 to handle is_bitstr and is_function2 beam_utils: Simplify handling of 'return' to eliminate uncovered line beam_jump: Clean up handling of labels before func_info beam_expect: Correctly handle blocks with multiple allocs v3_codegen: Don't confuse beam_validator v3_codegen: Correct code generation for an error/1 call in a guard beam_receive: Don't crash when encountering nonsensical code
Diffstat (limited to 'lib/compiler/src/beam_utils.erl')
-rw-r--r--lib/compiler/src/beam_utils.erl20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index 47703b4aa3..a15ecf633e 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -167,8 +167,7 @@ bif_to_test(is_record, [_,_,_]=Ops, Fail) -> {test,is_record,Fail,Ops}.
%% is_pure_test({test,Op,Fail,Ops}) -> true|false.
%% Return 'true' if the test instruction does not modify any
-%% registers and/or bit syntax matching state, nor modifies
-%% any bit syntax matching state.
+%% registers and/or bit syntax matching state.
%%
is_pure_test({test,is_eq,_,[_,_]}) -> true;
is_pure_test({test,is_ne,_,[_,_]}) -> true;
@@ -180,6 +179,8 @@ is_pure_test({test,is_nil,_,[_]}) -> true;
is_pure_test({test,is_nonempty_list,_,[_]}) -> true;
is_pure_test({test,test_arity,_,[_,_]}) -> true;
is_pure_test({test,has_map_fields,_,[_|_]}) -> true;
+is_pure_test({test,is_bitstr,_,[_]}) -> true;
+is_pure_test({test,is_function2,_,[_,_]}) -> true;
is_pure_test({test,Op,_,Ops}) ->
erl_internal:new_type_test(Op, length(Ops)).
@@ -324,8 +325,11 @@ check_liveness(R, [{deallocate,_}|Is], St) ->
{y,_} -> {killed,St};
_ -> check_liveness(R, Is, St)
end;
-check_liveness(R, [return|_], St) ->
- check_liveness_live_ret(R, 1, St);
+check_liveness({x,_}=R, [return|_], St) ->
+ case R of
+ {x,0} -> {used,St};
+ {x,_} -> {killed,St}
+ end;
check_liveness(R, [{call,Live,_}|Is], St) ->
case R of
{x,X} when X < Live -> {used,St};
@@ -534,14 +538,6 @@ check_liveness_at(R, Lbl, #live{lbl=Ll,res=ResMemorized}=St0) ->
check_liveness_ret(R, R, St) -> {used,St};
check_liveness_ret(_, _, St) -> {killed,St}.
-check_liveness_live_ret({x,R}, Live, St) ->
- if
- R < Live -> {used,St};
- true -> {killed,St}
- end;
-check_liveness_live_ret({y,_}, _, St) ->
- {killed,St}.
-
check_liveness_fail(_, _, _, 0, St) ->
{killed,St};
check_liveness_fail(R, Op, Args, Fail, St) ->