aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_pre_codegen.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-07-10 15:41:13 +0200
committerJohn Högberg <[email protected]>2019-07-10 18:04:45 +0200
commit9ca0e82455297040069b8274649e7ddd28a5d65b (patch)
treee26660518783d87e46262d38d51207e73e7f582e /lib/compiler/src/beam_ssa_pre_codegen.erl
parentfa5e2cae48323a391ff65512a972d6c9f4ba4119 (diff)
downloadotp-9ca0e82455297040069b8274649e7ddd28a5d65b.tar.gz
otp-9ca0e82455297040069b8274649e7ddd28a5d65b.tar.bz2
otp-9ca0e82455297040069b8274649e7ddd28a5d65b.zip
compiler: Fix compiler crash introduced by OTP-15952
An assertion in code generation would fail when the common exit block was ?BADARG_BLOCK, as some operations expect to always "fail" directly to that block (= throw an exception) and we had inserted a dummy block in between. Other operations could also get funny fail labels, jumping to blocks that immediately jumped to {f,0}, but these were all cleaned up by beam_jump, sweeping the bug under the rug.
Diffstat (limited to 'lib/compiler/src/beam_ssa_pre_codegen.erl')
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index a2e687930b..7ef604d444 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -1472,10 +1472,14 @@ find_loop_exit([L1,L2|_Ls], Blocks) ->
find_loop_exit_1(Path1, cerl_sets:from_list(Path2));
find_loop_exit(_, _) -> none.
+find_loop_exit_1([?BADARG_BLOCK | T], OtherPath) ->
+ %% ?BADARG_BLOCK is a marker and not an actual block, so we can't consider
+ %% it to be a common block even if both paths cross it.
+ find_loop_exit_1(T, OtherPath);
find_loop_exit_1([H|T], OtherPath) ->
case cerl_sets:is_element(H, OtherPath) of
true -> H;
- false -> find_loop_exit_1(T, OtherPath)
+ false -> find_loop_exit_1(T, OtherPath)
end;
find_loop_exit_1([], _) -> none.