[m-rev.] for post-commit review: d file dependencies part 1

Julien Fischer jfischer at opturion.com
Sun Aug 3 02:36:55 AEST 2025


On Fri, 1 Aug 2025 at 23:34, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:

> Give construct_d_file_deps_hlds more detailed info.

...

> diff --git a/compiler/generate_dep_d_files.m b/compiler/generate_dep_d_files.m
> index 1a323c0ae..ff3130d8b 100644
> --- a/compiler/generate_dep_d_files.m
> +++ b/compiler/generate_dep_d_files.m
> @@ -110,13 +110,71 @@
>  :- pred construct_d_file_deps_gendep(globals::in, dep_graphs::in,
>      burdened_aug_comp_unit::in, d_file_deps::out) is det.
>
> +    % The set of modules imported or used (i.e. made available)
> +    % by the current modules by various means, categorized by those means.

s/modules/module/

> +    % (We use "import" as shorthand for "import and/or use', given that
> +    % for the purposes of the users of this type, which deal with dependencoes

s/dependencoes/dependencies/

> +    % between files, the distinction does not matter.)
> +:- type avail_module_sets
> +    --->    avail_module_sets(
> +                % The set of ancestors of the current module.
> +                % We import their .int0 files.
> +                am_ancestors                :: set(module_name),
> +
> +                % The set of modules for which the current module
> +                % has an import_module or use_module declaration.
> +                % We will want to read the .int files of these modules.
> +                am_direct_imports           :: set(module_name),
> +
> +                % The names of all the indirectly imported/used modules,
> +                % as computed by grab_qual_imported_modules_augment.
> +                %
> +                % This field never used on its own; it is always used together

*is* never used

> +                % with the previous one, which records info about the
> +                % directly imported/used modules, to compute the set of modules
> +                % that are imported or used either directly or indirectly.
> +                %
> +                % This is used for purposes such as:
> +                %
> +                % - recording references to those modules' .int2 files
> +                %   in the current module's .d file;
> +                % - reading and writing the .analysis files of those modules;
> +                % - #including the .mh and .mih files of those modules.
> +                %
> +                % This field *should* be disjoint with am_direct_imports.
> +                am_indirect_imports         :: set(module_name),
> +
> +                % The set of modules that have an import_module or use_module
> +                % declaration in an ancestor module.
> +                %
> +                % We mostly treat these modules as if they were imported
> +                % or used by the current module itself.
> +                am_imports_in_ancestors     :: set(module_name),
> +
> +                % The set of files whose .int files we need to read
> +                % when compiling the current module in order to make sense
> +                % of all the .opt files we have read in.
> +                %
> +                % This field may overlap with the other fields.
> +                am_int_for_opt_imports      :: set(module_name),
> +
> +                % The set of modules that are implicitly imported or used
> +                % by the current module. Examples include the public and
> +                % private builtin modules, the table_builtin module
> +                % in debug grades (for I/O tabling), and modules needed
> +                % to implement e.g. io.format and string.format.
> +                %
> +                % This field may overlap with the other fields.
> +                am_implicit_imports         :: set(module_name)
> +            ).

...


> diff --git a/compiler/hlds_module.m b/compiler/hlds_module.m
> index dbdd478af..2316876a0 100644
> --- a/compiler/hlds_module.m
> +++ b/compiler/hlds_module.m
>  :- pred module_info_add_module_to_public_used_modules(module_name::in,

...

> @@ -951,32 +969,23 @@
>                  %   of the module.
>                  mri_avail_module_map            :: avail_module_map,
>
> -                % The names of all the indirectly imported/used modules.
> -                % This field never used on its own; it is always used together
> -                % with the previous one, which records info about the
> -                % directly imported/used modules, to compute the set of modules
> -                % that are imported or used either directly or indirectly.
> -                %
> -                % This is used for purposes such as:
> -                %
> -                % - including references to those modules in .d files;
> -                % - reading and writing the .analysis files of those modules;
> -                % - #including the .mh and .mih files of those modules.
> -                mri_indirectly_imported_modules :: set(module_name),
> +                % The set of module imported by various means,
> +                % categories by those means.

s/categories/categorised/

> +                mri_avail_module_sets           :: avail_module_sets,
>
>                  % The modules which have already been calculated as being used.
> +                % (In the sense of "made use of", *not* in the sense of having
> +                % a use_module declaration for them.)
> +                %
>                  % This slot is initialized to the set of modules that have
>                  % been seen to be used during the expansion of equivalence
>                  % types and insts.
> -                mri_used_modules                :: used_modules,
> -
> -                % The set of modules imported by ancestor modules.
>                  %
> -                % We used to add these to mri_used_modules, but that prevented
> -                % the compiler from generating useful warnings about unused
> -                % local imports/uses of those modules. We now keep this info
> -                % on a "may be useful later" basis; it is currently unused.
> -                mri_ancestor_avail_modules      :: set(module_name),
> +                % Note that we used to add the set of modules imported or used
> +                % by ancestors to this field, but that prevented the compiler
> +                % from generating useful warnings about unused local
> +                % imports/uses of those modules.
> +                mri_used_modules                :: used_modules,
>
>                  % Information about the procedures we are performing
>                  % complexity experiments on.

That looks fine otherwise.

Julien.


More information about the reviews mailing list