aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-08-02 10:39:55 +0200
committerBjörn Gustavsson <[email protected]>2019-08-02 10:39:55 +0200
commite1a2c49be73a8bafdae0aabb32d83c3e9a64c652 (patch)
treebb8df95164e472fcf578d2cc761b7d7a591c4a70 /lib/compiler/src
parent2c6fa6c21cc373f67bddef658b53fd8ababff127 (diff)
parent773e3d0f4a2d978a7ec6be9ed639eb1941d92d6c (diff)
downloadotp-e1a2c49be73a8bafdae0aabb32d83c3e9a64c652.tar.gz
otp-e1a2c49be73a8bafdae0aabb32d83c3e9a64c652.tar.bz2
otp-e1a2c49be73a8bafdae0aabb32d83c3e9a64c652.zip
Merge branch 'bjorn/compiler/fix-no_type_opt/ERL-997' of https://github.com/bjorng/otp into maint
OTP-15969 * 'bjorn/compiler/fix-no_type_opt/ERL-997' of https://github.com/bjorng/otp: Fix compiler crash when compiling with +no_type_opt
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_ssa_opt.erl18
-rw-r--r--lib/compiler/src/compile.erl7
2 files changed, 20 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl
index 229edc6a1d..d87c66c272 100644
--- a/lib/compiler/src/beam_ssa_opt.erl
+++ b/lib/compiler/src/beam_ssa_opt.erl
@@ -1939,12 +1939,24 @@ verify_merge_is(_) ->
is_merge_allowed(_, #b_blk{}, #b_blk{is=[#b_set{op=peek_message}|_]}) ->
false;
-is_merge_allowed(L, #b_blk{last=#b_br{}}=Blk, #b_blk{}) ->
+is_merge_allowed(L, #b_blk{last=#b_br{}}=Blk, #b_blk{is=Is}) ->
%% The predecessor block must have exactly one successor (L) for
%% the merge to be safe.
case beam_ssa:successors(Blk) of
- [L] -> true;
- [_|_] -> false
+ [L] ->
+ case Is of
+ [#b_set{op=phi,args=[_]}|_] ->
+ %% The type optimizer pass must have been
+ %% turned off, since it would have removed this
+ %% redundant phi node. Refuse to merge the blocks
+ %% to ensure that this phi node remains at the
+ %% beginning of a block.
+ false;
+ _ ->
+ true
+ end;
+ [_|_] ->
+ false
end;
is_merge_allowed(_, #b_blk{last=#b_switch{}}, #b_blk{}) ->
false.
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 28db8986ff..0325c714d0 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -268,8 +268,11 @@ expand_opt(r21, Os) ->
[no_put_tuple2 | expand_opt(no_bsm3, Os)];
expand_opt({debug_info_key,_}=O, Os) ->
[encrypt_debug_info,O|Os];
-expand_opt(no_type_opt, Os) ->
- [no_ssa_opt_type_start,
+expand_opt(no_type_opt=O, Os) ->
+ %% Be sure to keep the no_type_opt option so that it will
+ %% be recorded in the BEAM file, allowing the test suites
+ %% to recompile the file with this option.
+ [O,no_ssa_opt_type_start,
no_ssa_opt_type_continue,
no_ssa_opt_type_finish | Os];
expand_opt(O, Os) -> [O|Os].