Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Linearize Pass #2020

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ jobs:
ocamlparam: '_,Oclassic=1'
disable_testcases: 'ocaml/testsuite/tests/typing-local/regression_cmm_unboxing.ml ocaml/testsuite/tests/int64-unboxing/test.ml'

- name: flambda2_no_cfg
config: --enable-middle-end=flambda2
os: ubuntu-latest
build_ocamlparam: _,ocamlcfg=0

- name: flambda2_macos
config: --enable-middle-end=flambda2
os: macos-latest
Expand Down
31 changes: 11 additions & 20 deletions backend/asmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ let write_ir prefix =
Linear_format.save filename linear_unit_info
end;
if should_save_cfg_before_emit () then begin
if not !Flambda_backend_flags.use_ocamlcfg then
Misc.fatal_error "Flag '-save-ir-after simplify_cfg' requires '-ocamlcfg'";
let filename = Compiler_pass.(to_output_filename Simplify_cfg ~prefix) in
cfg_unit_info.items <- List.rev cfg_unit_info.items;
Cfg_format.save filename cfg_unit_info
Expand Down Expand Up @@ -346,24 +344,17 @@ let compile_fundecl ~ppf_dump ~funcnames fd_cmm =
else Available_regs.fundecl fundecl)
++ pass_dump_if ppf_dump Flambda_backend_flags.davail
"Register availability analysis"
++ Profile.record ~accumulate:true "mach to linear" (fun (fd : Mach.fundecl) ->
if !Flambda_backend_flags.use_ocamlcfg then begin
fd
++ Profile.record ~accumulate:true "cfgize"
(Cfgize.fundecl
~before_register_allocation:false
~preserve_orig_labels:false
~simplify_terminators:true)
++ Compiler_hooks.execute_and_pipe Compiler_hooks.Cfg
++ pass_dump_cfg_if ppf_dump Flambda_backend_flags.dump_cfg "After linear_to_cfg"
++ Profile.record ~accumulate:true "save_cfg" save_cfg
++ Profile.record ~accumulate:true "cfg_reorder_blocks"
(reorder_blocks_random ppf_dump)
++ Profile.record ~accumulate:true "cfg_to_linear" Cfg_to_linear.run
end else begin
fd
++ Profile.record ~accumulate:true "linearize" Linearize.fundecl
end))
++ Profile.record ~accumulate:true "cfgize"
(Cfgize.fundecl
~before_register_allocation:false
~preserve_orig_labels:false
~simplify_terminators:true)
++ Compiler_hooks.execute_and_pipe Compiler_hooks.Cfg
++ pass_dump_cfg_if ppf_dump Flambda_backend_flags.dump_cfg "After cfgize"
++ Profile.record ~accumulate:true "save_cfg" save_cfg
++ Profile.record ~accumulate:true "cfg_reorder_blocks"
(reorder_blocks_random ppf_dump)
++ Profile.record ~accumulate:true "cfg_to_linear" Cfg_to_linear.run)
++ pass_dump_linear_if ppf_dump dump_linear "Linearized code")
++ Compiler_hooks.execute_and_pipe Compiler_hooks.Linear
++ Profile.record ~accumulate:true "scheduling" Scheduling.fundecl
Expand Down
12 changes: 4 additions & 8 deletions backend/cfg/cfg.mli
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,10 @@ val print_instruction :
exception handling. It has a lot of redundancy and the result of the
computation is not used.

Redundancy: linear_to_cfg reconstructs intraprocedural exception handling
stacks from linear IR and annotates each block with this information.
However, CFG instructions still include the original push/poptraps from
Linear.

To remove these push/poptraps from CFG IR, we need to split blocks at every
push/poptrap. Then, we can annotate the blocks with the top of the trap
stack, instead of carrying the copy of the stack. *)
CFG instructions still include push/poptraps. To remove these push/poptraps
from CFG IR, we need to split blocks at every push/poptrap. Then, we can
annotate the blocks with the top of the trap stack, instead of carrying the
copy of the stack. *)

(* CR-someday gyorsh: store label after separately and update after
reordering. *)
Expand Down
3 changes: 1 addition & 2 deletions backend/cfg/cfgize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,7 @@ let fundecl :
fun_contains_calls;
(* CR-someday mshinwell: [fun_poll] will need to be propagated in the
future, e.g. when writing a [Polling] equivalent on [Cfg]. We don't
do this at present since there is no need, and because
[Linear_to_cfg] doesn't have [fun_poll] available. *)
do this at present since there is no need. *)
fun_poll = _
} =
fundecl
Expand Down
Loading
Loading