diff options
| author | Björn Gustavsson <bjorn@erlang.org> | 2023-03-09 12:55:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-09 12:55:22 +0100 |
| commit | 896518d196cd81ba26cb084827957a93b90220fb (patch) | |
| tree | 972b075cf83df021d1c0037f491b95f4c5f104ee /lib/compiler | |
| parent | 4bcd6108df51630322087c40e93ece5e631a01b9 (diff) | |
| parent | bb3cfdb32447f41ac2a27b7bd413434524b17b85 (diff) | |
| download | erlang-896518d196cd81ba26cb084827957a93b90220fb.tar.gz | |
Merge pull request #6992 from bjorng/bjorn/compiler/fix-unfold-literals
Eliminate assertion failure in beam_ssa_codegen
Diffstat (limited to 'lib/compiler')
| -rw-r--r-- | lib/compiler/src/beam_ssa_opt.erl | 2 | ||||
| -rw-r--r-- | lib/compiler/test/beam_except_SUITE.erl | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl index 4cbc7b375f..13e4114319 100644 --- a/lib/compiler/src/beam_ssa_opt.erl +++ b/lib/compiler/src/beam_ssa_opt.erl @@ -3022,6 +3022,8 @@ collect_arg_literals([V|Vs], Info, X, Acc0) -> collect_arg_literals([], _Info, _X, Acc) -> Acc. +unfold_literals([?EXCEPTION_BLOCK|Ls], LitMap, SafeMap, Blocks) -> + unfold_literals(Ls, LitMap, SafeMap,Blocks); unfold_literals([L|Ls], LitMap, SafeMap0, Blocks0) -> {Blocks,Safe} = case map_get(L, SafeMap0) of diff --git a/lib/compiler/test/beam_except_SUITE.erl b/lib/compiler/test/beam_except_SUITE.erl index 9a90c1b676..c52217ad79 100644 --- a/lib/compiler/test/beam_except_SUITE.erl +++ b/lib/compiler/test/beam_except_SUITE.erl @@ -22,7 +22,7 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, multiple_allocs/1,bs_get_tail/1,coverage/1, - binary_construction_allocation/1]). + binary_construction_allocation/1,unfold_literals/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -34,7 +34,8 @@ groups() -> [multiple_allocs, bs_get_tail, coverage, - binary_construction_allocation]}]. + binary_construction_allocation, + unfold_literals]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -177,6 +178,19 @@ do_binary_construction_allocation(Req) -> _ -> ok end. +unfold_literals(_Config) -> + a = do_unfold_literals(badarg, id({a,b})), + {'EXIT',{badarg,_}} = catch do_unfold_literals(badarg, id(a)), + + ok. + +do_unfold_literals(_BadArg, T) -> + %% The call `erlang:error(badarg)` in ?EXCEPTION_BLOCK would be + %% rewritten to `erlang:error(_BadArg)` by + %% beam_ssa_opt:unfold_literals/1, which would cause + %% beam_ssa_codegen:assert_exception_block/1 to fail. + element(1, T). + id(I) -> I. -file("fake.erl", 1). |
