From a59d3e521c880d3709efcd1fbbab3485c7c9723d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bour?= Date: Tue, 1 Feb 2022 22:08:28 +0100 Subject: [PATCH] Packer: add indirections to split initialisation of sub-modules to sub-functions Directly concatenating all modules produce a unique, big, control-flow-graph for the whole initialisation. Wrapping the sub-modules in functors that are immediately applied split the initialisation procedure in smaller components. Auditing the CMM shows that this wrapping does not prevent optimizations/inlining. --- src/lib_protocol_compiler/packer.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib_protocol_compiler/packer.ml b/src/lib_protocol_compiler/packer.ml index f203006d6ef4..552dbec1f7b8 100644 --- a/src/lib_protocol_compiler/packer.ml +++ b/src/lib_protocol_compiler/packer.ml @@ -91,7 +91,7 @@ let include_ml oc file = other) unit in - Printf.fprintf oc "module %s " unit ; + Printf.fprintf oc "open struct module %s (_ : sig end)" unit ; let mli = file ^ "i" in if Sys.file_exists mli then ( check_syntax `Interface mli ; @@ -103,7 +103,8 @@ let include_ml oc file = Printf.fprintf oc "# 1 %S\n" file ; check_syntax `Implementation file ; dump_file oc file ; - Printf.fprintf oc "end\n%!" + Printf.fprintf oc "end end\n" ; + Printf.fprintf oc "module %s = %s ()\n" unit unit let opened_modules = ["Tezos_protocol_environment"; "Pervasives"; "Error_monad"] -- GitLab