Files
mercury/tests/recompilation/Mercury.options
Zoltan Somogyi f12968eee6 Replace item_id_set with several specialized types.
The old code used item_id_sets for representing several closely related
but nevertheless significantly different pieces of information. These had
different invariants, but these could not be expressed in the type.
Using a different type for each purpose allows encoding the applicable
invariants in the types.

Also, the original code was organized around higher order code
that (a) used an item_type key to get a field from an item_id_set,
(b) did something with that field, and then, in some cases
(c) put its updated version back into the item_id_set.
It often did this in a loop over some, but not all, item_type values.
This diff replaces such code with code that (a) deconstructs a value
in one of item_id_set's replacement types, (b) uses a separate call
to process each field that needs to be processed, and then maybe
(c) constructs a new value containing the updated field.

This new approach has several advantages.

- It is more direct and hence more understandable. Due to the extra code
  that used to be required by the higher order machinery, it can also be
  shorter.

- It made clear that two of the fields of item_id_set, the fields
  ostensibly containing information about mutables and foreign_procs,
  were *never actually used*.

- It also works when the fields are not all the same type. The old code
  stored information about instances separately from item_id_sets
  precisely because it would have required a field of a different type.

- This last point allows a future diff to further specialize the types
  of the fields. Some now store items; in the future, they could store
  either just one specific kind of item, or one of a small set of kinds
  of items; e.g. the fields for predicates and functions could store
  one of item_pred_decl_infos, item_mode_decl_infos or item_decl_pragma_infos.

- It is also more efficient. Some of the old traversals allocated a new
  item_id_set every time they updated a field, with their replacement
  traversals never constructing a new item_id_set (or rather a value
  of one of its replacement types) until the traversal is complete.

One minor aspect of the change is that this diff consistently puts insts
before modes in data structures and in the code that operates on them,
as we do in the rest of the compiler. Another is that it uses the name_arity
type to replace the type that the old code used, which was pair(string, int).

compiler/recompilation.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
    As above.

    Delete assignments to !:MaybeStoppingReason that assign it the value
    ("no") that !.MaybeStoppingReason already contains, as tested
    immediately above.

    Add XXX RECOMP where further changes are desirable.

compiler/module_qual.id_set.m:
    Put insts before modes in id_type.

library/cord.m:
    Add foldl versions with two and three accumulators.

NEWS:
    Announce the new predicates.

tests/recompilation/two_module_debug:
    Add this script, which can help debug problems with smart recompilation.

tests/recompilation/Mercury.options:
    Fix indentation.
2021-08-27 21:49:37 +10:00

8 lines
325 B
Plaintext

# typeclass_method_pragma_r calls a predicate with a
# `:- pragma obsolete' declaration.
MCFLAGS-typeclass_method_pragma_r = --no-halt-at-warn
# This module tests recompilation of a module which depends on a module
# for which no version numbers have been computed.
MCFLAGS-no_version_numbers_r_2 = --no-smart-recompilation