diff options
author | Björn Gustavsson <[email protected]> | 2018-09-06 07:33:56 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-09-12 14:19:03 +0200 |
commit | 0442b6a4587c0961febe3c6044d94d2ce7f8f469 (patch) | |
tree | 6a1d6a508bee0971fffe96fd5b4b58e3d46fa4df | |
parent | 48b844b196e115b2995661ec81c108610acc4b6a (diff) | |
download | otp-0442b6a4587c0961febe3c6044d94d2ce7f8f469.tar.gz otp-0442b6a4587c0961febe3c6044d94d2ce7f8f469.tar.bz2 otp-0442b6a4587c0961febe3c6044d94d2ce7f8f469.zip |
beam_ssa_pre_codegen: Fix bug in receive fixing
When creating a phi node for the common exit block of a receive,
the code failed to take into account that there could be more
than one predecessor to the exit block for each remove_message.
Rename exit_predessor/3 to exit_predessors/3 and make it return a
list of the predecessors.
-rw-r--r-- | lib/compiler/src/beam_ssa_pre_codegen.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl index 54aa2efaf6..7f67e315f5 100644 --- a/lib/compiler/src/beam_ssa_pre_codegen.erl +++ b/lib/compiler/src/beam_ssa_pre_codegen.erl @@ -1016,14 +1016,19 @@ recv_fix_common_1([], [], _Msg, Blocks) -> Blocks. fix_exit_phi_args([V|Vs], [Rm|Rms], Exit, Blocks) -> Path = beam_ssa:rpo([Rm], Blocks), - Pred = exit_predecessor(Path, Exit), - [{V,Pred}|fix_exit_phi_args(Vs, Rms, Exit, Blocks)]; + Preds = exit_predecessors(Path, Exit, Blocks), + [{V,Pred} || Pred <- Preds] ++ fix_exit_phi_args(Vs, Rms, Exit, Blocks); fix_exit_phi_args([], [], _, _) -> []. -exit_predecessor([Pred,Exit|_], Exit) -> - Pred; -exit_predecessor([_|Bs], Exit) -> - exit_predecessor(Bs, Exit). +exit_predecessors([L|Ls], Exit, Blocks) -> + Blk = map_get(L, Blocks), + case member(Exit, beam_ssa:successors(Blk)) of + true -> + [L|exit_predecessors(Ls, Exit, Blocks)]; + false -> + exit_predecessors(Ls, Exit, Blocks) + end; +exit_predecessors([], _Exit, _Blocks) -> []. %% fix_receive([Label], Defs, Blocks0, Count0) -> {Blocks,Count}. %% Add a copy instruction for all variables that are matched out and |