[m-rev.] for review: don't count non-local const_structs as using imported modules
Julien Fischer
jfischer at opturion.com
Sat Jan 23 15:23:11 AEDT 2021
On Fri, 22 Jan 2021, Zoltan Somogyi wrote:
> For review by anyone.
>
> Consts from other modules can't use imported modules.
>
> This fixes the failure of the warnings/bug412 test case with -O5
> --intermodule-optimization.
...
> diff --git a/compiler/const_struct.m b/compiler/const_struct.m
> index 52b686681..fcad0ccfd 100644
> --- a/compiler/const_struct.m
> +++ b/compiler/const_struct.m
...
> @@ -223,12 +237,35 @@ lookup_insert_const_struct(ConstStruct, ConstNum, !Db) :-
> map.det_insert(ConstNum, ConstStruct, NumMap0, NumMap),
>
> const_struct_db_set_next_num(NextConstNum + 1, !Db),
> - const_struct_db_set_other_struct_map(OtherMap, !Db),
> + const_struct_db_set_noncons_proxy_map(NonConsProxyMap, !Db),
> const_struct_db_set_num_map(NumMap, !Db)
> )
> )
> ).
>
> +:- pred maybe_update_defined_where(defined_where::in, int::in,
> + const_struct_db::in, const_struct_db::out) is det.
> +
> +maybe_update_defined_where(DefinedWhere, ConstNum, !Db) :-
> + const_struct_db_get_num_map(!.Db, NumMap0),
> + map.lookup(NumMap0, ConstNum, ConstStruct0),
> + DefinedWhere0 = ConstStruct0 ^ cs_defined_where,
> + % If the new definition say that this constant is derived from code
s/say/says/
> + % in this module, then set the constant accordingly, unless its old
> + % setting already says the same.
> + ( if
> + DefinedWhere = defined_in_this_module,
> + DefinedWhere0 = defined_in_other_module
> + then
> + ConstStruct = ConstStruct0 ^ cs_defined_where
> + := defined_in_this_module,
> + map.det_update(ConstNum, ConstStruct, NumMap0, NumMap),
> + const_struct_db_set_num_map(NumMap, !Db)
> + else
> + % There is nothing to update.
> + true
> + ).
That looks fine otherwise.
Julien.
More information about the reviews
mailing list