From 9f25b33446bf130cdbfb5c4dc8de9923d0ad4102 Mon Sep 17 00:00:00 2001 From: Luke Maurer Date: Thu, 31 Oct 2024 12:07:29 +0000 Subject: [PATCH] Remove addidentally-resurrected files --- middle_end/closure/closure_middle_end.ml | 76 ------- middle_end/flambda/flambda_middle_end.ml | 259 ----------------------- 2 files changed, 335 deletions(-) delete mode 100644 middle_end/closure/closure_middle_end.ml delete mode 100644 middle_end/flambda/flambda_middle_end.ml diff --git a/middle_end/closure/closure_middle_end.ml b/middle_end/closure/closure_middle_end.ml deleted file mode 100644 index e1b58afe839..00000000000 --- a/middle_end/closure/closure_middle_end.ml +++ /dev/null @@ -1,76 +0,0 @@ -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -[@@@ocaml.warning "+a-4-30-40-41-42"] - -let raw_clambda_dump_if ppf - ((ulambda, _, structured_constants) : Clambda.with_constants) = - if !Clflags.dump_rawclambda || !Clflags.dump_clambda then - begin - Format.fprintf ppf "@.clambda:@."; - Printclambda.clambda ppf ulambda; - List.iter (fun { Clambda. symbol; definition; _ } -> - Format.fprintf ppf "%s:@ %a@." - symbol - Printclambda.structured_constant definition) - structured_constants - end; - if !Clflags.dump_cmm then Format.fprintf ppf "@.cmm:@." - -let lambda_to_clambda ~backend ~filename:_ ~prefixname:_ ~ppf_dump - (lambda : Lambda.program) = - let size = - match lambda.module_block_format with - | Mb_record { mb_size; _ } -> mb_size - | Mb_wrapped_function _ -> - Misc.fatal_error "Parameterised modules not supported by Closure" - in - let clambda = Closure.intro ~backend ~size lambda.code in - let provenance : Clambda.usymbol_provenance = - let current_unit_ident = - Compilation_unit.get_current_exn () - |> Compilation_unit.name - |> Compilation_unit.Name.to_string - |> Ident.create_persistent - in - { original_idents = []; - (* CR-someday lmaurer: Properly construct a [Path.t] from the module name - with its pack prefix. *) - module_path = Path.Pident current_unit_ident; - } - in - let symbol = - Symbol.for_current_unit () - |> Symbol.linkage_name - |> Linkage_name.to_string - in - let preallocated_block = - Clambda.{ - symbol; - exported = true; - tag = 0; - fields = List.init size (fun _ -> None); - provenance = Some provenance; - } - in - let constants = Compilenv.structured_constants () in - Compilenv.clear_structured_constants (); - let clambda_and_constants = - clambda, [preallocated_block], constants - in - Compiler_hooks.execute Compiler_hooks.Raw_clambda clambda; - Compiler_hooks.execute Compiler_hooks.Clambda clambda; - raw_clambda_dump_if ppf_dump clambda_and_constants; - clambda_and_constants diff --git a/middle_end/flambda/flambda_middle_end.ml b/middle_end/flambda/flambda_middle_end.ml deleted file mode 100644 index 56ae90768cc..00000000000 --- a/middle_end/flambda/flambda_middle_end.ml +++ /dev/null @@ -1,259 +0,0 @@ -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Pierre Chambart, OCamlPro *) -(* Mark Shinwell and Leo White, Jane Street Europe *) -(* *) -(* Copyright 2013--2016 OCamlPro SAS *) -(* Copyright 2014--2019 Jane Street Group LLC *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -[@@@ocaml.warning "+a-4-30-40-41-42-66"] -open! Int_replace_polymorphic_compare - -let _dump_function_sizes flam = - let than = max_int in - Flambda_iterators.iter_on_set_of_closures_of_program flam - ~f:(fun ~constant:_ (set_of_closures : Flambda.set_of_closures) -> - Variable.Map.iter (fun fun_var - (function_decl : Flambda.function_declaration) -> - let closure_id = Closure_id.wrap fun_var in - let symbol = Symbol_utils.Flambda.for_closure closure_id in - match Inlining_cost.lambda_smaller' function_decl.body ~than with - | Some size -> Format.eprintf "%a %d\n" Symbol.print symbol size - | None -> assert false) - set_of_closures.function_decls.funs) - -let lambda_to_flambda ~ppf_dump ~prefixname ~backend ~size ~filename - ~compilation_unit ~module_initializer = - Profile.record_call "flambda" (fun () -> - let previous_warning_reporter = !Location.warning_reporter in - let module WarningSet = - Set.Make (struct - type t = Location.t * Warnings.t - let compare = Stdlib.compare - end) - in - let warning_set = ref WarningSet.empty in - let flambda_warning_reporter loc w = - let elt = loc, w in - if not (WarningSet.mem elt !warning_set) then begin - warning_set := WarningSet.add elt !warning_set; - previous_warning_reporter loc w - end else None - in - Misc.protect_refs - [Misc.R (Location.warning_reporter, flambda_warning_reporter)] - (fun () -> - let pass_number = ref 0 in - let round_number = ref 0 in - let check flam = - if !Clflags.flambda_invariant_checks then begin - try Flambda_invariants.check_exn flam - with exn -> - Misc.fatal_errorf "After Flambda pass %d, round %d:@.%s:@.%a" - !pass_number !round_number (Printexc.to_string exn) - Flambda.print_program flam - end - in - let (+-+) flam (name, pass) = - incr pass_number; - if !Clflags.dump_flambda_verbose then begin - Format.fprintf ppf_dump "@.PASS: %s@." name; - Format.fprintf ppf_dump "Before pass %d, round %d:@ %a@." - !pass_number !round_number Flambda.print_program flam; - Format.fprintf ppf_dump "\n@?" - end; - let flam = Profile.record ~accumulate:true name pass flam in - if !Clflags.flambda_invariant_checks then begin - Profile.record ~accumulate:true "check" check flam - end; - flam - in - Profile.record_call ~accumulate:true "middle_end" (fun () -> - let flam = - Profile.record_call ~accumulate:true "closure_conversion" - (fun () -> - module_initializer - |> Closure_conversion.lambda_to_flambda ~backend - ~compilation_unit ~size ~filename) - in - Compiler_hooks.execute Compiler_hooks.Raw_flambda1 flam; - if !Clflags.dump_rawflambda - then - Format.fprintf ppf_dump "After closure conversion:@ %a@." - Flambda.print_program flam; - check flam; - let fast_mode flam = - pass_number := 0; - let round = 0 in - flam - +-+ ("lift_lets 1", Lift_code.lift_lets) - +-+ ("Lift_constants", Lift_constants.lift_constants ~backend) - +-+ ("Share_constants", Share_constants.share_constants) - +-+ ("Lift_let_to_initialize_symbol", - Lift_let_to_initialize_symbol.lift ~backend) - +-+ ("Inline_and_simplify", - Inline_and_simplify.run ~never_inline:false ~backend - ~prefixname ~round ~ppf_dump) - +-+ ("Remove_unused_closure_vars 2", - Remove_unused_closure_vars.remove_unused_closure_variables - ~remove_direct_call_surrogates:false) - +-+ ("Ref_to_variables", - Ref_to_variables.eliminate_ref) - +-+ ("Initialize_symbol_to_let_symbol", - Initialize_symbol_to_let_symbol.run) - in - let rec loop flam = - pass_number := 0; - let round = !round_number in - incr round_number; - if !round_number > (Clflags.rounds ()) then flam - else - flam - (* Beware: [Lift_constants] must be run before any pass that - might duplicate strings. *) - +-+ ("lift_lets 1", Lift_code.lift_lets) - +-+ ("Lift_constants", Lift_constants.lift_constants ~backend) - +-+ ("Share_constants", Share_constants.share_constants) - +-+ ("Remove_unused_program_constructs", - Remove_unused_program_constructs.remove_unused_program_constructs) - +-+ ("Lift_let_to_initialize_symbol", - Lift_let_to_initialize_symbol.lift ~backend) - +-+ ("lift_lets 2", Lift_code.lift_lets) - +-+ ("Remove_unused_closure_vars 1", - Remove_unused_closure_vars.remove_unused_closure_variables - ~remove_direct_call_surrogates:false) - +-+ ("Inline_and_simplify", - Inline_and_simplify.run ~never_inline:false ~backend - ~prefixname ~round ~ppf_dump) - +-+ ("Remove_unused_closure_vars 2", - Remove_unused_closure_vars.remove_unused_closure_variables - ~remove_direct_call_surrogates:false) - +-+ ("lift_lets 3", Lift_code.lift_lets) - +-+ ("Inline_and_simplify noinline", - Inline_and_simplify.run ~never_inline:true ~backend - ~prefixname ~round ~ppf_dump) - +-+ ("Remove_unused_closure_vars 3", - Remove_unused_closure_vars.remove_unused_closure_variables - ~remove_direct_call_surrogates:false) - +-+ ("Ref_to_variables", - Ref_to_variables.eliminate_ref) - +-+ ("Initialize_symbol_to_let_symbol", - Initialize_symbol_to_let_symbol.run) - |> loop - in - let back_end flam = - flam - +-+ ("Remove_unused_closure_vars", - Remove_unused_closure_vars.remove_unused_closure_variables - ~remove_direct_call_surrogates:true) - +-+ ("Lift_constants", Lift_constants.lift_constants ~backend) - +-+ ("Share_constants", Share_constants.share_constants) - +-+ ("Remove_unused_program_constructs", - Remove_unused_program_constructs.remove_unused_program_constructs) - in - let flam = - if !Clflags.classic_inlining then - fast_mode flam - else - loop flam - in - let flam = back_end flam in - (* Check that there aren't any unused "always inlined" attributes. *) - Flambda_iterators.iter_apply_on_program flam ~f:(fun apply -> - match apply.inlined with - | Default_inlined | Never_inlined | Hint_inlined -> () - | Always_inlined -> - (* CR-someday mshinwell: consider a different error message if - this triggers as a result of the propagation of a user's - attribute into the second part of an over application - (inline_and_simplify.ml line 710). *) - Location.prerr_warning (Debuginfo.to_location apply.dbg) - (Warnings.Inlining_impossible - "[@inlined] attribute was not used on this function \ - application (the optimizer did not know what function \ - was being applied)") - | Unroll _ -> - Location.prerr_warning (Debuginfo.to_location apply.dbg) - (Warnings.Inlining_impossible - "[@unrolled] attribute was not used on this function \ - application (the optimizer did not know what function \ - was being applied)")); - Compiler_hooks.execute Compiler_hooks.Flambda1 flam; - if !Clflags.dump_flambda - then - Format.fprintf ppf_dump "End of middle end:@ %a@." - Flambda.print_program flam; - check flam; - (* CR-someday mshinwell: add -d... option for this *) - (* dump_function_sizes flam ~backend; *) - flam)) - ) - -let flambda_raw_clambda_dump_if ppf - ({ Flambda_to_clambda. expr = ulambda; preallocated_blocks = _; - structured_constants; exported = _; } as input) = - Compiler_hooks.execute Compiler_hooks.Raw_clambda ulambda; - if !Clflags.dump_rawclambda then - begin - Format.fprintf ppf "@.clambda (before Un_anf):@."; - Printclambda.clambda ppf ulambda; - Symbol.Map.iter (fun sym cst -> - Format.fprintf ppf "%a:@ %a@." - Symbol.print sym - Printclambda.structured_constant cst) - structured_constants - end; - if !Clflags.dump_cmm then Format.fprintf ppf "@.cmm:@."; - input - -let lambda_to_clambda ~backend ~filename ~prefixname ~ppf_dump - (program : Lambda.program) = - let size = - match program.module_block_format with - | Mb_record { mb_size } -> mb_size - | Mb_wrapped_function _ -> - (* The module block has exactly a single function, the instantiating - functor *) - 1 - in - let program = - lambda_to_flambda ~ppf_dump ~prefixname ~backend - ~size - ~filename - ~compilation_unit:program.compilation_unit - ~module_initializer:program.code - in - let export = Build_export_info.build_transient program in - let clambda, preallocated_blocks, constants = - Profile.record_call "backend" (fun () -> - (program, export) - |> Flambda_to_clambda.convert ~ppf_dump - |> flambda_raw_clambda_dump_if ppf_dump - |> (fun { Flambda_to_clambda. expr; preallocated_blocks; - structured_constants; exported; } -> - Compilenv.set_export_info exported; - let clambda = - Un_anf.apply ~what:(Symbol.for_current_unit ()) - ~ppf_dump expr - in - clambda, preallocated_blocks, structured_constants)) - in - let constants = - List.map (fun (symbol, definition) -> - { Clambda. - symbol = Symbol.linkage_name symbol |> Linkage_name.to_string; - exported = true; - definition; - provenance = None; - }) - (Symbol.Map.bindings constants) - in - clambda, preallocated_blocks, constants