diff options
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 7ef37a6082..9ff09911f9 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2022. All Rights Reserved. +%% Copyright Ericsson AB 1996-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -274,7 +274,10 @@ expand_opt(r23, Os) -> no_recv_opt, no_init_yregs | expand_opt(r24, Os)]); expand_opt(r24, Os) -> - expand_opt(no_type_opt, [no_bs_create_bin, no_ssa_opt_ranges | Os]); + expand_opt(no_type_opt, [no_bs_create_bin, no_ssa_opt_ranges | + expand_opt(r25, Os)]); +expand_opt(r25, Os) -> + [no_ssa_opt_update_tuple, no_bs_match, no_min_max_bifs | Os]; expand_opt(no_make_fun3, Os) -> [no_make_fun3, no_fun_opt | Os]; expand_opt({debug_info_key,_}=O, Os) -> @@ -288,6 +291,8 @@ expand_opt(no_type_opt=O, Os) -> no_ssa_opt_type_finish | Os]; expand_opt(no_module_opt=O, Os) -> [O,no_recv_opt | Os]; +expand_opt({check_ssa,Tag}, Os) -> + [check_ssa, Tag | Os]; expand_opt(O, Os) -> [O|Os]. -spec format_error(error_description()) -> iolist(). @@ -770,6 +775,16 @@ select_list_passes_1([P|Ps], Opts, Acc) -> select_list_passes_1([], _, Acc) -> {not_done,reverse(Acc)}. +make_ssa_check_pass(PassFlag) -> + F = fun (Code, St) -> + case beam_ssa_check:module(Code, PassFlag) of + ok -> {ok, Code, St}; + {error, Errors} -> + {error, St#compile{errors=St#compile.errors++Errors}} + end + end, + {iff, PassFlag, {PassFlag, F}}. + %% The standard passes (almost) always run. standard_passes() -> @@ -874,6 +889,7 @@ kernel_passes() -> {unless,no_bsm_opt,{iff,ssalint,{pass,beam_ssa_lint}}}, {unless,no_ssa_opt,{pass,beam_ssa_opt}}, + make_ssa_check_pass(post_ssa_opt), {iff,dssaopt,{listing,"ssaopt"}}, {unless,no_ssa_opt,{iff,ssalint,{pass,beam_ssa_lint}}}, @@ -1026,7 +1042,13 @@ do_parse_module(DefEncoding, #compile{ifile=File,options=Opts,dir=Dir}=St) -> {location,StartLocation}, {reserved_word_fun, ResWordFun}, {features, Features}, - extra]), + extra| + case member(check_ssa, Opts) of + true -> + [{compiler_internal,[ssa_checks]}]; + false -> + [] + end]), case R of %% FIXME Extra should include used features as well {ok,Forms0,Extra} -> @@ -1929,9 +1951,8 @@ output_encoding(F, #compile{encoding = Encoding}) -> diffable(Code0, St) -> {Mod,Exp,Attr,Fs0,NumLabels} = Code0, - EntryLabels0 = [{Entry,{Name,Arity}} || - {function,Name,Arity,Entry,_} <- Fs0], - EntryLabels = maps:from_list(EntryLabels0), + EntryLabels = #{Entry => {Name,Arity} || + {function,Name,Arity,Entry,_} <- Fs0}, Fs = [diffable_fix_function(F, EntryLabels) || F <- Fs0], Code = {Mod,Exp,Attr,Fs,NumLabels}, {ok,Code,St}. @@ -2080,6 +2101,7 @@ pre_load() -> beam_kernel_to_ssa, beam_opcodes, beam_ssa, + beam_ssa_alias, beam_ssa_bc_size, beam_ssa_bool, beam_ssa_bsm, @@ -2087,6 +2109,7 @@ pre_load() -> beam_ssa_dead, beam_ssa_opt, beam_ssa_pre_codegen, + beam_ssa_private_append, beam_ssa_recv, beam_ssa_share, beam_ssa_throw, |