diff options
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 61c2512222..390effeb41 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -291,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(). @@ -773,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() -> @@ -877,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}}}, @@ -1029,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} -> |