aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-11-02 10:16:59 +0100
committerBjörn Gustavsson <[email protected]>2018-11-02 10:16:59 +0100
commitad8ef2bda1fa8cc337e581dca0c67cfc756f5e4f (patch)
tree634f5c219153593919a3ffe7d3f1c4caa502d4d4 /lib/compiler/src
parent9c33f00f78724ce0f68fef1dfc6ab4810d8c45f1 (diff)
parent3e742b1d270069ede1aa8b6ae69c83fc6e71f814 (diff)
downloadotp-ad8ef2bda1fa8cc337e581dca0c67cfc756f5e4f.tar.gz
otp-ad8ef2bda1fa8cc337e581dca0c67cfc756f5e4f.tar.bz2
otp-ad8ef2bda1fa8cc337e581dca0c67cfc756f5e4f.zip
Merge branch 'maint'
* maint: Fix bug when beam_jump removes put_tuple instructions Conflicts: lib/compiler/src/beam_jump.erl lib/compiler/test/beam_jump_SUITE.erl
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_jump.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl
index d694bd2a5b..edc4522cc7 100644
--- a/lib/compiler/src/beam_jump.erl
+++ b/lib/compiler/src/beam_jump.erl
@@ -128,7 +128,7 @@
%%% on the program state.
%%%
--import(lists, [foldl/3,mapfoldl/3,reverse/1,reverse/2]).
+-import(lists, [dropwhile/2,foldl/3,mapfoldl/3,reverse/1,reverse/2]).
-type instruction() :: beam_utils:instruction().
@@ -522,14 +522,19 @@ opt_useless_loads([{test,_,{f,L},_}=I|Is], L, St) ->
opt_useless_loads(Is, _L, St) ->
{Is,St}.
-opt_useless_block_loads([{set,[Dst],_,_}=I|Is], L, Index) ->
- BlockJump = [{block,Is},{jump,{f,L}}],
+opt_useless_block_loads([{set,[Dst],_,_}=I|Is0], L, Index) ->
+ BlockJump = [{block,Is0},{jump,{f,L}}],
case beam_utils:is_killed(Dst, BlockJump, Index) of
true ->
- %% The register is killed and not used, we can remove the load
+ %% The register is killed and not used, we can remove the load.
+ %% Remove any `put` instructions in case we just
+ %% removed a `put_tuple` instruction.
+ Is = dropwhile(fun({set,_,_,put}) -> true;
+ (_) -> false
+ end, Is0),
opt_useless_block_loads(Is, L, Index);
false ->
- [I|opt_useless_block_loads(Is, L, Index)]
+ [I|opt_useless_block_loads(Is0, L, Index)]
end;
opt_useless_block_loads([I|Is], L, Index) ->
[I|opt_useless_block_loads(Is, L, Index)];