aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_reorder.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-05-23 08:40:23 +0200
committerBjörn Gustavsson <[email protected]>2016-05-23 08:40:23 +0200
commitd0554c760abc10f0c90348c8d3b63ca6110c6938 (patch)
tree06d2ce826e524951002883329291c1dfa9c6199f /lib/compiler/src/beam_reorder.erl
parentde114bb8523486c0174eb763b939fbdb34aa9421 (diff)
parent69dd6018b7731becda651393b837639746aa63c7 (diff)
downloadotp-d0554c760abc10f0c90348c8d3b63ca6110c6938.tar.gz
otp-d0554c760abc10f0c90348c8d3b63ca6110c6938.tar.bz2
otp-d0554c760abc10f0c90348c8d3b63ca6110c6938.zip
Merge branch 'bjorn/compiler/misc'
* bjorn/compiler/misc: beam_bool_SUITE: Cover one more line beam_utils_SUITE: Cover more lines in beam_utils beam_reorder: Don't confuse beam_validator beam_bool: Reject potentially unsafe optimization v3_core: Don't depend on sys_core_fold for cleaning up beam_type: Eliminate crash beam_type: Correct handling of setelement/3 beam_validator: Handle cons literals better beam_validator: Keep better track of tuple literals
Diffstat (limited to 'lib/compiler/src/beam_reorder.erl')
-rw-r--r--lib/compiler/src/beam_reorder.erl9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_reorder.erl b/lib/compiler/src/beam_reorder.erl
index f1c0b3ef91..6a7c033ec6 100644
--- a/lib/compiler/src/beam_reorder.erl
+++ b/lib/compiler/src/beam_reorder.erl
@@ -87,6 +87,15 @@ reorder_1([{test,_,_,_}=I,
%% instruction between the test instruction and the select
%% instruction.
reorder_1(Is, D, [S,I|Acc]);
+reorder_1([{test,_,{f,_},[Src|_]}=I|Is], D,
+ [{get_tuple_element,Src,_,_}|_]=Acc) ->
+ %% We want to avoid code that can confuse beam_validator such as:
+ %% is_tuple Fail Src
+ %% test_arity Fail Src Arity
+ %% is_map Fail Src
+ %% get_tuple_element Src Pos Dst
+ %% Therefore, don't reorder the instructions in such cases.
+ reorder_1(Is, D, [I|Acc]);
reorder_1([{test,_,{f,L},Ss}=I|Is0], D0,
[{get_tuple_element,_,_,El}=G|Acc0]=Acc) ->
case member(El, Ss) of