summaryrefslogtreecommitdiff
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2023-04-18 07:20:50 +0200
committerBjörn Gustavsson <bjorn@erlang.org>2023-04-18 07:28:22 +0200
commitdedc07d6e600cb9b0c6cc89a862114a1ff071d85 (patch)
treeaeace4f7d3bb9dba24ff979ba552620f5d6f755e /lib/compiler
parent7022abd762883726cf33e616769aca3727ab0354 (diff)
downloaderlang-dedc07d6e600cb9b0c6cc89a862114a1ff071d85.tar.gz
Fix failure to load module with disabled optimizations
Closes #7128
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl2
-rw-r--r--lib/compiler/test/beam_ssa_SUITE.erl15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index e3406f12de..dc76755aad 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -680,7 +680,7 @@ sanitize([L|Ls], InBlocks, Count0, Values0, Blocks0) ->
no_change ->
Blk = sanitize_last(Blk0, Values0),
Blocks1 = Blocks0#{L := Blk},
- Blocks = sanitize_reachable(Blk0, Blocks1),
+ Blocks = sanitize_reachable(Blk, Blocks1),
sanitize(Ls, InBlocks, Count0, Values0, Blocks);
{Is,Last,Count,Values} ->
Blk1 = Blk0#b_blk{is=Is,last=Last},
diff --git a/lib/compiler/test/beam_ssa_SUITE.erl b/lib/compiler/test/beam_ssa_SUITE.erl
index f6b0eb2929..6a91bdd7b8 100644
--- a/lib/compiler/test/beam_ssa_SUITE.erl
+++ b/lib/compiler/test/beam_ssa_SUITE.erl
@@ -18,6 +18,7 @@
%% %CopyrightEnd%
%%
-module(beam_ssa_SUITE).
+-feature(maybe_expr, enable).
-export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1,
init_per_group/2,end_per_group/2,
@@ -904,6 +905,8 @@ grab_bag(_Config) ->
6 = grab_bag_21(id(64)),
{'EXIT',{badarith,_}} = catch grab_bag_21(id(a)),
+ false = grab_bag_22(),
+
ok.
grab_bag_1() ->
@@ -1180,6 +1183,18 @@ grab_bag_21(A) ->
grab_bag_21(_, D, _, _) ->
D.
+%% GH-7128: With optimizations disabled, the code would fail to
+%% load with the following message:
+%%
+%% beam/beam_load.c(367): Error loading function
+%% beam_ssa_no_opt_SUITE:grab_bag_22/0: op get_list: Sdd:
+%% bad tag 2 for destination
+grab_bag_22() ->
+ maybe
+ [_ | _] ?= ((true xor true) andalso foo),
+ bar ?= id(42)
+ end.
+
redundant_br(_Config) ->
{false,{x,y,z}} = redundant_br_1(id({x,y,z})),
{true,[[a,b,c]]} = redundant_br_1(id([[[a,b,c]]])),