[m-rev.] fore post-commit review: improve the speed of the typechecker

Zoltan Somogyi zs at csse.unimelb.edu.au
Fri Jul 30 15:14:21 AEST 2010


For review by anyone. The only non-trivial change is the one to typechecker.m.

Zoltan.

Change the way the typechecker iterates over the predicates of the program.
We used to do it by looking up each predicate in the module_info,
typechecking it, and putting it back into the module_info. We now do it
by converting the predicate table into a list, iterating over the list
transforming each pred_info in it, converting the updated list back to
a predicate table.

The original intention of this change was to allow different predicates
to be typechecked in parallel by removing a synchronization bottleneck:
the typechecking of a predicate now doesn't have to wait for the typechecking
of the previous predicate to generate an the updated version of the
module_info. However, it turned out that the change is good for sequential
execution as well, improving the time on tools/speedtest from 11.33 seconds
to 11.08 seconds, a speedup of 2.2%. On tools/speedtest -l, which tests
the compilation of more modules, the speedup is even better: 3.1%
(from 32.63 to 31.60s).

compiler/typecheck.m:
	Implement the above change.

compiler/hlds_module.m:
compiler/pred_table.m:
	Add a new operation, setting the list of valid pred_ids, now needed by
	typecheck.m, to both modules.

	Make the names of the predicates for accessing the predicate table
	more expressive, and make them conform to our naming conventions.

compiler/*.m:
	Trivial changes to conform to the change in hlds_module.m.

library/assoc_list.m:
	Add new predicates now needed by typecheck.m

NEWS:
	Mention the new predicates.

library/list.m:
	Improve documentation that is now copied to assoc_list.m.

tools/speedtest:
	Make the test command more easily configurable.

cvs diff: Diffing .
Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.531
diff -u -b -r1.531 NEWS
--- NEWS	28 Jul 2010 02:10:09 -0000	1.531
+++ NEWS	29 Jul 2010 09:38:01 -0000
@@ -3,14 +3,17 @@
 
 Changes to the Mercury standard library:
 
-* Semidet modes have been added for array.foldl/4, array.foldl2/6,
+* We have added semidet modes for array.foldl/4, array.foldl2/6,
   hash_table.fold/4, version_array.foldl/4, and version_hash_table.fold/4.
 
-* cc_multi modes have been added for map.foldl2/6, tree234.foldl2/6.
+* We have added cc_multi modes for map.foldl2/6, tree234.foldl2/6.
 
-* New predicates have been added to the assoc_list module, these are
-  map_keys_only/3 map_values_only/3 and map_values/3.  They complement the
-  functions of the same name.
+* We have added new predicates and functions added to the assoc_list module.
+  The predicates map_keys_only/3 map_values_only/3 and map_values/3 complement
+  the functions of the same name. The predicates filter/3, negated_filter/3,
+  filter/4, merge/3, which also have function versions, do jobs very similar
+  to the predicates of the same name in the list module, but do the relevant
+  operations on keys instead of entire list elements.
 
 * We have improved the performance of hash tables and version hash tables.
 
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/extra
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/extra
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/doc
cvs diff: Diffing boehm_gc/libatomic_ops/src
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/armcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops/tests
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/m4
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.103
diff -u -b -r1.103 add_pragma.m
--- compiler/add_pragma.m	11 Feb 2010 04:36:09 -0000	1.103
+++ compiler/add_pragma.m	20 Jul 2010 02:10:22 -0000
@@ -1894,7 +1894,7 @@
         PredIds = [_ | _]
     ->
         ( PredIds = [PredId] ->
-            module_info_preds(!.ModuleInfo, PredTable0),
+            module_info_get_preds(!.ModuleInfo, PredTable0),
             map.lookup(PredTable0, PredId, PredInfo0),
             pred_info_get_procedures(PredInfo0, ProcTable0),
             map.to_assoc_list(ProcTable0, ProcList),
@@ -1965,7 +1965,7 @@
         PredIds = [_ | _]
     ->
         ( PredIds = [PredId] ->
-            module_info_preds(!.ModuleInfo, PredTable0),
+            module_info_get_preds(!.ModuleInfo, PredTable0),
             map.lookup(PredTable0, PredId, PredInfo0),
             pred_info_get_procedures(PredInfo0, ProcTable0),
             map.to_assoc_list(ProcTable0, ProcList),
@@ -2020,7 +2020,7 @@
         PredIds = [_ | _]
     ->
         ( PredIds = [PredId] ->
-            module_info_preds(!.ModuleInfo, PredTable0),
+            module_info_get_preds(!.ModuleInfo, PredTable0),
             map.lookup(PredTable0, PredId, PredInfo0),
             pred_info_get_procedures(PredInfo0, ProcTable0),
             map.to_assoc_list(ProcTable0, ProcList),
@@ -2074,7 +2074,7 @@
         PredIds = [_ | _]
     ->
         ( PredIds = [PredId] ->
-            module_info_preds(!.ModuleInfo, PredTable0),
+            module_info_get_preds(!.ModuleInfo, PredTable0),
             map.lookup(PredTable0, PredId, PredInfo0),
             pred_info_get_procedures(PredInfo0, ProcTable0),
             map.to_assoc_list(ProcTable0, ProcList),
Index: compiler/add_special_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_special_pred.m,v
retrieving revision 1.27
diff -u -b -r1.27 add_special_pred.m
--- compiler/add_special_pred.m	19 Aug 2009 07:44:52 -0000	1.27
+++ compiler/add_special_pred.m	20 Jul 2010 02:10:28 -0000
@@ -264,7 +264,7 @@
     ),
     module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap1),
     map.lookup(SpecialPredMap1, SpecialPredId - TypeCtor, PredId),
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, PredInfo0),
     % If the type was imported, then the special preds for that
     % type should be imported too.
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.58
diff -u -b -r1.58 arg_info.m
--- compiler/arg_info.m	23 Nov 2007 07:34:54 -0000	1.58
+++ compiler/arg_info.m	20 Jul 2010 02:10:45 -0000
@@ -127,7 +127,7 @@
 %
 
 generate_arg_info(ModuleInfo0, ModuleInfo) :-
-    module_info_preds(ModuleInfo0, Preds),
+    module_info_get_preds(ModuleInfo0, Preds),
     map.keys(Preds, PredIds),
     generate_pred_arg_info(PredIds, ModuleInfo0, ModuleInfo).
 
@@ -136,7 +136,7 @@
 
 generate_pred_arg_info([], !ModuleInfo).
 generate_pred_arg_info([PredId | PredIds], !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     generate_proc_list_arg_info(PredId, pred_info_procids(PredInfo),
         !ModuleInfo),
@@ -147,7 +147,7 @@
 
 generate_proc_list_arg_info(_PredId, [], !ModuleInfo).
 generate_proc_list_arg_info(PredId, [ProcId | ProcIds], !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     pred_info_get_arg_types(PredInfo0, ArgTypes),
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.122
diff -u -b -r1.122 bytecode_gen.m
--- compiler/bytecode_gen.m	11 Jun 2009 07:00:06 -0000	1.122
+++ compiler/bytecode_gen.m	20 Jul 2010 03:58:17 -0000
@@ -83,7 +83,7 @@
 %---------------------------------------------------------------------------%
 
 gen_module(!ModuleInfo, Code, !IO) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     gen_preds(PredIds, !.ModuleInfo, CodeTree, !IO),
     Code = cord.list(CodeTree).
 
@@ -92,7 +92,7 @@
 
 gen_preds([], _ModuleInfo, empty, !IO).
 gen_preds([PredId | PredIds], ModuleInfo, Code, !IO) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     (
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.127
diff -u -b -r1.127 check_typeclass.m
--- compiler/check_typeclass.m	18 Jan 2010 07:24:37 -0000	1.127
+++ compiler/check_typeclass.m	20 Jul 2010 03:58:24 -0000
@@ -1539,7 +1539,7 @@
     list(error_spec)::in, list(error_spec)::out) is det.
 
 check_typeclass_constraints(!ModuleInfo, !Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl2(check_pred_constraints, PredIds, !ModuleInfo, !Specs),
     module_info_get_type_table(!.ModuleInfo, TypeTable),
     get_all_type_ctor_defns(TypeTable, TypeCtorsDefns),
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.83
diff -u -b -r1.83 clause_to_proc.m
--- compiler/clause_to_proc.m	19 Aug 2009 07:44:53 -0000	1.83
+++ compiler/clause_to_proc.m	20 Jul 2010 02:10:57 -0000
@@ -138,7 +138,7 @@
     ).
 
 copy_module_clauses_to_procs(PredIds, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     list.foldl(copy_pred_clauses_to_procs_if_needed, PredIds,
         PredTable0, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
@@ -318,7 +318,7 @@
 %-----------------------------------------------------------------------------%
 
 introduce_exists_casts(PredIds, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     list.foldl(introduce_exists_casts_pred(!.ModuleInfo), PredIds,
         PredTable0, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.125
diff -u -b -r1.125 cse_detection.m
--- compiler/cse_detection.m	4 Nov 2009 03:44:46 -0000	1.125
+++ compiler/cse_detection.m	20 Jul 2010 03:58:32 -0000
@@ -75,7 +75,7 @@
 detect_cse_in_module(!ModuleInfo) :-
     % Traverse the module structure, calling `detect_cse_in_goal'
     % for each procedure body.
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     detect_cse_in_preds(PredIds, !ModuleInfo).
 
 :- pred detect_cse_in_preds(list(pred_id)::in,
@@ -83,7 +83,7 @@
 
 detect_cse_in_preds([], !ModuleInfo).
 detect_cse_in_preds([PredId | PredIds], !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     detect_cse_in_pred(PredId, PredInfo, !ModuleInfo),
     detect_cse_in_preds(PredIds, !ModuleInfo).
@@ -189,7 +189,7 @@
     module_info::in, module_info::out) is det.
 
 detect_cse_in_proc_pass(ProcId, PredId, Redo, ModuleInfo0, ModuleInfo) :-
-    module_info_preds(ModuleInfo0, PredTable0),
+    module_info_get_preds(ModuleInfo0, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.134
diff -u -b -r1.134 dead_proc_elim.m
--- compiler/dead_proc_elim.m	19 Aug 2009 07:44:53 -0000	1.134
+++ compiler/dead_proc_elim.m	20 Jul 2010 03:58:51 -0000
@@ -150,8 +150,8 @@
 dead_proc_initialize(!ModuleInfo, !:Queue, !:Needed) :-
     !:Queue = queue.init,
     !:Needed = map.init,
-    module_info_predids(PredIds, !ModuleInfo),
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     dead_proc_initialize_preds(PredIds, PredTable, !Queue, !Needed),
 
     module_info_get_pragma_exported_procs(!.ModuleInfo, PragmaExports),
@@ -401,7 +401,7 @@
 dead_proc_examine_proc(proc(PredId, ProcId), ModuleInfo,
         !Queue, !Needed) :-
     (
-        module_info_preds(ModuleInfo, PredTable),
+        module_info_get_preds(ModuleInfo, PredTable),
         map.lookup(PredTable, PredId, PredInfo),
         ProcIds = pred_info_non_imported_procids(PredInfo),
         list.member(ProcId, ProcIds),
@@ -655,8 +655,8 @@
     module_info::in, module_info::out, list(error_spec)::out) is det.
 
 dead_proc_eliminate(ElimOptImported, !.Needed, !ModuleInfo, Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
 
     Changed0 = no,
     ProcElimInfo0 = proc_elim_info(!.Needed, !.ModuleInfo, PredTable0,
@@ -906,7 +906,7 @@
     list.foldl2(dead_pred_elim_add_entity, Entities, Queue1, Queue,
         NeededPreds0, NeededPreds1),
 
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
 
     Preds0 = set_tree234.init,
     Names0 = set_tree234.init,
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.103
diff -u -b -r1.103 deep_profiling.m
--- compiler/deep_profiling.m	4 Jul 2010 10:24:07 -0000	1.103
+++ compiler/deep_profiling.m	20 Jul 2010 03:59:00 -0000
@@ -106,7 +106,7 @@
     ;
         TailRecursion = no
     ),
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     module_info_get_predicate_table(!.ModuleInfo, PredTable0),
     predicate_table_get_preds(PredTable0, PredMap0),
     list.foldl(deep_prof_transform_pred(!.ModuleInfo), PredIds,
@@ -137,7 +137,7 @@
 
 apply_deep_prof_tail_rec_transform_to_proc(PredProcId, !ModuleInfo) :-
     PredProcId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_arg_types(PredInfo0, Types),
     pred_info_get_procedures(PredInfo0, ProcTable0),
Index: compiler/dep_par_conj.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dep_par_conj.m,v
retrieving revision 1.43
diff -u -b -r1.43 dep_par_conj.m
--- compiler/dep_par_conj.m	25 Jul 2010 23:39:36 -0000	1.43
+++ compiler/dep_par_conj.m	27 Jul 2010 00:38:49 -0000
@@ -182,7 +182,7 @@
 
     % Phase one: insert synchronization code into all parallel conjunctions
     % in the module.
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl2(maybe_sync_dep_par_conjs_in_pred, PredIds,
         !ModuleInfo, [], ProcsToScan),
 
Index: compiler/dependency_graph.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.105
diff -u -b -r1.105 dependency_graph.m
--- compiler/dependency_graph.m	19 Aug 2009 07:44:53 -0000	1.105
+++ compiler/dependency_graph.m	20 Jul 2010 03:59:16 -0000
@@ -142,14 +142,14 @@
         MaybeDepInfo = yes(_)
     ;
         MaybeDepInfo = no,
-        module_info_predids(PredIds, !ModuleInfo),
+        module_info_get_valid_predids(PredIds, !ModuleInfo),
         build_dependency_graph(!.ModuleInfo, PredIds, do_not_include_imported,
             DepInfo),
         module_info_set_dependency_info(DepInfo, !ModuleInfo)
     ).
 
 module_info_rebuild_dependency_info(!ModuleInfo, DepInfo) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     build_dependency_graph(!.ModuleInfo, PredIds, do_not_include_imported,
         DepInfo),
     module_info_set_dependency_info(DepInfo, !ModuleInfo).
@@ -220,7 +220,7 @@
 
 add_pred_proc_nodes([], _ModuleInfo, _, !DepGraph).
 add_pred_proc_nodes([PredId | PredIds], ModuleInfo, Imported, !DepGraph) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     (
         % Don't bother adding nodes (or arcs) for procedures which are imported
@@ -250,7 +250,7 @@
 
 add_pred_nodes([], _ModuleInfo, _, DepGraph, DepGraph).
 add_pred_nodes([PredId | PredIds], ModuleInfo, IncludeImported, !DepGraph) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     % Don't bother adding nodes (or arcs) for predicates
     % which are imported (i.e. which we don't have any `clauses' for).
@@ -272,7 +272,7 @@
 
 add_pred_proc_arcs([], _ModuleInfo, _, !DepGraph).
 add_pred_proc_arcs([PredId | PredIds], ModuleInfo, Imported, !DepGraph) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     (
         % Don't bother adding nodes (or arcs) for procedures which are imported
@@ -292,7 +292,7 @@
 add_proc_arcs([], _PredId, _ModuleInfo, _, !DepGraph).
 add_proc_arcs([ProcId | ProcIds], PredId, ModuleInfo, IncludeImported,
         !DepGraph) :-
-    module_info_preds(ModuleInfo, PredTable0),
+    module_info_get_preds(ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -324,7 +324,7 @@
 
 add_pred_arcs([], _ModuleInfo, _, !DepGraph).
 add_pred_arcs([PredId | PredIds], ModuleInfo, IncludeImported, !DepGraph) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     (
         IncludeImported = do_not_include_imported,
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.222
diff -u -b -r1.222 det_analysis.m
--- compiler/det_analysis.m	4 Nov 2009 03:44:46 -0000	1.222
+++ compiler/det_analysis.m	20 Jul 2010 03:59:22 -0000
@@ -141,7 +141,7 @@
 %-----------------------------------------------------------------------------%
 
 determinism_pass(!ModuleInfo, Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     determinism_declarations(!.ModuleInfo, PredIds,
         DeclaredProcs, UndeclaredProcs, NoInferProcs),
     list.foldl(set_non_inferred_proc_determinism, NoInferProcs, !ModuleInfo),
@@ -257,7 +257,7 @@
 
 det_infer_proc(PredId, ProcId, !ModuleInfo, OldDetism, NewDetism, !Specs) :-
     % Get the proc_info structure for this procedure.
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -1739,7 +1739,7 @@
 
 det_find_matching_non_cc_mode(DetInfo, PredId, !ProcId) :-
     det_info_get_module_info(DetInfo, ModuleInfo),
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.to_assoc_list(ProcTable, ProcList),
@@ -1970,7 +1970,7 @@
     pred_proc_list::out) is det.
 
 get_all_pred_procs(ModuleInfo, PredIds, PredProcs) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     get_all_pred_procs_2(PredTable, PredIds, [], PredProcs).
 
 :- pred get_all_pred_procs_2(pred_table::in, list(pred_id)::in,
@@ -2024,7 +2024,7 @@
 segregate_procs_2(ModuleInfo, [PredProcId | PredProcIds],
         !DeclaredProcs, !UndeclaredProcs, !NoInferProcs) :-
     PredProcId = proc(PredId, ProcId),
-    module_info_preds(ModuleInfo, Preds),
+    module_info_get_preds(ModuleInfo, Preds),
     map.lookup(Preds, PredId, Pred),
     (
         (
Index: compiler/det_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_util.m,v
retrieving revision 1.50
diff -u -b -r1.50 det_util.m
--- compiler/det_util.m	4 Sep 2009 02:27:49 -0000	1.50
+++ compiler/det_util.m	20 Jul 2010 02:12:16 -0000
@@ -175,7 +175,7 @@
 
 det_lookup_pred_info_and_detism(DetInfo, PredId, ModeId, PredInfo, Detism) :-
     det_info_get_module_info(DetInfo, ModuleInfo),
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.lookup(ProcTable, ModeId, ProcInfo),
@@ -185,7 +185,7 @@
     det_info_get_module_info(DetInfo, ModuleInfo),
     det_info_get_pred_id(DetInfo, PredId),
     det_info_get_proc_id(DetInfo, ProcId),
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.lookup(ProcTable, ProcId, ProcInfo).
Index: compiler/distance_granularity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/distance_granularity.m,v
retrieving revision 1.11
diff -u -b -r1.11 distance_granularity.m
--- compiler/distance_granularity.m	8 Sep 2009 02:43:32 -0000	1.11
+++ compiler/distance_granularity.m	20 Jul 2010 03:59:28 -0000
@@ -180,7 +180,7 @@
 
 
 control_distance_granularity(!ModuleInfo, Distance) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     apply_dg_to_preds(PredIds, Distance, !ModuleInfo).
 
     % Apply the distance granularity transformation to each predicate in the
Index: compiler/equiv_type_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type_hlds.m,v
retrieving revision 1.60
diff -u -b -r1.60 equiv_type_hlds.m
--- compiler/equiv_type_hlds.m	14 Oct 2009 05:28:32 -0000	1.60
+++ compiler/equiv_type_hlds.m	20 Jul 2010 03:59:33 -0000
@@ -84,7 +84,7 @@
     replace_in_cons_table(EqvMap, ConsTable0, ConsTable),
     module_info_set_cons_table(ConsTable, !ModuleInfo),
 
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl2(replace_in_pred(EqvMap), PredIds, !ModuleInfo, InstCache, _).
 
 %-----------------------------------------------------------------------------%
Index: compiler/erl_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_gen.m,v
retrieving revision 1.34
diff -u -b -r1.34 erl_code_gen.m
--- compiler/erl_code_gen.m	14 Oct 2009 05:28:32 -0000	1.34
+++ compiler/erl_code_gen.m	20 Jul 2010 02:12:23 -0000
@@ -134,7 +134,7 @@
     is det.
 
 erl_gen_preds(ModuleInfo, PredDefns, !IO) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.keys(PredTable, PredIds),
     erl_gen_preds_2(ModuleInfo, PredIds, PredTable, [], RevPredDefns, !IO),
     PredDefns = list.reverse(RevPredDefns).
Index: compiler/exception_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exception_analysis.m,v
retrieving revision 1.53
diff -u -b -r1.53 exception_analysis.m
--- compiler/exception_analysis.m	14 Oct 2009 05:28:32 -0000	1.53
+++ compiler/exception_analysis.m	20 Jul 2010 03:59:50 -0000
@@ -186,7 +186,7 @@
     (
         MakeAnalysisReg = yes,
         module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0),
-        module_info_predids(PredIds, !ModuleInfo),
+        module_info_get_valid_predids(PredIds, !ModuleInfo),
         list.foldl(maybe_record_exception_result(!.ModuleInfo),
             PredIds, AnalysisInfo0, AnalysisInfo),
         module_info_set_analysis_info(AnalysisInfo, !ModuleInfo)
@@ -1230,7 +1230,7 @@
         OptFileRes = ok(OptFile),
         io.set_output_stream(OptFile, OldStream, !IO),
         module_info_get_exception_info(ModuleInfo, ExceptionInfo),
-        module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
         list.foldl(write_pragma_exceptions(ModuleInfo, ExceptionInfo),
             PredIds, !IO),
         io.set_output_stream(OldStream, _, !IO),
Index: compiler/granularity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/granularity.m,v
retrieving revision 1.15
diff -u -b -r1.15 granularity.m
--- compiler/granularity.m	8 Sep 2009 02:43:32 -0000	1.15
+++ compiler/granularity.m	20 Jul 2010 02:12:29 -0000
@@ -63,7 +63,7 @@
     pred_proc_id::in, module_info::in, module_info::out) is det.
 
 runtime_granularity_test_in_proc(SCC, proc(PredId, ProcId), !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.187
diff -u -b -r1.187 higher_order.m
--- compiler/higher_order.m	25 Jan 2010 05:26:03 -0000	1.187
+++ compiler/higher_order.m	20 Jul 2010 04:10:47 -0000
@@ -109,7 +109,7 @@
         !:GlobalInfo = higher_order_global_info(Requests0, NewPreds0,
             VersionInfo0, !.ModuleInfo, GoalSizes0, Params, counter.init(1)),
 
-        module_info_predids(PredIds0, !ModuleInfo),
+        module_info_get_valid_predids(PredIds0, !ModuleInfo),
         module_info_get_type_spec_info(!.ModuleInfo, TypeSpecInfo),
         TypeSpecInfo = type_spec_info(_, UserSpecPreds, _, _),
 
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.165
diff -u -b -r1.165 hlds_module.m
--- compiler/hlds_module.m	14 Oct 2009 05:28:33 -0000	1.165
+++ compiler/hlds_module.m	20 Jul 2010 04:08:43 -0000
@@ -540,7 +540,9 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred module_info_preds(module_info::in, pred_table::out) is det.
+:- pred module_info_get_preds(module_info::in, pred_table::out) is det.
+:- pred module_info_set_preds(pred_table::in,
+    module_info::in, module_info::out) is det.
 
     % Given a pred_id, return the pred_info of the specified pred.
     %
@@ -563,7 +565,7 @@
 :- pred module_info_pred_proc_info(module_info::in, pred_proc_id::in,
     pred_info::out, proc_info::out) is det.
 
-    % Return a list of the pred_ids of all the "valid" predicates.
+    % Return a list of the pred_ids of all the valid predicates.
     % (Predicates whose definition contains a type error, etc.
     % get removed from this list, so that later passes can rely
     % on the predicates in this list being type-correct, etc.)
@@ -571,7 +573,15 @@
     % This operation does not logically change the module_info,
     % but does update it physically.
     %
-:- pred module_info_predids(list(pred_id)::out,
+:- pred module_info_get_valid_predids(list(pred_id)::out,
+    module_info::in, module_info::out) is det.
+
+    % Set the list of the pred_ids of all the "valid" predicates.
+    % NOTE: The only approved way to specify the list is to call
+    % module_info_get_valid_predids or predicate_table_get_valid_predids,
+    % and remove some pred_ids from that list.
+    %
+:- pred module_info_set_valid_predids(list(pred_id)::in,
     module_info::in, module_info::out) is det.
 
     % Remove a predicate from the list of pred_ids, to prevent
@@ -585,9 +595,6 @@
 :- pred module_info_remove_predicate(pred_id::in,
     module_info::in, module_info::out) is det.
 
-:- pred module_info_set_preds(pred_table::in,
-    module_info::in, module_info::out) is det.
-
 :- pred module_info_set_pred_info(pred_id::in, pred_info::in,
     module_info::in, module_info::out) is det.
 
@@ -1201,12 +1208,17 @@
     % Various predicates which do simple things that are nevertheless
     % beyond the capability of an access predicate.
 
-module_info_preds(MI, Preds) :-
+module_info_get_preds(MI, Preds) :-
     module_info_get_predicate_table(MI, PredTable),
     predicate_table_get_preds(PredTable, Preds).
 
+module_info_set_preds(Preds, !MI) :-
+    module_info_get_predicate_table(!.MI, PredTable0),
+    predicate_table_set_preds(Preds, PredTable0, PredTable),
+    module_info_set_predicate_table(PredTable, !MI).
+
 module_info_pred_info(MI, PredId, PredInfo) :-
-    module_info_preds(MI, Preds),
+    module_info_get_preds(MI, Preds),
     ( map.search(Preds, PredId, PredInfoPrime) ->
         PredInfo = PredInfoPrime
     ;
@@ -1230,9 +1242,14 @@
 module_info_pred_proc_info(MI, proc(PredId, ProcId), PredInfo, ProcInfo) :-
     module_info_pred_proc_info(MI, PredId, ProcId, PredInfo, ProcInfo).
 
-module_info_predids(PredIds, !MI) :-
+module_info_get_valid_predids(PredIds, !MI) :-
+    module_info_get_predicate_table(!.MI, PredTable0),
+    predicate_table_get_valid_predids(PredIds, PredTable0, PredTable),
+    module_info_set_predicate_table(PredTable, !MI).
+
+module_info_set_valid_predids(PredIds, !MI) :-
     module_info_get_predicate_table(!.MI, PredTable0),
-    predicate_table_get_predids(PredIds, PredTable0, PredTable),
+    predicate_table_set_valid_predids(PredIds, PredTable0, PredTable),
     module_info_set_predicate_table(PredTable, !MI).
 
 module_info_remove_predid(PredId, !MI) :-
@@ -1245,13 +1262,8 @@
     predicate_table_remove_predicate(PredId, PredTable0, PredTable),
     module_info_set_predicate_table(PredTable, !MI).
 
-module_info_set_preds(Preds, !MI) :-
-    module_info_get_predicate_table(!.MI, PredTable0),
-    predicate_table_set_preds(Preds, PredTable0, PredTable),
-    module_info_set_predicate_table(PredTable, !MI).
-
 module_info_set_pred_info(PredId, PredInfo, !MI) :-
-    module_info_preds(!.MI, Preds0),
+    module_info_get_preds(!.MI, Preds0),
     map.set(Preds0, PredId, PredInfo, Preds),
     module_info_set_preds(Preds, !MI).
 
Index: compiler/hlds_out_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out_module.m,v
retrieving revision 1.1
diff -u -b -r1.1 hlds_out_module.m
--- compiler/hlds_out_module.m	4 Nov 2009 03:44:47 -0000	1.1
+++ compiler/hlds_out_module.m	20 Jul 2010 02:12:55 -0000
@@ -68,7 +68,7 @@
 
 write_hlds(Indent, ModuleInfo, !IO) :-
     module_info_get_imported_module_specifiers(ModuleInfo, Imports),
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     module_info_get_type_table(ModuleInfo, TypeTable),
     module_info_get_inst_table(ModuleInfo, InstTable),
     module_info_get_mode_table(ModuleInfo, ModeTable),
Index: compiler/hlds_out_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out_util.m,v
retrieving revision 1.1
diff -u -b -r1.1 hlds_out_util.m
--- compiler/hlds_out_util.m	4 Nov 2009 03:44:47 -0000	1.1
+++ compiler/hlds_out_util.m	20 Jul 2010 02:12:59 -0000
@@ -239,7 +239,7 @@
     io.write_string(pred_id_to_string(ModuleInfo, PredId), !IO).
 
 pred_id_to_string(ModuleInfo, PredId) = Str :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     ( map.search(PredTable, PredId, PredInfo) ->
         Module = pred_info_module(PredInfo),
         Name = pred_info_name(PredInfo),
Index: compiler/hlds_statistics.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_statistics.m,v
retrieving revision 1.1
diff -u -b -r1.1 hlds_statistics.m
--- compiler/hlds_statistics.m	4 Feb 2010 02:20:41 -0000	1.1
+++ compiler/hlds_statistics.m	20 Jul 2010 02:13:04 -0000
@@ -55,7 +55,7 @@
     ModuleName = sym_name_to_string(ModuleSymName),
     io.format(OutStream, "MODULE %s\n", [s(ModuleName)], !IO),
 
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.to_assoc_list(PredTable, Preds),
     list.foldl(write_proc_stats_for_pred(OutStream, Msg, ModuleInfo),
         Preds, !IO).
Index: compiler/implementation_defined_literals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/implementation_defined_literals.m,v
retrieving revision 1.8
diff -u -b -r1.8 implementation_defined_literals.m
--- compiler/implementation_defined_literals.m	5 Feb 2010 03:10:59 -0000	1.8
+++ compiler/implementation_defined_literals.m	20 Jul 2010 02:13:13 -0000
@@ -56,7 +56,7 @@
 %-----------------------------------------------------------------------------%
 
 subst_impl_defined_literals(!ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.map_values(subst_literals_in_pred(!.ModuleInfo), Preds0, Preds),
     module_info_set_preds(Preds, !ModuleInfo).
 
Index: compiler/implicit_parallelism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/implicit_parallelism.m,v
retrieving revision 1.19
diff -u -b -r1.19 implicit_parallelism.m
--- compiler/implicit_parallelism.m	14 Jul 2010 00:40:21 -0000	1.19
+++ compiler/implicit_parallelism.m	20 Jul 2010 04:01:17 -0000
@@ -130,7 +130,7 @@
             ParallelismInfo)
     ->
         % Retrieve and process predicates.
-        module_info_predids(PredIds, !ModuleInfo),
+        module_info_get_valid_predids(PredIds, !ModuleInfo),
         module_info_get_predicate_table(!.ModuleInfo, PredTable0),
         predicate_table_get_preds(PredTable0, PredMap0),
         list.foldl3(maybe_parallelise_pred(!.ModuleInfo, ParallelismInfo), 
@@ -893,7 +893,7 @@
         some [!ModuleInfo]
         (
             !:ModuleInfo = ModuleInfo0,
-            module_info_predids(PredIds, !ModuleInfo),
+            module_info_get_valid_predids(PredIds, !ModuleInfo),
             FeedbackData =
                 feedback_data_calls_above_threshold_sorted(_, _, Calls),
             list.map(call_site_convert, Calls, CandidateCallSites),
Index: compiler/inlining.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.166
diff -u -b -r1.166 inlining.m
--- compiler/inlining.m	10 May 2010 05:02:27 -0000	1.166
+++ compiler/inlining.m	20 Jul 2010 02:13:18 -0000
@@ -461,7 +461,7 @@
     PredProcId = proc(PredId, ProcId),
 
     some [!PredInfo, !ProcInfo] (
-        module_info_preds(!.ModuleInfo, PredTable0),
+        module_info_get_preds(!.ModuleInfo, PredTable0),
         map.lookup(PredTable0, PredId, !:PredInfo),
         pred_info_get_procedures(!.PredInfo, ProcTable0),
         map.lookup(ProcTable0, ProcId, !:ProcInfo),
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.252
diff -u -b -r1.252 intermod.m
--- compiler/intermod.m	21 Jul 2010 04:27:59 -0000	1.252
+++ compiler/intermod.m	21 Jul 2010 05:44:12 -0000
@@ -159,7 +159,7 @@
     ;
         Result = ok(FileStream),
         io.set_output_stream(FileStream, OutputStream, !IO),
-        module_info_predids(RealPredIds, !ModuleInfo),
+        module_info_get_valid_predids(RealPredIds, !ModuleInfo),
         module_info_get_assertion_table(!.ModuleInfo, AssertionTable),
         assertion_table_pred_ids(AssertionTable, AssertPredIds),
         PredIds = AssertPredIds ++ RealPredIds,
@@ -228,7 +228,7 @@
 gather_pred_list([PredId | PredIds], ProcessLocalPreds, CollectTypes,
         InlineThreshold, HigherOrderSizeLimit, Deforestation, !Info) :-
     intermod_info_get_module_info(!.Info, ModuleInfo0),
-    module_info_preds(ModuleInfo0, PredTable0),
+    module_info_get_preds(ModuleInfo0, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     module_info_get_type_spec_info(ModuleInfo0, TypeSpecInfo),
     TypeSpecInfo = type_spec_info(_, TypeSpecForcePreds, _, _),
@@ -2141,7 +2141,7 @@
             !IO)
     ),
 
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     globals.lookup_int_option(Globals, intermod_inline_simple_threshold,
         Threshold),
     globals.lookup_bool_option(Globals, deforestation, Deforestation),
@@ -2283,7 +2283,7 @@
         module_info::out) is det.
 
 set_list_of_preds_exported(PredIds, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     set_list_of_preds_exported_2(PredIds, Preds0, Preds),
     module_info_set_preds(Preds, !ModuleInfo).
 
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.142
diff -u -b -r1.142 lambda.m
--- compiler/lambda.m	16 Sep 2009 02:32:52 -0000	1.142
+++ compiler/lambda.m	20 Jul 2010 04:01:36 -0000
@@ -139,7 +139,7 @@
 %
 
 expand_lambdas_in_module(!ModuleInfo) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(expand_lambdas_in_pred, PredIds, !ModuleInfo),
     % Need update the dependency graph to include the lambda predicates.
     module_info_clobber_dependency_info(!ModuleInfo).
@@ -153,7 +153,7 @@
     module_info::in, module_info::out) is det.
 
 expand_lambdas_in_proc(PredId, ProcId, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -164,7 +164,7 @@
     pred_info_get_procedures(PredInfo1, ProcTable1),
     map.det_update(ProcTable1, ProcId, ProcInfo, ProcTable),
     pred_info_set_procedures(ProcTable, PredInfo1, PredInfo),
-    module_info_preds(!.ModuleInfo, PredTable1),
+    module_info_get_preds(!.ModuleInfo, PredTable1),
     map.det_update(PredTable1, PredId, PredInfo, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
 
Index: compiler/lco.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lco.m,v
retrieving revision 1.61
diff -u -b -r1.61 lco.m
--- compiler/lco.m	23 Feb 2010 05:03:02 -0000	1.61
+++ compiler/lco.m	20 Jul 2010 02:13:47 -0000
@@ -310,8 +310,7 @@
 
 process_proc_update(PredProcId - NewProcInfo, !ModuleInfo) :-
     PredProcId = proc(PredId, ProcId),
-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, Procs0),
     map.det_update(Procs0, ProcId, NewProcInfo, Procs),
@@ -338,7 +337,7 @@
     map.apply_to_list(HeadVars, VarTypes, ArgTypes),
 
     some [!VariantPredInfo, !PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
         map.lookup(!.PredTable, VariantPredId, !:VariantPredInfo),
         pred_info_set_name(VariantName, !VariantPredInfo),
         pred_info_set_is_pred_or_func(pf_predicate, !VariantPredInfo),
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.173
diff -u -b -r1.173 liveness.m
--- compiler/liveness.m	18 Nov 2009 23:49:22 -0000	1.173
+++ compiler/liveness.m	20 Jul 2010 04:01:42 -0000
@@ -235,7 +235,7 @@
 %-----------------------------------------------------------------------------%
 
 detect_liveness_preds_parallel(!HLDS) :-
-    module_info_predids(PredIds, !HLDS),
+    module_info_get_valid_predids(PredIds, !HLDS),
     detect_liveness_preds_parallel_2(PredIds, !.HLDS, !HLDS).
 
 :- pred detect_liveness_preds_parallel_2(list(pred_id)::in,
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.99
diff -u -b -r1.99 make_hlds_passes.m
--- compiler/make_hlds_passes.m	7 May 2010 11:49:06 -0000	1.99
+++ compiler/make_hlds_passes.m	20 Jul 2010 02:13:57 -0000
@@ -2852,7 +2852,7 @@
     ),
     do_add_pred_marker(PragmaName, Name, Arity, Status, MustBeExported,
         Context, add_marker_pred_info(Marker), !ModuleInfo, PredIds, !Specs),
-    module_info_preds(!.ModuleInfo, Preds),
+    module_info_get_preds(!.ModuleInfo, Preds),
     pragma_check_markers(Preds, PredIds, ConflictMarkers, Conflict),
     (
         Conflict = yes,
@@ -2920,7 +2920,7 @@
 
 module_mark_preds_as_external([], !ModuleInfo).
 module_mark_preds_as_external([PredId | PredIds], !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, PredInfo0),
     pred_info_mark_as_external(PredInfo0, PredInfo),
     map.det_update(Preds0, PredId, PredInfo, Preds),
Index: compiler/mercury_compile_front_end.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile_front_end.m,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_compile_front_end.m
--- compiler/mercury_compile_front_end.m	4 Feb 2010 02:20:41 -0000	1.3
+++ compiler/mercury_compile_front_end.m	20 Jul 2010 04:01:50 -0000
@@ -56,7 +56,7 @@
     ;       simplify_pass_ll_backend.
             % The first stage of LLDS code generation.
 
-    % This predicate set up and maybe run the simplification pass.
+    % This predicate sets up and maybe runs the simplification pass.
     %
 :- pred maybe_simplify(bool::in, simplify_pass::in, bool::in, bool::in,
     module_info::in, module_info::out,
@@ -252,7 +252,7 @@
         % get any type errors already; this avoids a lot of spurious
         % diagnostics.
         PostTypeCheckReportErrors = bool.not(FoundTypeError),
-        module_info_predids(PredIds, !HLDS),
+        module_info_get_valid_predids(PredIds, !HLDS),
         post_typecheck_finish_preds(PredIds, PostTypeCheckReportErrors,
             NumPostTypeCheckErrors, !HLDS, !Specs),
         maybe_dump_hlds(!.HLDS, 19, "post_typecheck", !DumpInfo, !IO),
Index: compiler/mercury_compile_llds_back_end.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile_llds_back_end.m,v
retrieving revision 1.4
diff -u -b -r1.4 mercury_compile_llds_back_end.m
--- compiler/mercury_compile_llds_back_end.m	4 Nov 2009 03:44:48 -0000	1.4
+++ compiler/mercury_compile_llds_back_end.m	20 Jul 2010 04:01:55 -0000
@@ -189,7 +189,7 @@
     io::di, io::uo) is det.
 
 llds_backend_pass_by_preds(!HLDS, !GlobalData, LLDS, !IO) :-
-    module_info_predids(PredIds, !HLDS),
+    module_info_get_valid_predids(PredIds, !HLDS),
     module_info_get_globals(!.HLDS, Globals),
     globals.lookup_bool_option(Globals, optimize_proc_dups, ProcDups),
     (
@@ -218,7 +218,7 @@
 llds_backend_pass_by_preds_2([], !HLDS, !GlobalData, _, !RevCodes, !IO).
 llds_backend_pass_by_preds_2([PredId | PredIds], !HLDS, !GlobalData,
         !.MaybeDupProcMap, !RevCodes, !IO) :-
-    module_info_preds(!.HLDS, PredTable),
+    module_info_get_preds(!.HLDS, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     (
Index: compiler/ml_proc_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_proc_gen.m,v
retrieving revision 1.3
diff -u -b -r1.3 ml_proc_gen.m
--- compiler/ml_proc_gen.m	15 Apr 2010 02:56:00 -0000	1.3
+++ compiler/ml_proc_gen.m	20 Jul 2010 02:14:13 -0000
@@ -261,7 +261,7 @@
     list(mlds_defn)::out, ml_global_data::out) is det.
 
 ml_gen_preds(!ModuleInfo, PredDefns, GlobalData) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.keys(PredTable, PredIds),
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.get_target(Globals, Target),
@@ -288,7 +288,7 @@
 ml_gen_preds_2(!ModuleInfo, PredIds0, !Defns, !GlobalDefns) :-
     (
         PredIds0 = [PredId | PredIds],
-        module_info_preds(!.ModuleInfo, PredTable),
+        module_info_get_preds(!.ModuleInfo, PredTable),
         map.lookup(PredTable, PredId, PredInfo),
         pred_info_get_import_status(PredInfo, ImportStatus),
         (
Index: compiler/mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_constraints.m,v
retrieving revision 1.54
diff -u -b -r1.54 mode_constraints.m
--- compiler/mode_constraints.m	14 Oct 2009 05:28:40 -0000	1.54
+++ compiler/mode_constraints.m	20 Jul 2010 04:02:10 -0000
@@ -115,7 +115,7 @@
 ].
 
 process_module(!ModuleInfo, !IO) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.lookup_bool_option(Globals, simple_mode_constraints, Simple),
     globals.lookup_bool_option(Globals, prop_mode_constraints, New),
@@ -1851,7 +1851,7 @@
     is det.
 
 get_predicate_sccs(!ModuleInfo, SCCs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     dependency_graph.build_pred_dependency_graph(!.ModuleInfo, PredIds,
         do_not_include_imported, DepInfo),
     hlds_dependency_info_get_dependency_ordering(DepInfo, SCCs0),
@@ -1901,7 +1901,7 @@
 :- pred add_imported_preds(module_info::in, sccs::in, sccs::out) is det.
 
 add_imported_preds(ModuleInfo, SCCs0, SCCs) :-
-    module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
     list.filter_map(
         (pred(PredId::in, [PredId]::out) is semidet :-
             module_info_pred_info(ModuleInfo, PredId, PredInfo),
Index: compiler/mode_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_info.m,v
retrieving revision 1.99
diff -u -b -r1.99 mode_info.m
--- compiler/mode_info.m	22 Sep 2009 07:34:14 -0000	1.99
+++ compiler/mode_info.m	20 Jul 2010 02:14:20 -0000
@@ -640,7 +640,7 @@
 
 mode_info_get_preds(ModeInfo, Preds) :-
     mode_info_get_module_info(ModeInfo, ModuleInfo),
-    module_info_preds(ModuleInfo, Preds).
+    module_info_get_preds(ModuleInfo, Preds).
 
 mode_info_get_modes(ModeInfo, Modes) :-
     mode_info_get_module_info(ModeInfo, ModuleInfo),
Index: compiler/modecheck_call.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_call.m,v
retrieving revision 1.85
diff -u -b -r1.85 modecheck_call.m
--- compiler/modecheck_call.m	25 Sep 2009 05:13:04 -0000	1.85
+++ compiler/modecheck_call.m	20 Jul 2010 02:14:25 -0000
@@ -477,7 +477,7 @@
     % create a new mode for this predicate
     get_var_insts_and_lives(ArgVars, !.ModeInfo, InitialInsts, ArgLives),
     mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
-    module_info_preds(ModuleInfo0, Preds0),
+    module_info_get_preds(ModuleInfo0, Preds0),
     map.lookup(Preds0, PredId, PredInfo0),
     pred_info_get_context(PredInfo0, Context),
     list.length(ArgVars, Arity),
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.389
diff -u -b -r1.389 modes.m
--- compiler/modes.m	4 Nov 2009 03:44:49 -0000	1.389
+++ compiler/modes.m	20 Jul 2010 04:02:24 -0000
@@ -191,7 +191,7 @@
 
 check_pred_modes(WhatToCheck, MayChangeCalledProc, !ModuleInfo,
         SafeToContinue, !:Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.lookup_int_option(Globals, mode_inference_iteration_limit,
         MaxIterations),
@@ -253,7 +253,7 @@
         !ModuleInfo, SafeToContinue, !:Specs) :-
     % Save the old procedure bodies so that we can restore them for the
     % next pass.
-    module_info_preds(!.ModuleInfo, OldPredTable0),
+    module_info_get_preds(!.ModuleInfo, OldPredTable0),
 
     % Analyze everything which has the "can-process" flag set to `yes'.
     list.foldl3(maybe_modecheck_pred(WhatToCheck, MayChangeCalledProc),
@@ -358,7 +358,7 @@
     module_info::in, module_info::out) is det.
 
 copy_pred_bodies(OldPredTable, PredIds, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     list.foldl(copy_pred_body(OldPredTable), PredIds, PredTable0, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
 
@@ -432,7 +432,7 @@
 
 maybe_modecheck_pred(WhatToCheck, MayChangeCalledProc, PredId,
         !ModuleInfo, !Changed, !Specs) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, PredInfo0),
     ShouldModeCheck = should_modecheck_pred(PredInfo0),
     (
@@ -573,7 +573,7 @@
         CanProcess = yes,
         do_modecheck_proc(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
             !ModuleInfo, ProcInfo0, ProcInfo, !Changed, Specs),
-        module_info_preds(!.ModuleInfo, Preds1),
+        module_info_get_preds(!.ModuleInfo, Preds1),
         map.lookup(Preds1, PredId, PredInfo1),
         pred_info_get_procedures(PredInfo1, Procs1),
         map.set(Procs1, ProcId, ProcInfo, Procs),
@@ -880,7 +880,7 @@
         % XXX inefficient! This is O(N*M).
 
         PredProcId = proc(PredId, _ProcId),
-        module_info_predids(ValidPredIds, !ModuleInfo),
+        module_info_get_valid_predids(ValidPredIds, !ModuleInfo),
         ( list.member(PredId, ValidPredIds) ->
             trace [io(!IO)] (
                 queued_proc_progress_message(!.ModuleInfo, PredProcId,
@@ -936,7 +936,7 @@
         !:Changed, Specs) :-
     % Mark the procedure as ready to be processed.
     PredProcId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, Procs0),
     map.lookup(Procs0, ProcId, ProcInfo0),
@@ -1257,7 +1257,7 @@
     list(error_spec)::in, list(error_spec)::out) is det.
 
 check_eval_methods(!ModuleInfo, !Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     pred_check_eval_methods(!.ModuleInfo, PredIds, !Specs).
 
 :- pred pred_check_eval_methods(module_info::in, list(pred_id)::in,
@@ -1265,7 +1265,7 @@
 
 pred_check_eval_methods(_, [], !Specs).
 pred_check_eval_methods(ModuleInfo, [PredId | PredIds], !Specs) :-
-    module_info_preds(ModuleInfo, Preds),
+    module_info_get_preds(ModuleInfo, Preds),
     map.lookup(Preds, PredId, PredInfo),
     ProcIds = pred_info_procids(PredInfo),
     proc_check_eval_methods(ModuleInfo, PredId, ProcIds, !Specs),
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.95
diff -u -b -r1.95 passes_aux.m
--- compiler/passes_aux.m	4 Nov 2009 03:44:49 -0000	1.95
+++ compiler/passes_aux.m	20 Jul 2010 04:02:33 -0000
@@ -93,7 +93,6 @@
 :- type pred_error_task ==
         pred(pred_id, module_info, module_info, pred_info, pred_info,
             list(error_spec), list(error_spec)).
-
 :- inst pred_error_task ==
     (pred(in, in, out, in, out, in, out) is det).
 
@@ -230,7 +229,7 @@
 
 process_matching_nonimported_procs_errors(Task, Filter, !ModuleInfo,
         !Specs, !IO) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     ( Task = update_pred_error(Pred) ->
         list.foldl2(process_nonimported_pred(Pred, Filter), PredIds,
             !ModuleInfo, !Specs)
@@ -247,7 +246,7 @@
 
 process_matching_nonimported_procs_update_errors(Task0, Task, Filter,
         !ModuleInfo, !Specs, !IO) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     process_nonimported_procs_in_preds(PredIds, Task0, Task, Filter,
         !ModuleInfo, !IO).
 
@@ -283,7 +282,7 @@
 process_nonimported_procs_in_preds([], !Task, _, !ModuleInfo, !IO).
 process_nonimported_procs_in_preds([PredId | PredIds], !Task, Filter,
         !ModuleInfo, !IO) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     ( call(Filter, PredInfo) ->
         ProcIds = pred_info_non_imported_procids(PredInfo),
@@ -301,7 +300,7 @@
 process_nonimported_procs([], _PredId, !Task, !ModuleInfo, !IO).
 process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo,
         !IO) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, Pred0),
     pred_info_get_procedures(Pred0, Procs0),
     map.lookup(Procs0, ProcId, Proc0),
@@ -341,7 +340,7 @@
     % If the pass changed the module_info, it may have changed the pred table
     % or the proc table for this pred_id.  Don't take any chances.
 
-    module_info_preds(!.ModuleInfo, Preds8),
+    module_info_get_preds(!.ModuleInfo, Preds8),
     map.lookup(Preds8, PredId, Pred8),
     pred_info_get_procedures(Pred8, Procs8),
 
@@ -412,7 +411,7 @@
 :- pred report_sizes(module_info::in, io::di, io::uo) is det.
 
 report_sizes(ModuleInfo, !IO) :-
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     io.format("Pred table size = %d\n", [i(map.count(PredTable))], !IO),
 
     module_info_get_type_table(ModuleInfo, TypeTable),
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.349
diff -u -b -r1.349 polymorphism.m
--- compiler/polymorphism.m	2 Nov 2009 05:53:44 -0000	1.349
+++ compiler/polymorphism.m	20 Jul 2010 02:15:49 -0000
@@ -436,10 +436,10 @@
 % sure we don't muck them up before we've finished the first pass.
 
 polymorphism_process_module(!ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.keys(Preds0, PredIds0),
     list.foldl(maybe_polymorphism_process_pred, PredIds0, !ModuleInfo),
-    module_info_preds(!.ModuleInfo, Preds1),
+    module_info_get_preds(!.ModuleInfo, Preds1),
     map.keys(Preds1, PredIds1),
     list.foldl(fixup_pred_polymorphism, PredIds1, !ModuleInfo),
     expand_class_method_bodies(!ModuleInfo).
@@ -474,7 +474,7 @@
     % otherwise we would stuff up the arg types for unification predicates for
     % equivalence types.
 
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_clauses_info(PredInfo0, ClausesInfo0),
     clauses_info_get_vartypes(ClausesInfo0, VarTypes0),
@@ -3547,7 +3547,7 @@
 
 expand_class_method_body(hlds_class_proc(PredId, ProcId), !ProcNum,
         !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
Index: compiler/pred_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pred_table.m,v
retrieving revision 1.14
diff -u -b -r1.14 pred_table.m
--- compiler/pred_table.m	30 Mar 2010 23:57:25 -0000	1.14
+++ compiler/pred_table.m	20 Jul 2010 04:02:39 -0000
@@ -88,11 +88,22 @@
     predicate_table::in, predicate_table::out) is det.
 
     % Get a list of all the valid predids in the predicate_table.
+    % (Predicates whose definition contains a type error, etc.
+    % get removed from this list, so that later passes can rely
+    % on the predicates in this list being type-correct, etc.)
     %
     % This operation does not logically change the predicate table,
     % but does update it physically.
     %
-:- pred predicate_table_get_predids(list(pred_id)::out,
+:- pred predicate_table_get_valid_predids(list(pred_id)::out,
+    predicate_table::in, predicate_table::out) is det.
+
+    % Set the list of the pred_ids of all the valid predicates.
+    % NOTE: The only approved way to specify the list is to call
+    % module_info_get_valid_predids or predicate_table_get_valid_predids,
+    % and remove some pred_ids from that list.
+    %
+:- pred predicate_table_set_valid_predids(list(pred_id)::in,
     predicate_table::in, predicate_table::out) is det.
 
     % Remove a pred_id from the valid list.
@@ -310,65 +321,52 @@
 
 :- type predicate_table
     --->    predicate_table(
-                preds               :: pred_table,
                                     % Map from pred_id to pred_info.
+                preds                           :: pred_table,
 
-                next_pred_id        :: pred_id,
                                     % The next available pred_id.
+                next_pred_id                    :: pred_id,
 
+                % The keys of the pred_table - cached here for efficiency.
+                % The old pred_ids are listed in order; the new pred_ids
+                % are listed in reverse order. You can get the full list
+                % with old_pred_ids ++ reverse(new_rev_pred_ids).
                 old_pred_ids        :: list(pred_id),
                 new_rev_pred_ids    :: list(pred_id),
-                                    % The keys of the pred_table - cached
-                                    % here for efficiency. The old pred_ids
-                                    % are listed in order; the new pred_iss
-                                    % are listed in reverse order. You can get
-                                    % the full list with old_pred_ids ++
-                                    % reverse(new_rev_pred_ids).
 
+                % Maps each pred_id to its accessibility by (partially)
+                % unqualified names.
                 accessibility_table :: accessibility_table,
-                                    % How is the predicate accessible?
-
-                % Indexes on predicates
 
+                % Indexes on predicates and on functions.
+                % - Map from pred/func name to pred_id.
+                % - Map from pred/func name & arity to pred_id.
+                % - Map from module, pred/func name & arity to pred_id.
                 pred_name_index     :: name_index,
-                                    % Map from pred name to pred_id.
-
                 pred_name_arity_index :: name_arity_index,
-                                    % Map from pred name & arity to pred_id.
-
                 pred_module_name_arity_index :: module_name_arity_index,
-                                    % Map from pred module, name & arity
-                                    % to pred_id.
-
-                % Indexes on functions
-
                 func_name_index     :: name_index,
-                                    % Map from func name to pred_id.
-
                 func_name_arity_index :: name_arity_index,
-                                    % Map from func name & arity to pred_id.
-
                 func_module_name_arity_index :: module_name_arity_index
-                                    % Map from func module, name & arity
-                                    % to pred_id.
             ).
 
 :- type accessibility_table == map(pred_id, name_accessibility).
 
 :- type name_accessibility
     --->    access(
-                % Is this predicate accessible by its unqualified name.
+                % Is this predicate accessible by its unqualified name?
                 accessible_by_unqualifed_name       :: bool,
 
                 % Is this predicate accessible by any partially qualified
-                % names.
+                % names?
                 accessible_by_partially_qualified_names :: bool
             ).
 
 :- type name_index  == map(string, list(pred_id)).
 
 :- type name_arity_index == map(name_arity, list(pred_id)).
-:- type name_arity ---> string / arity.
+:- type name_arity
+    --->    string / arity.
 
     % First search on module and name, then search on arity. The two levels
     % are needed because typecheck.m needs to be able to search on module
@@ -394,7 +392,8 @@
         Func_N_Index, Func_NA_Index, Func_MNA_Index).
 
 predicate_table_optimize(PredicateTable0, PredicateTable) :-
-    PredicateTable0 = predicate_table(A, B, C, D, E,
+    PredicateTable0 = predicate_table(Preds, NextPredId,
+        OldPredIds, NewRevPredIds, Accessibility,
         Pred_N_Index0, Pred_NA_Index0, Pred_MNA_Index0,
         Func_N_Index0, Func_NA_Index0, Func_MNA_Index0),
     map.optimize(Pred_N_Index0, Pred_N_Index),
@@ -403,16 +402,17 @@
     map.optimize(Func_N_Index0, Func_N_Index),
     map.optimize(Func_NA_Index0, Func_NA_Index),
     map.optimize(Func_MNA_Index0, Func_MNA_Index),
-    PredicateTable = predicate_table(A, B, C, D, E,
+    PredicateTable = predicate_table(Preds, NextPredId,
+        OldPredIds, NewRevPredIds, Accessibility,
         Pred_N_Index, Pred_NA_Index, Pred_MNA_Index,
         Func_N_Index, Func_NA_Index, Func_MNA_Index).
 
 predicate_table_get_preds(PredicateTable, PredicateTable ^ preds).
 
-predicate_table_set_preds(Preds, PredicateTable,
-    PredicateTable ^ preds := Preds).
+predicate_table_set_preds(Preds, !PredicateTable) :-
+    !PredicateTable ^ preds := Preds.
 
-predicate_table_get_predids(PredIds, !PredicateTable) :-
+predicate_table_get_valid_predids(PredIds, !PredicateTable) :-
     OldPredIds = !.PredicateTable ^ old_pred_ids,
     NewRevPredIds = !.PredicateTable ^ new_rev_pred_ids,
     (
@@ -425,6 +425,10 @@
     !PredicateTable ^ old_pred_ids := PredIds,
     !PredicateTable ^ new_rev_pred_ids := [].
 
+predicate_table_set_valid_predids(PredIds, !PredicateTable) :-
+    !PredicateTable ^ old_pred_ids := PredIds,
+    !PredicateTable ^ new_rev_pred_ids := [].
+
 predicate_table_remove_predid(PredId, !PredicateTable) :-
     OldPredIds0 = !.PredicateTable ^ old_pred_ids,
     NewRevPredIds0 = !.PredicateTable ^ new_rev_pred_ids,
@@ -786,7 +790,7 @@
     list.foldl(
         reinsert_for_restrict(PartialQualInfo, Preds, AccessibilityTable),
         PredIds, !PredicateTable),
-    predicate_table_get_predids(NewPredIds, !PredicateTable),
+    predicate_table_get_valid_predids(NewPredIds, !PredicateTable),
     list.sort(NewPredIds, SortedNewPredIds),
     !PredicateTable ^ old_pred_ids := SortedNewPredIds,
     !PredicateTable ^ new_rev_pred_ids := [].
Index: compiler/proc_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/proc_gen.m,v
retrieving revision 1.36
diff -u -b -r1.36 proc_gen.m
--- compiler/proc_gen.m	4 Nov 2009 03:44:50 -0000	1.36
+++ compiler/proc_gen.m	20 Jul 2010 04:02:45 -0000
@@ -120,7 +120,7 @@
 
 generate_module_code(!ModuleInfo, !GlobalData, Procedures, !IO) :-
     % Get a list of all the predicate ids for which we will generate code.
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     % Check if we want to use parallel code generation.
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.lookup_bool_option(Globals, parallel_code_gen, ParallelCodeGen),
@@ -217,7 +217,7 @@
     % also need to be repeated there.
     %
 generate_maybe_pred_code(ModuleInfo, PredId, Predicates, !GlobalData, !IO) :-
-    module_info_preds(ModuleInfo, PredInfos),
+    module_info_get_preds(ModuleInfo, PredInfos),
     map.lookup(PredInfos, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     (
@@ -246,7 +246,7 @@
     list(c_procedure)::out, global_data::in, global_data::out) is det.
 
 generate_pred_code_par(ModuleInfo, PredId, Predicates, !GlobalData) :-
-    module_info_preds(ModuleInfo, PredInfos),
+    module_info_get_preds(ModuleInfo, PredInfos),
     map.lookup(PredInfos, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     generate_pred_code(ModuleInfo, PredId, PredInfo, ProcIds, Predicates,
Index: compiler/purity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/purity.m,v
retrieving revision 1.137
diff -u -b -r1.137 purity.m
--- compiler/purity.m	26 Nov 2009 04:56:00 -0000	1.137
+++ compiler/purity.m	20 Jul 2010 04:02:50 -0000
@@ -205,7 +205,7 @@
 %-----------------------------------------------------------------------------%
 
 puritycheck_module(!ModuleInfo, !Specs) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     check_preds_purity(PredIds, !ModuleInfo, !Specs).
 
 :- pred check_preds_purity(list(pred_id)::in,
Index: compiler/rbmm.condition_renaming.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.condition_renaming.m,v
retrieving revision 1.11
diff -u -b -r1.11 rbmm.condition_renaming.m
--- compiler/rbmm.condition_renaming.m	23 Dec 2008 01:37:40 -0000	1.11
+++ compiler/rbmm.condition_renaming.m	20 Jul 2010 04:02:58 -0000
@@ -150,7 +150,7 @@
 collect_non_local_and_in_cond_regions(ModuleInfo, RptaInfoTable,
         LRBeforeTable, LRAfterTable, ResurRenamingTable,
         ResurRenamingAnnoTable, NonLocalRegionsTable, InCondRegionsTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     list.foldl2(collect_non_local_and_in_cond_regions_pred(ModuleInfo,
         RptaInfoTable, LRBeforeTable, LRAfterTable, ResurRenamingTable,
         ResurRenamingAnnoTable), PredIds,
Index: compiler/rbmm.execution_path.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.execution_path.m,v
retrieving revision 1.10
diff -u -b -r1.10 rbmm.execution_path.m
--- compiler/rbmm.execution_path.m	11 Jun 2009 07:00:18 -0000	1.10
+++ compiler/rbmm.execution_path.m	20 Jul 2010 04:03:06 -0000
@@ -53,7 +53,7 @@
 %
 
 execution_path_analysis(ModuleInfo, ExecPathTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     map.init(ExecPathTable0),
     list.foldl(execution_path_analysis_pred(ModuleInfo), PredIds,
         ExecPathTable0, ExecPathTable).
Index: compiler/rbmm.live_region_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.live_region_analysis.m,v
retrieving revision 1.4
diff -u -b -r1.4 rbmm.live_region_analysis.m
--- compiler/rbmm.live_region_analysis.m	21 Apr 2009 14:05:55 -0000	1.4
+++ compiler/rbmm.live_region_analysis.m	20 Jul 2010 04:03:13 -0000
@@ -83,7 +83,7 @@
 live_region_analysis(ModuleInfo, RptaInfoTable, LVBeforeTable, LVAfterTable,
         VoidVarTable, LRBeforeTable, LRAfterTable, VoidVarRegionTable,
         InputRTable, OutputRTable, BornRTable, DeadRTable, LocalRTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     map.init(LRBeforeTable0),
     map.init(LRAfterTable0),
     map.init(VoidVarRegionTable0),
Index: compiler/rbmm.live_variable_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.live_variable_analysis.m,v
retrieving revision 1.3
diff -u -b -r1.3 rbmm.live_variable_analysis.m
--- compiler/rbmm.live_variable_analysis.m	23 Jul 2007 05:06:13 -0000	1.3
+++ compiler/rbmm.live_variable_analysis.m	20 Jul 2010 04:03:19 -0000
@@ -70,7 +70,7 @@
 
 live_variable_analysis(ModuleInfo, ExecPathTable, LVBeforeTable,
         LVAfterTable, VoidVarTable) :-
-    module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
     map.init(LVBeforeTable0),
     map.init(LVAfterTable0),
     map.init(VoidVarTable0),
Index: compiler/rbmm.points_to_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.points_to_analysis.m,v
retrieving revision 1.13
diff -u -b -r1.13 rbmm.points_to_analysis.m
--- compiler/rbmm.points_to_analysis.m	28 Nov 2009 01:58:00 -0000	1.13
+++ compiler/rbmm.points_to_analysis.m	20 Jul 2010 04:03:25 -0000
@@ -88,7 +88,7 @@
     rpta_info_table::in, rpta_info_table::out) is det.
 
 intra_proc_rpta(ModuleInfo, !InfoTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     list.foldl(intra_proc_rpta_pred(ModuleInfo), PredIds, !InfoTable).
 
 :- pred intra_proc_rpta_pred(module_info::in, pred_id::in,
Index: compiler/rbmm.region_arguments.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.region_arguments.m,v
retrieving revision 1.2
diff -u -b -r1.2 rbmm.region_arguments.m
--- compiler/rbmm.region_arguments.m	1 Dec 2009 10:24:25 -0000	1.2
+++ compiler/rbmm.region_arguments.m	20 Jul 2010 04:03:32 -0000
@@ -84,7 +84,7 @@
 
 record_region_arguments(ModuleInfo, RptaInfoTable, ConstantRTable,
         DeadRTable, BornRTable, FormalRegionArgTable, ActualRegionArgTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     list.foldl2(record_actual_region_arguments_pred(ModuleInfo,
         RptaInfoTable, ConstantRTable, DeadRTable, BornRTable),
         PredIds, map.init, FormalRegionArgTable,
Index: compiler/rbmm.region_instruction.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.region_instruction.m,v
retrieving revision 1.8
diff -u -b -r1.8 rbmm.region_instruction.m
--- compiler/rbmm.region_instruction.m	30 Apr 2009 07:49:41 -0000	1.8
+++ compiler/rbmm.region_instruction.m	20 Jul 2010 04:03:39 -0000
@@ -130,7 +130,7 @@
         DeadRTable, LocalRTable,
         BecomeLiveTable, BecomeDeadBeforeTable, BecomeDeadAfterTable,
         RegionInstructionTable) :-
-    module_info_predids(PredIds, ModuleInfo, _),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _),
     list.foldl4(introduce_region_instructions_pred(ModuleInfo,
         RptaInfoTable, ExecPathTable, LRBeforeTable, LRAfterTable,
         VoidVarRegionTable, BornRTable, DeadRTable, LocalRTable), PredIds,
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.248
diff -u -b -r1.248 simplify.m
--- compiler/simplify.m	26 Jul 2010 05:05:48 -0000	1.248
+++ compiler/simplify.m	27 Jul 2010 00:38:51 -0000
@@ -491,7 +491,7 @@
             % transformation that inserts calls to these predicates,
             % there is no point in invoking find_format_call again later.
 
-            module_info_preds(!.ModuleInfo, PredTable1),
+            module_info_get_preds(!.ModuleInfo, PredTable1),
             map.lookup(PredTable1, PredId, PredInfo1),
             pred_info_get_procedures(PredInfo1, ProcTable1),
             map.det_update(ProcTable1, ProcId, !.ProcInfo, ProcTable),
Index: compiler/ssdebug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ssdebug.m,v
retrieving revision 1.28
diff -u -b -r1.28 ssdebug.m
--- compiler/ssdebug.m	17 Jun 2010 02:18:28 -0000	1.28
+++ compiler/ssdebug.m	20 Jul 2010 04:03:44 -0000
@@ -236,7 +236,7 @@
 :- pred first_pass(module_info::in, module_info::out) is det.
 
 first_pass(!ModuleInfo) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl2(first_pass_in_pred, PredIds, map.init, _ProxyMap, !ModuleInfo).
 
 :- pred first_pass_in_pred(pred_id::in, proxy_map::in, proxy_map::out,
Index: compiler/stm_expand.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stm_expand.m,v
retrieving revision 1.10
diff -u -b -r1.10 stm_expand.m
--- compiler/stm_expand.m	19 Nov 2009 00:08:34 -0000	1.10
+++ compiler/stm_expand.m	20 Jul 2010 04:03:50 -0000
@@ -250,7 +250,7 @@
 %-----------------------------------------------------------------------------%
 
 stm_process_module(!ModuleInfo) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(stm_process_pred, PredIds, !ModuleInfo),
     module_info_clobber_dependency_info(!ModuleInfo).
 
@@ -263,7 +263,7 @@
     module_info::out) is det.
 
 stm_process_proc(PredId, ProcId, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -274,7 +274,7 @@
     pred_info_get_procedures(PredInfo1, ProcTable1),
     map.det_update(ProcTable1, ProcId, ProcInfo, ProcTable),
     pred_info_set_procedures(ProcTable, PredInfo1, PredInfo),
-    module_info_preds(!.ModuleInfo, PredTable1),
+    module_info_get_preds(!.ModuleInfo, PredTable1),
     map.det_update(PredTable1, PredId, PredInfo, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
 
Index: compiler/stratify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stratify.m,v
retrieving revision 1.73
diff -u -b -r1.73 stratify.m
--- compiler/stratify.m	14 Aug 2009 20:37:48 -0000	1.73
+++ compiler/stratify.m	20 Jul 2010 04:03:55 -0000
@@ -498,7 +498,7 @@
     map.init(!:ProcCalls),
     map.init(!:HOInfo),
     set.init(!:CallsHO),
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     expand_predids(PredIds, !.ModuleInfo, !ProcCalls, !HOInfo, !CallsHO).
 
     % Finds the transitive closure of a given list of procedures.
Index: compiler/structure_reuse.analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.analysis.m,v
retrieving revision 1.23
diff -u -b -r1.23 structure_reuse.analysis.m
--- compiler/structure_reuse.analysis.m	4 Nov 2009 03:44:50 -0000	1.23
+++ compiler/structure_reuse.analysis.m	20 Jul 2010 04:04:12 -0000
@@ -483,7 +483,7 @@
 :- pred process_imported_reuse(module_info::in, module_info::out) is det.
 
 process_imported_reuse(!ModuleInfo):-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(process_imported_reuse_in_pred, PredIds, !ModuleInfo).
 
 :- pred process_imported_reuse_in_pred(pred_id::in, module_info::in,
@@ -491,8 +491,8 @@
 
 process_imported_reuse_in_pred(PredId, !ModuleInfo) :-
     some [!PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
-        PredInfo0 = !.PredTable ^ det_elem(PredId),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
+        map.lookup(!.PredTable, PredId, PredInfo0),
         process_imported_reuse_in_procs(PredInfo0, PredInfo),
         svmap.det_update(PredId, PredInfo, !PredTable),
         module_info_set_preds(!.PredTable, !ModuleInfo)
@@ -558,7 +558,7 @@
 
 process_intermod_analysis_reuse(!ModuleInfo, ReuseTable, ExternalRequests,
         MustHaveReuseVersions) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl4(process_intermod_analysis_reuse_pred, PredIds,
         !ModuleInfo, reuse_as_table_init, ReuseTable, [], ExternalRequests0,
         [], MustHaveReuseVersions),
@@ -771,7 +771,7 @@
     (
         OptFileRes = ok(OptFile),
         io.set_output_stream(OptFile, OldStream, !IO),
-        module_info_predids(PredIds, !ModuleInfo),
+        module_info_get_valid_predids(PredIds, !ModuleInfo),
         list.foldl(write_pred_reuse_info(!.ModuleInfo), PredIds, !IO),
         io.set_output_stream(OldStream, _, !IO),
         io.close_output(OptFile, !IO),
Index: compiler/structure_reuse.direct.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.direct.m,v
retrieving revision 1.14
diff -u -b -r1.14 structure_reuse.direct.m
--- compiler/structure_reuse.direct.m	14 Oct 2009 05:28:44 -0000	1.14
+++ compiler/structure_reuse.direct.m	20 Jul 2010 04:04:22 -0000
@@ -73,8 +73,8 @@
 %-----------------------------------------------------------------------------%
 
 direct_reuse_pass(SharingTable, !ModuleInfo, !ReuseTable) :-
-    % Gather the pred-ids of the preds that need to be analysed.
-    module_info_predids(AllPredIds, !ModuleInfo),
+    % Gather the pred_ids of the preds that need to be analysed.
+    module_info_get_valid_predids(AllPredIds, !ModuleInfo),
     list.filter(pred_requires_analysis(!.ModuleInfo), AllPredIds,
         ToBeAnalysedPredIds),
 
@@ -139,7 +139,7 @@
 
 direct_reuse_process_proc(SharingTable, PredId, ProcId,
         !ModuleInfo, !ReuseTable) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.lookup(Preds0, PredId, Pred0),
     pred_info_get_procedures(Pred0, Procs0),
     map.lookup(Procs0, ProcId, Proc0),
Index: compiler/structure_reuse.domain.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.domain.m,v
retrieving revision 1.21
diff -u -b -r1.21 structure_reuse.domain.m
--- compiler/structure_reuse.domain.m	4 Nov 2009 03:44:51 -0000	1.21
+++ compiler/structure_reuse.domain.m	20 Jul 2010 04:04:28 -0000
@@ -989,7 +989,7 @@
     io.nl(!IO).
 
 load_structure_reuse_table(ModuleInfo) = ReuseTable :- 
-    module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
     list.foldl(load_structure_reuse_table_2(ModuleInfo), PredIds,
         reuse_as_table_init, ReuseTable).
 
Index: compiler/structure_sharing.analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_sharing.analysis.m,v
retrieving revision 1.46
diff -u -b -r1.46 structure_sharing.analysis.m
--- compiler/structure_sharing.analysis.m	4 Nov 2009 03:44:51 -0000	1.46
+++ compiler/structure_sharing.analysis.m	20 Jul 2010 04:04:49 -0000
@@ -158,7 +158,7 @@
 :- pred process_imported_sharing(module_info::in, module_info::out) is det.
 
 process_imported_sharing(!ModuleInfo):-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(process_imported_sharing_in_pred, PredIds, !ModuleInfo).
 
 :- pred process_imported_sharing_in_pred(pred_id::in, module_info::in,
@@ -166,7 +166,7 @@
 
 process_imported_sharing_in_pred(PredId, !ModuleInfo) :-
     some [!PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
         PredInfo0 = !.PredTable ^ det_elem(PredId),
         process_imported_sharing_in_procs(PredInfo0, PredInfo),
         svmap.det_update(PredId, PredInfo, !PredTable),
@@ -232,7 +232,7 @@
     module_info::out) is det.
 
 process_intermod_analysis_imported_sharing(!ModuleInfo):-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(process_intermod_analysis_imported_sharing_in_pred, PredIds,
         !ModuleInfo).
 
@@ -241,8 +241,8 @@
 
 process_intermod_analysis_imported_sharing_in_pred(PredId, !ModuleInfo) :-
     some [!PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
-        PredInfo0 = !.PredTable ^ det_elem(PredId),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
+        map.lookup(!.PredTable, PredId, PredInfo0),
         ( pred_info_is_imported_not_external(PredInfo0) ->
             module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo),
             process_intermod_analysis_imported_sharing_in_procs(!.ModuleInfo,
@@ -393,7 +393,7 @@
         MakeAnalysisRegistry = yes,
         some [!AnalysisInfo] (
             module_info_get_analysis_info(!.ModuleInfo, !:AnalysisInfo),
-            module_info_predids(PredIds, !ModuleInfo),
+            module_info_get_valid_predids(PredIds, !ModuleInfo),
             list.foldl(maybe_record_sharing_analysis_result(!.ModuleInfo,
                 !.SharingTable), PredIds, !AnalysisInfo),
             list.foldl(handle_dep_procs(!.ModuleInfo), DepProcs,
@@ -934,7 +934,7 @@
     (
         OptFileRes = ok(OptFile),
         io.set_output_stream(OptFile, OldStream, !IO),
-        module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
         list.foldl(write_pred_sharing_info(ModuleInfo), PredIds, !IO),
         io.set_output_stream(OldStream, _, !IO),
         io.close_output(OptFile, !IO),
Index: compiler/structure_sharing.domain.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_sharing.domain.m,v
retrieving revision 1.40
diff -u -b -r1.40 structure_sharing.domain.m
--- compiler/structure_sharing.domain.m	11 Aug 2008 07:39:35 -0000	1.40
+++ compiler/structure_sharing.domain.m	20 Jul 2010 04:04:56 -0000
@@ -936,7 +936,7 @@
 %-----------------------------------------------------------------------------%
 
 load_structure_sharing_table(ModuleInfo) = SharingTable :-
-    module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+    module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
     list.foldl(load_structure_sharing_table_2(ModuleInfo), PredIds,
         sharing_as_table_init, SharingTable).
 
Index: compiler/switch_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/switch_detection.m,v
retrieving revision 1.148
diff -u -b -r1.148 switch_detection.m
--- compiler/switch_detection.m	8 Sep 2009 02:43:39 -0000	1.148
+++ compiler/switch_detection.m	20 Jul 2010 04:05:02 -0000
@@ -116,7 +116,7 @@
     % Traverse the module structure, calling `detect_switches_in_goal'
     % for each procedure body.
     lookup_allow_multi_arm(!.ModuleInfo, AllowMulti),
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     detect_switches_in_preds_allow(PredIds, AllowMulti, !ModuleInfo).
 
 :- pred detect_switches_in_preds_allow(list(pred_id)::in, allow_multi_arm::in,
@@ -124,7 +124,7 @@
 
 detect_switches_in_preds_allow([], _, !ModuleInfo).
 detect_switches_in_preds_allow([PredId | PredIds], AllowMulti, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     detect_switches_in_pred_allow(PredId, PredInfo, AllowMulti, !ModuleInfo),
     detect_switches_in_preds_allow(PredIds, AllowMulti, !ModuleInfo).
@@ -165,7 +165,7 @@
     allow_multi_arm::in, module_info::in, module_info::out) is det.
 
 detect_switches_in_proc_allow(ProcId, PredId, AllowMulti, !ModuleInfo) :-
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.153
diff -u -b -r1.153 table_gen.m
--- compiler/table_gen.m	4 Sep 2009 02:27:55 -0000	1.153
+++ compiler/table_gen.m	20 Jul 2010 02:18:12 -0000
@@ -107,7 +107,7 @@
     % polymorphism and getting an updated module_info back.
     %
 table_gen_process_module(!ModuleInfo, !Specs) :-
-    module_info_preds(!.ModuleInfo, Preds0),
+    module_info_get_preds(!.ModuleInfo, Preds0),
     map.keys(Preds0, PredIds),
     map.init(GenMap0),
     table_gen_process_preds(PredIds, !ModuleInfo, GenMap0, _, !Specs).
@@ -139,7 +139,7 @@
 table_gen_process_procs(_PredId, [], !ModuleInfo, !GenMap, !Specs).
 table_gen_process_procs(PredId, [ProcId | ProcIds], !ModuleInfo, !GenMap,
         !Specs) :-
-    module_info_preds(!.ModuleInfo, PredTable),
+    module_info_get_preds(!.ModuleInfo, PredTable),
     map.lookup(PredTable, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.lookup(ProcTable, ProcId, ProcInfo0),
@@ -563,7 +563,7 @@
     % The transformation doesn't pay attention to the purity of compound goals,
     % so recompute the purity here.
     repuritycheck_proc(!.ModuleInfo, proc(PredId, ProcId), !PredInfo),
-    module_info_preds(!.ModuleInfo, PredTable1),
+    module_info_get_preds(!.ModuleInfo, PredTable1),
     map.det_update(PredTable1, PredId, !.PredInfo, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo).
 
@@ -1225,7 +1225,7 @@
         clone_proc_and_create_call(PredInfo, ProcId, CallExpr, ModuleInfo0,
             ModuleInfo),
         NewGoal = hlds_goal(CallExpr, OrigGoalInfo),
-        !:TableInfo = !.TableInfo ^ table_module_info := ModuleInfo
+        !TableInfo ^ table_module_info := ModuleInfo
     ;
         NewGoal = OrigGoal,
         ModuleInfo = ModuleInfo0
@@ -1722,8 +1722,7 @@
         NumberedInputVars, NumberedOutputVars,
         OrigNonLocals, OrigInstMapDelta, !.VarTypes, !.VarSet,
         GeneratorTableInfo0, GeneratorTableInfo, InputSteps, OutputSteps),
-    !:TableInfo = !.TableInfo ^ table_module_info :=
-        GeneratorTableInfo ^ table_module_info.
+    !TableInfo ^ table_module_info := GeneratorTableInfo ^ table_module_info.
 
 :- pred generate_save_input_vars_code(assoc_list(foreign_arg, mer_mode)::in,
     module_info::in, int::in, list(foreign_arg)::out, string::out, string::out)
@@ -1839,10 +1838,10 @@
     map.det_insert(ProcTable0, ProcId, !.ProcInfo, ProcTable),
     pred_info_set_procedures(ProcTable, !PredInfo),
 
-    module_info_preds(ModuleInfo1, PredTable0),
+    module_info_get_preds(ModuleInfo1, PredTable0),
     map.det_update(PredTable0, PredId, !.PredInfo, PredTable),
     module_info_set_preds(PredTable, ModuleInfo1, ModuleInfo),
-    !:TableInfo = !.TableInfo ^ table_module_info := ModuleInfo.
+    !TableInfo ^ table_module_info := ModuleInfo.
 
 :- pred clone_pred_info(pred_id::in, pred_info::in, list(prog_var)::in,
     list(var_mode_pos_method)::in, pred_id::out,
@@ -1891,7 +1890,7 @@
     module_info_get_predicate_table(ModuleInfo0, PredTable0),
     predicate_table_insert(PredInfo, GeneratorPredId, PredTable0, PredTable),
     module_info_set_predicate_table(PredTable, ModuleInfo0, ModuleInfo),
-    !:TableInfo = !.TableInfo ^ table_module_info := ModuleInfo.
+    !TableInfo ^ table_module_info := ModuleInfo.
 
     % clone_proc_and_create_call(PredInfo, ProcId, CallExpr, !ModuleInfo).
     % This predicate creates a new procedure with the same body as the
Index: compiler/tabling_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/tabling_analysis.m,v
retrieving revision 1.20
diff -u -b -r1.20 tabling_analysis.m
--- compiler/tabling_analysis.m	14 Oct 2009 05:28:44 -0000	1.20
+++ compiler/tabling_analysis.m	20 Jul 2010 04:05:12 -0000
@@ -157,7 +157,7 @@
         (
             MakeAnalysisReg = yes,
             module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0),
-            module_info_predids(PredIds, !ModuleInfo),
+            module_info_get_valid_predids(PredIds, !ModuleInfo),
             list.foldl(maybe_record_mm_tabling_result(!.ModuleInfo),
                 PredIds, AnalysisInfo0, AnalysisInfo),
             module_info_set_analysis_info(AnalysisInfo, !ModuleInfo)
@@ -807,7 +807,7 @@
         OptFileRes = ok(OptFile),
         io.set_output_stream(OptFile, OldStream, !IO),
         module_info_get_mm_tabling_info(ModuleInfo, TablingInfo),
-        module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
         list.foldl(write_pragma_mm_tabling_info(ModuleInfo, TablingInfo),
             PredIds, !IO),
         io.set_output_stream(OldStream, _, !IO),
Index: compiler/term_constr_build.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_build.m,v
retrieving revision 1.26
diff -u -b -r1.26 term_constr_build.m
--- compiler/term_constr_build.m	4 Nov 2009 03:44:51 -0000	1.26
+++ compiler/term_constr_build.m	20 Jul 2010 02:18:42 -0000
@@ -139,7 +139,7 @@
         term_constr_build_abstract_proc(EntryProcs, Options, SCC,
             !.ModuleInfo),
         SCC, varset.init, SizeVarset, [], AbstractSCC, !IO),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     RecordInfo = (pred(Info::in, !.Errors::in, !:Errors::out,
             !.PredTable::in, !:PredTable::out) is det :-
         Info = term_scc_info(proc(PredId, ProcId), AR0, VarMap, Status,
@@ -157,16 +157,15 @@
         map.lookup(ProcTable0, ProcId, ProcInfo0),
         some [!TermInfo] (
             proc_info_get_termination2_info(ProcInfo0, !:TermInfo),
-            !:TermInfo = !.TermInfo ^ intermod_status := yes(Status),
-            !:TermInfo = !.TermInfo ^ abstract_rep    := yes(AR),
-            !:TermInfo = !.TermInfo ^ size_var_map    := VarMap,
-            !:TermInfo = !.TermInfo ^ head_vars       := HeadSizeVars,
+            !TermInfo ^ intermod_status := yes(Status),
+            !TermInfo ^ abstract_rep    := yes(AR),
+            !TermInfo ^ size_var_map    := VarMap,
+            !TermInfo ^ head_vars       := HeadSizeVars,
 
             % If the remainder of the analysis is going to depend upon
             % higher order constructs, then set up the information accordingly.
             ( analysis_depends_on_ho(AR) ->
-                !:TermInfo = !.TermInfo ^ success_constrs :=
-                    yes(polyhedron.universe),
+                !TermInfo ^ success_constrs := yes(polyhedron.universe),
                 HorderErrors = list.map((func(ho_call(Context))
                     = Context - horder_call), AR ^ ap_ho_calls),
                 list.append(HorderErrors, !Errors)
Index: compiler/term_constr_initial.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_initial.m,v
retrieving revision 1.27
diff -u -b -r1.27 term_constr_initial.m
--- compiler/term_constr_initial.m	14 Oct 2009 05:28:44 -0000	1.27
+++ compiler/term_constr_initial.m	20 Jul 2010 04:25:34 -0000
@@ -107,7 +107,7 @@
 % Also look at builtin_compound_eq, builtin_compound_lt.
 
 preprocess_module(!ModuleInfo, !IO) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     process_builtin_preds(PredIds, !ModuleInfo, !IO),
     process_imported_preds(PredIds, !ModuleInfo).
 
@@ -144,11 +144,11 @@
 
 process_imported_pred(PredId, !ModuleInfo) :-
     some [!PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
         module_info_get_type_spec_info(!.ModuleInfo, TypeSpecInfo),
         TypeSpecInfo = type_spec_info(_, TypeSpecPredIds, _, _),
         ( not set.member(PredId, TypeSpecPredIds) ->
-            PredInfo0 = !.PredTable  ^ det_elem(PredId),
+            map.lookup(!.PredTable, PredId, PredInfo0),
             process_imported_procs(PredInfo0, PredInfo),
             svmap.det_update(PredId, PredInfo, !PredTable),
             module_info_set_preds(!.PredTable, !ModuleInfo)
@@ -172,7 +172,7 @@
 
 process_imported_proc(ProcId, !ProcTable) :-
     some [!ProcInfo] (
-        !:ProcInfo = !.ProcTable ^ det_elem(ProcId),
+        map.lookup(!.ProcTable, ProcId, !:ProcInfo),
         proc_info_get_termination2_info(!.ProcInfo, TermInfo0),
         (
             % Check that there is something to import.
@@ -201,15 +201,14 @@
     create_arg_size_polyhedron(SubstMap, !.TermInfo ^ import_failure,
         MaybeFailurePoly),
     SizeVars = prog_vars_to_size_vars(SizeVarMap, HeadVars),
-    !:TermInfo = !.TermInfo ^ size_var_map := SizeVarMap,
-    !:TermInfo = !.TermInfo ^ head_vars := SizeVars,
-    !:TermInfo = !.TermInfo ^ success_constrs := MaybeSuccessPoly,
-    !:TermInfo = !.TermInfo ^ failure_constrs := MaybeFailurePoly,
-    %
+    !TermInfo ^ size_var_map := SizeVarMap,
+    !TermInfo ^ head_vars := SizeVars,
+    !TermInfo ^ success_constrs := MaybeSuccessPoly,
+    !TermInfo ^ failure_constrs := MaybeFailurePoly,
+
     % We don't use these fields after this point.
-    %
-    !:TermInfo = !.TermInfo ^ import_success := no,
-    !:TermInfo = !.TermInfo ^ import_failure := no.
+    !TermInfo ^ import_success := no,
+    !TermInfo ^ import_failure := no.
 
 :- pred create_substitution_map(list(int)::in, map(int, prog_var)::in,
     size_var_map::in, map(int, size_var)::out) is det.
@@ -264,7 +263,7 @@
     globals.lookup_bool_option(Globals, make_optimization_interface,
         MakeOptInt),
     some [!PredTable] (
-        module_info_preds(!.ModuleInfo, !:PredTable),
+        module_info_get_preds(!.ModuleInfo, !:PredTable),
         PredInfo0 = !.PredTable ^ det_elem(PredId),
         process_builtin_procs(MakeOptInt, PredId, !.ModuleInfo,
             PredInfo0, PredInfo),
@@ -407,12 +406,12 @@
             VarTypes, ArgSize, Termination, VarMap, HeadSizeVars),
         some [!TermInfo] (
             proc_info_get_termination2_info(ProcInfo0, !:TermInfo),
-            !:TermInfo = !.TermInfo ^ success_constrs := yes(ArgSize),
-            !:TermInfo = !.TermInfo ^ term_status := yes(Termination),
+            !TermInfo ^ success_constrs := yes(ArgSize),
+            !TermInfo ^ term_status := yes(Termination),
             IntermodStatus = yes(not_mutually_recursive),
-            !:TermInfo = !.TermInfo ^ intermod_status := IntermodStatus,
-            !:TermInfo = !.TermInfo ^ size_var_map := VarMap,
-            !:TermInfo = !.TermInfo ^ head_vars := HeadSizeVars,
+            !TermInfo ^ intermod_status := IntermodStatus,
+            !TermInfo ^ size_var_map := VarMap,
+            !TermInfo ^ head_vars := HeadSizeVars,
             proc_info_set_termination2_info(!.TermInfo, ProcInfo0, ProcInfo)
         ),
         svmap.det_update(ProcId, ProcInfo, !ProcTable)
@@ -513,14 +512,10 @@
     PredName   = pred_info_name(PredInfo),
     PredArity  = pred_info_orig_arity(PredInfo),
     make_size_var_map(HeadVars, _SizeVarset, SizeVarMap),
-    (
-        no_type_info_builtin(PredModule, PredName, PredArity)
-    ->
+    ( no_type_info_builtin(PredModule, PredName, PredArity) ->
         Constrs = process_no_type_info_builtin(PredName, HeadVars,
             SizeVarMap)
-    ;
-        all_args_input_or_zero_size(ModuleInfo, PredInfo, ProcInfo0)
-    ->
+    ; all_args_input_or_zero_size(ModuleInfo, PredInfo, ProcInfo0) ->
         Constrs = []
     ;
         unexpected(this_file, "builtin with non-zero size args.")
@@ -530,18 +525,15 @@
     HeadSizeVars = prog_vars_to_size_vars(SizeVarMap, HeadVars),
     some [!TermInfo] (
         proc_info_get_termination2_info(ProcInfo0, !:TermInfo),
-        !:TermInfo = !.TermInfo ^ success_constrs := ArgSizeInfo,
-        !:TermInfo = !.TermInfo ^ term_status :=
-            yes(cannot_loop(term_reason_builtin)),
-        !:TermInfo = !.TermInfo ^ intermod_status :=
-            yes(not_mutually_recursive),
-        !:TermInfo = !.TermInfo ^ size_var_map := SizeVarMap,
-        !:TermInfo = !.TermInfo ^ head_vars := HeadSizeVars,
+        !TermInfo ^ success_constrs := ArgSizeInfo,
+        !TermInfo ^ term_status := yes(cannot_loop(term_reason_builtin)),
+        !TermInfo ^ intermod_status := yes(not_mutually_recursive),
+        !TermInfo ^ size_var_map := SizeVarMap,
+        !TermInfo ^ head_vars := HeadSizeVars,
         proc_info_set_termination2_info(!.TermInfo, ProcInfo0, ProcInfo)
     ),
     svmap.det_update(ProcId, ProcInfo, !ProcTable),
-    set_builtin_terminates(ProcIds, PredId, PredInfo, ModuleInfo,
-        !ProcTable).
+    set_builtin_terminates(ProcIds, PredId, PredInfo, ModuleInfo, !ProcTable).
 
 :- func process_no_type_info_builtin(string, prog_vars, size_var_map)
     = constraints.
Index: compiler/term_constr_main.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_main.m,v
retrieving revision 1.21
diff -u -b -r1.21 term_constr_main.m
--- compiler/term_constr_main.m	14 Oct 2009 05:28:44 -0000	1.21
+++ compiler/term_constr_main.m	20 Jul 2010 04:25:40 -0000
@@ -468,7 +468,7 @@
         MakeOptInt),
     (
         MakeOptInt = yes,
-        module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
         make_opt_int(PredIds, ModuleInfo, !IO)
     ;
         MakeOptInt = no
Index: compiler/term_constr_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_util.m,v
retrieving revision 1.17
diff -u -b -r1.17 term_constr_util.m
--- compiler/term_constr_util.m	4 Nov 2009 03:44:51 -0000	1.17
+++ compiler/term_constr_util.m	20 Jul 2010 02:21:43 -0000
@@ -214,16 +214,16 @@
 set_pred_proc_ids_constr_arg_size_info([], _ArgSize, !ModuleInfo).
 set_pred_proc_ids_constr_arg_size_info([PPId | PPIds], ArgSize, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
-    PredInfo0 = PredTable0 ^ det_elem(PredId),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
+    map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
-    ProcInfo0 = ProcTable0 ^ det_elem(ProcId),
+    map.lookup(ProcTable0, ProcId, ProcInfo0),
     proc_info_get_termination2_info(ProcInfo0, TermInfo0),
     TermInfo = TermInfo0 ^ success_constrs := yes(ArgSize),
     proc_info_set_termination2_info(TermInfo, ProcInfo0, ProcInfo),
-    ProcTable = ProcTable0 ^ det_elem(ProcId) := ProcInfo,
+    map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
     pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
-    PredTable = PredTable0 ^ det_elem(PredId) := PredInfo,
+    map.det_update(PredTable0, PredId, PredInfo, PredTable),
     module_info_set_preds(PredTable, !ModuleInfo),
     set_pred_proc_ids_constr_arg_size_info(PPIds, ArgSize, !ModuleInfo).
 
Index: compiler/term_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_util.m,v
retrieving revision 1.58
diff -u -b -r1.58 term_util.m
--- compiler/term_util.m	23 Nov 2007 07:35:28 -0000	1.58
+++ compiler/term_util.m	20 Jul 2010 02:21:57 -0000
@@ -301,7 +301,7 @@
 set_pred_proc_ids_arg_size_info([], _ArgSize, !ModuleInfo).
 set_pred_proc_ids_arg_size_info([PPId | PPIds], ArgSize, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -317,7 +317,7 @@
 set_pred_proc_ids_termination_info([], _Termination, !ModuleInfo).
 set_pred_proc_ids_termination_info([PPId | PPIds], Termination, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
Index: compiler/termination.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/termination.m,v
retrieving revision 1.83
diff -u -b -r1.83 termination.m
--- compiler/termination.m	14 Oct 2009 05:28:44 -0000	1.83
+++ compiler/termination.m	20 Jul 2010 04:25:52 -0000
@@ -99,7 +99,7 @@
 
     % Process builtin and compiler-generated predicates, and user-supplied
     % pragmas.
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     check_preds(PredIds, !ModuleInfo, !IO),
 
     % Process all the SCCs of the call graph in a bottom-up order.
@@ -436,7 +436,7 @@
 set_finite_arg_size_infos([Soln | Solns], OutputSupplierMap, !ModuleInfo) :-
     Soln = PPId - Gamma,
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.lookup(ProcTable, ProcId, ProcInfo),
@@ -456,7 +456,7 @@
 set_infinite_arg_size_infos([], _, !ModuleInfo).
 set_infinite_arg_size_infos([PPId | PPIds], ArgSizeInfo, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, ProcTable),
     map.lookup(ProcTable, ProcId, ProcInfo),
@@ -476,7 +476,7 @@
 set_termination_infos([], _, !ModuleInfo).
 set_termination_infos([PPId | PPIds], TerminationInfo, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_procedures(PredInfo0, ProcTable0),
     map.lookup(ProcTable0, ProcId, ProcInfo0),
@@ -608,7 +608,7 @@
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.lookup_bool_option(Globals, make_optimization_interface,
         MakeOptInt),
-    module_info_preds(!.ModuleInfo, PredTable0),
+    module_info_get_preds(!.ModuleInfo, PredTable0),
     map.lookup(PredTable0, PredId, PredInfo0),
     pred_info_get_import_status(PredInfo0, ImportStatus),
     pred_info_get_context(PredInfo0, Context),
Index: compiler/trailing_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/trailing_analysis.m,v
retrieving revision 1.39
diff -u -b -r1.39 trailing_analysis.m
--- compiler/trailing_analysis.m	14 Oct 2009 05:28:44 -0000	1.39
+++ compiler/trailing_analysis.m	20 Jul 2010 04:26:04 -0000
@@ -166,7 +166,7 @@
         (
             MakeAnalysisReg = yes,
             module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0),
-            module_info_predids(PredIds, !ModuleInfo),
+            module_info_get_valid_predids(PredIds, !ModuleInfo),
             list.foldl(maybe_record_trailing_result(!.ModuleInfo),
                 PredIds, AnalysisInfo0, AnalysisInfo),
             module_info_set_analysis_info(AnalysisInfo, !ModuleInfo)
@@ -1053,7 +1053,7 @@
         OptFileRes = ok(OptFile),
         io.set_output_stream(OptFile, OldStream, !IO),
         module_info_get_trailing_info(ModuleInfo, TrailingInfo),
-        module_info_predids(PredIds, ModuleInfo, _ModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _ModuleInfo),
         list.foldl(write_pragma_trailing_info(ModuleInfo, TrailingInfo),
             PredIds, !IO),
         io.set_output_stream(OldStream, _, !IO),
Index: compiler/trans_opt.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/trans_opt.m,v
retrieving revision 1.55
diff -u -b -r1.55 trans_opt.m
--- compiler/trans_opt.m	14 Oct 2009 05:28:44 -0000	1.55
+++ compiler/trans_opt.m	20 Jul 2010 04:26:10 -0000
@@ -150,7 +150,7 @@
         % Select all the predicates for which something should be written
         % into the .trans_opt file.
 
-        module_info_predids(PredIds, ModuleInfo, _UpdatedModuleInfo),
+        module_info_get_valid_predids(PredIds, ModuleInfo, _UpdatedModuleInfo),
         PredIdsSet = set.from_list(PredIds),
         module_info_get_structure_reuse_preds(ModuleInfo, ReusePredsSet),
         PredIdsNoReusePredsSet = set.difference(PredIdsSet, ReusePredsSet),
Index: compiler/try_expand.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/try_expand.m,v
retrieving revision 1.10
diff -u -b -r1.10 try_expand.m
--- compiler/try_expand.m	15 Feb 2010 01:48:30 -0000	1.10
+++ compiler/try_expand.m	20 Jul 2010 04:05:19 -0000
@@ -258,7 +258,7 @@
             disable_det_warnings(OptionsToRestore, !Globals),
             module_info_set_globals(!.Globals, !ModuleInfo),
 
-            module_info_predids(PredIds, !ModuleInfo),
+            module_info_get_valid_predids(PredIds, !ModuleInfo),
             list.foldl2(expand_try_goals_in_pred, PredIds,
                 !ModuleInfo, !Specs),
 
Index: compiler/type_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_constraints.m,v
retrieving revision 1.9
diff -u -b -r1.9 type_constraints.m
--- compiler/type_constraints.m	4 Jul 2010 10:24:08 -0000	1.9
+++ compiler/type_constraints.m	20 Jul 2010 04:05:27 -0000
@@ -226,7 +226,7 @@
     hlds_module.module_info_get_predicate_table(!.HLDS, PredEnv),
     Environment0 = tconstr_environment(EventEnv, ClassEnv, FuncEnv, PredEnv),
 
-    hlds_module.module_info_predids(PredIds, !HLDS),
+    module_info_get_valid_predids(PredIds, !HLDS),
     list.foldl3(typecheck_one_predicate_if_needed, PredIds,
         Environment0, _, !HLDS, [], Specs).
 
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.445
diff -u -b -r1.445 typecheck.m
--- compiler/typecheck.m	6 Nov 2009 02:22:02 -0000	1.445
+++ compiler/typecheck.m	30 Jul 2010 02:57:04 -0000
@@ -13,45 +13,40 @@
 %
 % The predicates in this module are named as follows:
 %
-%   Predicates that type check a particular language
-%   construct (goal, clause, etc.) are called typecheck_*.
-%   These will eventually have to iterate over every type
-%   assignment in the type assignment set.
+% - Predicates that type check a particular language construct
+%   (goal, clause, etc.) are called typecheck_*. These will eventually
+%   have to iterate over every type assignment in the type assignment set.
 %
-%   Predicates that unify two things with respect to a
-%   single type assignment, as opposed to a type assignment set
-%   are called type_assign_*.
+% - Predicates that unify two things with respect to a single type assignment,
+%   as opposed to a type assignment set are called type_assign_*.
 %
 %   Access predicates for the typecheck_info data structure are called
 %   typecheck_info_*.
 %
 % There are four sorts of types:
 %
-% 1) discriminated unions:
+% 1 discriminated unions:
 %   :- type tree(T) ---> nil ; t(tree(T), T, tree(T)).
 %
-% 2) equivalent types (treated identically, ie, same name.  Any number
-%   of types can be equivalent; the *canonical* one is the one
-%   which is not defined using ==):
+% 2 equivalent types (treated identically, ie, same name. Any number of types
+%   can be equivalent; the *canonical* one is the one which is not defined
+%   using ==):
 %   :- type real == float.
 %
-%   Currently references to equivalence types are expanded
-%   in a separate pass by mercury_compile.m.  It would be better
-%   to avoid expanding them (and instead modify the type unification
-%   algorithm to handle equivalent types) because this would
-%   give better error messages.  However, this is not a high
-%   priority.
+%   Currently references to equivalence types are expanded in a separate pass
+%   by mercury_compile_front_end.m. It would be better to avoid expanding them
+%   (and instead modify the type unification algorithm to handle equivalent
+%   types) because this would give better error messages. However, this is
+%   not a high priority.
 %
-% 3) higher-order predicate and function types
+% 3 higher-order predicate and function types
 %   pred, pred(T), pred(T1, T2), pred(T1, T2, T3), ...
 %   func(T1) = T2, func(T1, T2) = T3, ...
 %
-% 4) builtin types
-%   character, int, float, string
-%       These types have special syntax for constants.
-%   There may be other types (list(T), unit, univ,
-%   etc.) provided by the system, but they can just
-%   be part of the standard library.
+% 4 builtin types
+%   character, int, float, string; These types have special syntax
+%   for constants. There may be other types (list(T), unit, univ, etc.)
+%   provided by the system, but they can just be part of the standard library.
 %
 % Each exported predicate must have a `:- pred' declaration specifying the
 % types of the arguments for that predicate.  For predicates that are
@@ -62,16 +57,16 @@
 % Known Bugs:
 %
 % XXX   Type inference doesn't handle ambiguity as well as it could do.
-%   We should do a topological sort, and then typecheck it all
-%   bottom-up.  If we infer an ambiguous type for a pred, we should
-%   not reject it immediately; instead we should give it an overloaded
-%   type, and keep going.  When we've finished type inference, we should
-%   then delete unused overloadings, and only then should we report
-%   ambiguity errors, if any overloading still remains.
+% We should do a topological sort, and then typecheck it all bottom-up.
+% If we infer an ambiguous type for a pred, we should not reject it
+% immediately; instead we should give it an overloaded type, and keep going.
+% When we've finished type inference, we should then delete unused
+% overloadings, and only then should we report ambiguity errors,
+% if any overloading still remains.
 %
 % Wish list:
 %
-%   we should handle equivalence types here
+% - We should handle equivalence types here.
 %
 %-----------------------------------------------------------------------------%
 
@@ -136,11 +131,13 @@
 :- import_module parse_tree.prog_type_subst.
 :- import_module parse_tree.prog_util.
 
+:- import_module assoc_list.
 :- import_module int.
 :- import_module map.
 :- import_module maybe.
 :- import_module pair.
 :- import_module set.
+:- import_module set_tree234.
 :- import_module std_util.
 :- import_module string.
 :- import_module svmap.
@@ -153,51 +150,116 @@
 %-----------------------------------------------------------------------------%
 
 typecheck_module(!ModuleInfo, Specs, ExceededIterationLimit) :-
-    module_info_predids(PredIds, !ModuleInfo),
     module_info_get_globals(!.ModuleInfo, Globals),
     globals.lookup_int_option(Globals, type_inference_iteration_limit,
         MaxIterations),
-    typecheck_to_fixpoint(1, MaxIterations, PredIds, !ModuleInfo,
+
+    module_info_get_valid_predids(OrigValidPredIds, !ModuleInfo),
+    OrigValidPredIdSet = set_tree234.list_to_set(OrigValidPredIds),
+
+    module_info_get_preds(!.ModuleInfo, PredMap0),
+    map.to_assoc_list(PredMap0, PredIdsInfos0),
+
+    % We seem to need this prepass. Without it, the typechecker throws
+    % an exception for two test cases involving field access functions.
+    % The reason is almost certainly that some part of the typechecker
+    % inspects the definitions of callees (even though it shouldn't),
+    % and thus gets things wrong if field access functions haven't yet had
+    % their defining clauses added to their pred_infos. We cannot add the
+    % defining clauses to the pred_infos of field access functions when those
+    % pred_infos are created, since those clauses are only defaults; any
+    % clauses given by the user override them. This pass is the first chance
+    % to decide that there won't be any user-given clauses coming, and that
+    % therefore the default clauses should be the actual clauses.
+    prepare_for_typecheck(!.ModuleInfo, OrigValidPredIdSet,
+        PredIdsInfos0, PredIdsInfos),
+
+    map.from_sorted_assoc_list(PredIdsInfos, PredMap),
+    module_info_set_preds(PredMap, !ModuleInfo),
+
+    typecheck_to_fixpoint(1, MaxIterations, !ModuleInfo,
+        OrigValidPredIds, OrigValidPredIdSet, FinalValidPredIdSet,
         CheckSpecs, ExceededIterationLimit),
-    construct_type_inference_messages(PredIds, !ModuleInfo, [], InferSpecs),
+
+    construct_type_inference_messages(!.ModuleInfo, FinalValidPredIdSet,
+        OrigValidPredIds, [], InferSpecs),
     Specs = InferSpecs ++ CheckSpecs.
 
+:- pred prepare_for_typecheck(module_info::in, set_tree234(pred_id)::in,
+    assoc_list(pred_id, pred_info)::in, assoc_list(pred_id, pred_info)::out)
+    is det.
+
+prepare_for_typecheck(_, _, [], []).
+prepare_for_typecheck(ModuleInfo, ValidPredIdSet,
+        [PredIdInfo0 | PredIdsInfos0], [PredIdInfo | PredIdsInfos]) :-
+    some [!PredInfo] (
+        PredIdInfo0 = PredId - !:PredInfo,
+        ( set_tree234.member(ValidPredIdSet, PredId) ->
+            % Goal paths are used to identify typeclass constraints.
+            fill_goal_path_slots_in_clauses(ModuleInfo, no, !PredInfo),
+            maybe_add_field_access_function_clause(ModuleInfo, !PredInfo),
+            module_info_get_globals(ModuleInfo, Globals),
+            maybe_improve_headvar_names(Globals, !PredInfo),
+            PredIdInfo = PredId - !.PredInfo
+        ;
+            PredIdInfo = PredIdInfo0
+        )
+    ),
+    prepare_for_typecheck(ModuleInfo, ValidPredIdSet,
+        PredIdsInfos0, PredIdsInfos).
+
     % Repeatedly typecheck the code for a group of predicates
     % until a fixpoint is reached, or until some errors are detected.
     %
-:- pred typecheck_to_fixpoint(int::in, int::in, list(pred_id)::in,
-    module_info::in, module_info::out, list(error_spec)::out, bool::out)
-    is det.
+:- pred typecheck_to_fixpoint(int::in, int::in,
+    module_info::in, module_info::out,
+    list(pred_id)::in, set_tree234(pred_id)::in, set_tree234(pred_id)::out,
+    list(error_spec)::out, bool::out) is det.
 
-typecheck_to_fixpoint(Iteration, NumIterations, PredIds, !ModuleInfo,
+typecheck_to_fixpoint(Iteration, MaxIterations, !ModuleInfo,
+        OrigValidPredIds, OrigValidPredIdSet, FinalValidPredIdSet,
         Specs, ExceededIterationLimit) :-
-    typecheck_module_one_iteration(Iteration, PredIds, !ModuleInfo,
+    module_info_get_preds(!.ModuleInfo, PredMap0),
+    map.to_assoc_list(PredMap0, PredIdsInfos0),
+    typecheck_module_one_iteration(!.ModuleInfo, OrigValidPredIdSet,
+        PredIdsInfos0, PredIdsInfos, [], NewlyInvalidPredIds,
         [], CurSpecs, no, Changed),
+    map.from_sorted_assoc_list(PredIdsInfos, PredMap),
+    module_info_set_preds(PredMap, !ModuleInfo),
+
+    set_tree234.delete_list(NewlyInvalidPredIds,
+        OrigValidPredIdSet, NewValidPredIdSet),
+    NewValidPredIds = set_tree234.to_sorted_list(NewValidPredIdSet),
+    module_info_set_valid_predids(NewValidPredIds, !ModuleInfo),
+
     module_info_get_globals(!.ModuleInfo, Globals),
     (
         ( Changed = no
         ; contains_errors(Globals, CurSpecs) = yes
         )
     ->
+        FinalValidPredIdSet = NewValidPredIdSet,
         Specs = CurSpecs,
         ExceededIterationLimit = no
     ;
         globals.lookup_bool_option(Globals, debug_types, DebugTypes),
         (
             DebugTypes = yes,
-            construct_type_inference_messages(PredIds, !ModuleInfo,
-                [], ProgressSpecs),
+            construct_type_inference_messages(!.ModuleInfo, NewValidPredIdSet,
+                OrigValidPredIds, [], ProgressSpecs),
             trace [io(!IO)] (
                 write_error_specs(ProgressSpecs, Globals, 0, _, 0, _, !IO)
             )
         ;
             DebugTypes = no
         ),
-        ( Iteration < NumIterations ->
-            typecheck_to_fixpoint(Iteration + 1, NumIterations, PredIds,
-                !ModuleInfo, Specs, ExceededIterationLimit)
+        ( Iteration < MaxIterations ->
+            typecheck_to_fixpoint(Iteration + 1, MaxIterations, !ModuleInfo,
+                OrigValidPredIds, OrigValidPredIdSet, FinalValidPredIdSet,
+                Specs, ExceededIterationLimit)
         ;
-            Specs = [typecheck_report_max_iterations_exceeded(NumIterations)],
+            FinalValidPredIdSet = NewValidPredIdSet,
+            Specs = [typecheck_report_max_iterations_exceeded(MaxIterations)],
             ExceededIterationLimit = yes
         )
     ).
@@ -205,18 +267,18 @@
     % Write out the inferred `pred' or `func' declarations for a list of
     % predicates.  Don't write out the inferred types for assertions.
     %
-:- pred construct_type_inference_messages(list(pred_id)::in,
-    module_info::in, module_info::out,
+:- pred construct_type_inference_messages(module_info::in,
+    set_tree234(pred_id)::in, list(pred_id)::in,
     list(error_spec)::in, list(error_spec)::out) is det.
 
-construct_type_inference_messages([], !ModuleInfo, !Specs).
-construct_type_inference_messages([PredId | PredIds], !ModuleInfo, !Specs) :-
-    module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
+construct_type_inference_messages(_, _, [], !Specs).
+construct_type_inference_messages(ModuleInfo, ValidPredIdSet,
+        [PredId | PredIds], !Specs) :-
+    module_info_pred_info(ModuleInfo, PredId, PredInfo),
     pred_info_get_markers(PredInfo, Markers),
     (
         check_marker(Markers, marker_infer_type),
-        module_info_predids(ValidPredIds, !ModuleInfo),
-        list.member(PredId, ValidPredIds),
+        set_tree234.member(ValidPredIdSet, PredId),
         \+ pred_info_get_goal_type(PredInfo, goal_type_promise(_))
     ->
         Spec = construct_type_inference_message(PredInfo),
@@ -224,7 +286,8 @@
     ;
         true
     ),
-    construct_type_inference_messages(PredIds, !ModuleInfo, !Specs).
+    construct_type_inference_messages(ModuleInfo, ValidPredIdSet,
+        PredIds, !Specs).
 
     % Construct a message containing the inferred `pred' or `func' declaration
     % for a single predicate.
@@ -274,66 +337,63 @@
 
     % Iterate over the list of pred_ids in a module.
     %
-:- pred typecheck_module_one_iteration(int::in, list(pred_id)::in,
-    module_info::in, module_info::out,
+:- pred typecheck_module_one_iteration(module_info::in,
+    set_tree234(pred_id)::in,
+    assoc_list(pred_id, pred_info)::in, assoc_list(pred_id, pred_info)::out,
+    list(pred_id)::in, list(pred_id)::out,
     list(error_spec)::in, list(error_spec)::out, bool::in, bool::out) is det.
 
-typecheck_module_one_iteration(_, [], !ModuleInfo, !Specs, !Changed).
-typecheck_module_one_iteration(Iteration, [PredId | PredIds], !ModuleInfo,
-        !Specs, !Changed) :-
-    module_info_preds(!.ModuleInfo, Preds0),
-    map.lookup(Preds0, PredId, PredInfo0),
-    ( pred_info_is_imported(PredInfo0) ->
-        true
+typecheck_module_one_iteration(_, _, [], [],
+        !NewlyInvalidPredIds, !Specs, !Changed).
+typecheck_module_one_iteration(ModuleInfo, ValidPredIdSet,
+        [PredIdInfo0 | PredIdsInfos0], [PredIdInfo | PredIdsInfos],
+        !NewlyInvalidPredIds, !Specs, !Changed) :-
+    PredIdInfo0 = PredId - PredInfo0,
+    (
+        (
+            pred_info_is_imported(PredInfo0)
     ;
-        typecheck_pred_if_needed(Iteration, PredId, PredInfo0, PredInfo1,
-            !ModuleInfo, PredSpecs, PredChanged),
-        module_info_get_globals(!.ModuleInfo, Globals),
+            not set_tree234.member(ValidPredIdSet, PredId)
+        )
+    ->
+        PredIdInfo = PredIdInfo0
+    ;
+        typecheck_pred_if_needed(ModuleInfo, PredId, PredInfo0, PredInfo,
+            PredSpecs, PredChanged),
+
+        module_info_get_globals(ModuleInfo, Globals),
         ContainsErrors = contains_errors(Globals, PredSpecs),
         (
-            ContainsErrors = no,
-            map.det_update(Preds0, PredId, PredInfo1, Preds),
-            module_info_set_preds(Preds, !ModuleInfo)
+            ContainsErrors = no
         ;
             ContainsErrors = yes,
-
-%       This code is not needed at the moment,
-%       since currently we don't run mode analysis if
-%       there are any type errors.
-%       And this code also causes problems:
-%       if there are undefined modes,
-%       this code can end up calling error/1,
-%       since post_finish_ill_typed_pred
-%       assumes that there are no undefined modes.
-%           %
-%           % if we get an error, we need to call
-%           % post_finish_ill_typed_pred on the
-%           % pred, to ensure that its mode declaration gets
-%           % properly module qualified; then we call
-%           % `remove_predid', so that the predicate's definition
-%           % will be ignored by later passes (the declaration
-%           % will still be used to check any calls to it).
-%           %
-%           post_finish_ill_typed_pred(ModuleInfo0,
-%               PredId, PredInfo1, PredInfo),
-%           map.det_update(Preds0, PredId, PredInfo, Preds),
-
-            map.det_update(Preds0, PredId, PredInfo1, Preds),
-            module_info_set_preds(Preds, !ModuleInfo),
-            module_info_remove_predid(PredId, !ModuleInfo)
+            % This code is not needed at the moment, since currently we don't
+            % run mode analysis if there are any type errors. And this code
+            % also causes problems: if there are undefined modes, it can end up
+            % calling error/1, since post_finish_ill_typed_pred assumes that
+            % there are no undefined modes.
+            %
+            % % If we get an error, we need to call post_finish_ill_typed_pred
+            % on the pred, to ensure that its mode declaration gets properly
+            % module qualified; then we call `remove_predid', so that the
+            % predicate's definition will be ignored by later passes
+            % (the declaration will still be used to check any calls to it).
+            %
+            % post_finish_ill_typed_pred(ModuleInfo0, PredId,
+            %   PredInfo1, PredInfo)
+            !:NewlyInvalidPredIds = [PredId | !.NewlyInvalidPredIds]
         ),
+        PredIdInfo = PredId - PredInfo,
         !:Specs = PredSpecs ++ !.Specs,
         bool.or(PredChanged, !Changed)
     ),
-    typecheck_module_one_iteration(Iteration, PredIds, !ModuleInfo,
-        !Specs, !Changed).
+    typecheck_module_one_iteration(ModuleInfo, ValidPredIdSet,
+        PredIdsInfos0, PredIdsInfos, !NewlyInvalidPredIds, !Specs, !Changed).
 
-:- pred typecheck_pred_if_needed(int::in, pred_id::in,
-    pred_info::in, pred_info::out, module_info::in, module_info::out,
-    list(error_spec)::out, bool::out) is det.
+:- pred typecheck_pred_if_needed(module_info::in, pred_id::in,
+    pred_info::in, pred_info::out, list(error_spec)::out, bool::out) is det.
 
-typecheck_pred_if_needed(Iteration, PredId, !PredInfo, !ModuleInfo,
-        Specs, Changed) :-
+typecheck_pred_if_needed(ModuleInfo, PredId, !PredInfo, Specs, Changed) :-
     (
         % Compiler-generated predicates are created already type-correct,
         % so there's no need to typecheck them. The same is true for builtins,
@@ -345,7 +405,7 @@
         % data type.
         (
             is_unify_or_compare_pred(!.PredInfo),
-            \+ special_pred_needs_typecheck(!.PredInfo, !.ModuleInfo)
+            \+ special_pred_needs_typecheck(!.PredInfo, ModuleInfo)
         ;
             pred_info_is_builtin(!.PredInfo),
             pred_info_get_markers(!.PredInfo, Markers),
@@ -364,37 +424,23 @@
         Specs = [],
         Changed = no
     ;
-        typecheck_pred(Iteration, PredId, !PredInfo, !ModuleInfo,
-            Specs, Changed)
+        typecheck_pred(ModuleInfo, PredId, !PredInfo, Specs, Changed)
     ).
 
-:- pred typecheck_pred(int::in, pred_id::in, pred_info::in, pred_info::out,
-    module_info::in, module_info::out, list(error_spec)::out, bool::out)
-    is det.
-
-typecheck_pred(Iteration, PredId, !PredInfo, !ModuleInfo, Specs, Changed) :-
-    module_info_get_globals(!.ModuleInfo, Globals),
-    ( Iteration = 1 ->
-        % Goal paths are used to identify typeclass constraints.
-        fill_goal_path_slots_in_clauses(!.ModuleInfo, no, !PredInfo),
-        maybe_add_field_access_function_clause(!.ModuleInfo, !PredInfo),
-        maybe_improve_headvar_names(Globals, !PredInfo),
+:- pred typecheck_pred(module_info::in, pred_id::in,
+    pred_info::in, pred_info::out, list(error_spec)::out, bool::out) is det.
 
-        % The goal_type of the pred_info may have been changed
-        % by maybe_add_field_access_function_clause.
-        module_info_set_pred_info(PredId, !.PredInfo, !ModuleInfo)
-    ;
-        true
-    ),
+typecheck_pred(ModuleInfo, PredId, !PredInfo, Specs, Changed) :-
+    module_info_get_globals(ModuleInfo, Globals),
     pred_info_get_arg_types(!.PredInfo, _ArgTypeVarSet, ExistQVars0,
         ArgTypes0),
     pred_info_get_clauses_info(!.PredInfo, ClausesInfo0),
     clauses_info_get_clauses_rep(ClausesInfo0, ClausesRep0, ItemNumbers0),
     pred_info_get_markers(!.PredInfo, Markers0),
-    % Handle the --allow-stubs and --warn-stubs options. If --allow-stubs
-    % is set, and there are no clauses, issue a warning (if --warn-stubs
-    % is set), and then generate a "stub" clause that just throws an
-    % exception.
+    % Handle the --allow-stubs and --warn-stubs options.
+    % If --allow-stubs is set, and there are no clauses, then
+    % - issue a warning (if --warn-stubs is set), and then
+    % - generate a "stub" clause that just throws an exception.
     clause_list_is_empty(ClausesRep0) = ClausesRep0IsEmpty,
     (
         ClausesRep0IsEmpty = yes,
@@ -402,14 +448,14 @@
             globals.lookup_bool_option(Globals, allow_stubs, yes),
             \+ check_marker(Markers0, marker_class_method)
         ->
-            Spec = report_no_clauses_stub(!.ModuleInfo, PredId, !.PredInfo),
+            Spec = report_no_clauses_stub(ModuleInfo, PredId, !.PredInfo),
             StartingSpecs = [Spec],
-            generate_stub_clause(PredId, !PredInfo, !.ModuleInfo)
+            generate_stub_clause(PredId, !PredInfo, ModuleInfo)
         ;
             check_marker(Markers0, marker_builtin_stub)
         ->
             StartingSpecs = [],
-            generate_stub_clause(PredId, !PredInfo, !.ModuleInfo)
+            generate_stub_clause(PredId, !PredInfo, ModuleInfo)
         ;
             StartingSpecs = []
         )
@@ -419,7 +465,7 @@
             WarnNonContiguousForeignProcs),
         (
             WarnNonContiguousForeignProcs = yes,
-            StartingSpecs = report_any_non_contiguous_clauses(!.ModuleInfo,
+            StartingSpecs = report_any_non_contiguous_clauses(ModuleInfo,
                 PredId, !.PredInfo, ItemNumbers0, clauses_and_foreign_procs)
         ;
             WarnNonContiguousForeignProcs = no,
@@ -427,7 +473,7 @@
                 WarnNonContiguousClauses),
             (
                 WarnNonContiguousClauses = yes,
-                StartingSpecs = report_any_non_contiguous_clauses(!.ModuleInfo,
+                StartingSpecs = report_any_non_contiguous_clauses(ModuleInfo,
                     PredId, !.PredInfo, ItemNumbers0, only_clauses)
             ;
                 WarnNonContiguousClauses = no,
@@ -464,7 +510,7 @@
                 Specs = [],
                 Changed = no
             ;
-                Specs = [report_no_clauses(!.ModuleInfo, PredId, !.PredInfo)],
+                Specs = [report_no_clauses(ModuleInfo, PredId, !.PredInfo)],
                 Changed = no
             )
         ;
@@ -480,7 +526,7 @@
                 Inferring = yes,
                 trace [io(!IO)] (
                     write_pred_progress_message("% Inferring type of ",
-                        PredId, !.ModuleInfo, !IO)
+                        PredId, ModuleInfo, !IO)
                 ),
                 !:HeadTypeParams = [],
                 PredConstraints = constraints([], [])
@@ -488,7 +534,7 @@
                 Inferring = no,
                 trace [io(!IO)] (
                     write_pred_progress_message("% Type-checking ", PredId,
-                        !.ModuleInfo, !IO)
+                        ModuleInfo, !IO)
                 ),
                 type_vars_list(ArgTypes0, !:HeadTypeParams),
                 pred_info_get_class_context(!.PredInfo, PredConstraints),
@@ -500,16 +546,16 @@
                     !:HeadTypeParams)
             ),
 
-            module_info_get_class_table(!.ModuleInfo, ClassTable),
+            module_info_get_class_table(ModuleInfo, ClassTable),
             make_head_hlds_constraints(ClassTable, TypeVarSet0,
                 PredConstraints, Constraints),
-            ( pred_info_is_field_access_function(!.ModuleInfo, !.PredInfo) ->
+            ( pred_info_is_field_access_function(ModuleInfo, !.PredInfo) ->
                 IsFieldAccessFunction = yes
             ;
                 IsFieldAccessFunction = no
             ),
             pred_info_get_markers(!.PredInfo, PredMarkers0),
-            typecheck_info_init(!.ModuleInfo, PredId, IsFieldAccessFunction,
+            typecheck_info_init(ModuleInfo, PredId, IsFieldAccessFunction,
                 TypeVarSet0, VarSet, ExplicitVarTypes0, !.HeadTypeParams,
                 Constraints, Status, PredMarkers0, StartingSpecs, !:Info),
             get_clause_list(ClausesRep1, Clauses1),
@@ -840,14 +886,14 @@
             list.member(TVar, HeadTypeVars)
     ).
 
-    % Check whether the argument types, type quantifiers, and type
-    % constraints are identical up to renaming.
+    % Check whether the argument types, type quantifiers, and type constraints
+    % are identical up to renaming.
     %
-    % Note that we can't compare each of the parts separately, since
-    % we need to ensure that the renaming (if any) is consistent
-    % over all the arguments and all the constraints.  So we need
-    % to append all the relevant types into one big type list and
-    % then compare them in a single call to identical_up_to_renaming.
+    % Note that we can't compare each of the parts separately, since we need
+    % to ensure that the renaming (if any) is consistent over all the arguments
+    % and all the constraints. So we need to append all the relevant types
+    % into one big type list and then compare them in a single call
+    % to identical_up_to_renaming.
     %
 :- pred argtypes_identical_up_to_renaming(tvar_kind_map::in,
     existq_tvars::in, list(mer_type)::in, prog_constraints::in,
@@ -864,9 +910,9 @@
     identical_up_to_renaming(TypesListA, TypesListB).
 
     % Check if two sets of type class constraints have the same structure
-    % (i.e. they specify the same list of type classes with the same
-    % arities) and if so, concatenate the argument types for all the
-    % type classes in each set of type class constraints and return them.
+    % (i.e. they specify the same list of type classes with the same arities)
+    % and if so, concatenate the argument types for all the type classes
+    % in each set of type class constraints and return them.
     %
 :- pred same_structure(prog_constraints::in, prog_constraints::in,
     list(mer_type)::out, list(mer_type)::out) is semidet.
@@ -963,9 +1009,9 @@
         adjust_func_arity(pf_function, FuncArity, PredArity),
         FuncSymName = qualified(FuncModule, FuncName),
         FuncConsId = cons(FuncSymName, FuncArity, cons_id_dummy_type_ctor),
+        FuncRHS = rhs_functor(FuncConsId, no, FuncArgs),
         create_pure_atomic_complicated_unification(FuncRetVal,
-            rhs_functor(FuncConsId, no, FuncArgs),
-            Context, umc_explicit, [], Goal0),
+            FuncRHS, Context, umc_explicit, [], Goal0),
         Goal0 = hlds_goal(GoalExpr, GoalInfo0),
         NonLocals = proc_arg_vector_to_set(HeadVars),
         goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo),
@@ -2496,9 +2542,8 @@
     % the output parameters, otherwise fails.
     %
     % Instantiates PredConsInfoList to the set of cons_type_info structures
-    % for each predicate with name `ConsId' and arity greater than
-    % or equal to Arity.  GoalPath is used to identify any constraints
-    % introduced.
+    % for each predicate with name `ConsId' and arity greater than or equal to
+    % Arity. GoalPath is used to identify any constraints introduced.
     %
     % For example, functor `map.search/1' has type `pred(K, V)'
     % (hence PredTypeParams = [K, V]) and argument types [map(K, V)].
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.196
diff -u -b -r1.196 unify_gen.m
--- compiler/unify_gen.m	4 Nov 2009 03:44:51 -0000	1.196
+++ compiler/unify_gen.m	20 Jul 2010 02:22:43 -0000
@@ -613,7 +613,7 @@
 
 generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :-
     get_module_info(!.CI, ModuleInfo),
-    module_info_preds(ModuleInfo, Preds),
+    module_info_get_preds(ModuleInfo, Preds),
     map.lookup(Preds, PredId, PredInfo),
     pred_info_get_procedures(PredInfo, Procs),
     map.lookup(Procs, ProcId, ProcInfo),
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.211
diff -u -b -r1.211 unify_proc.m
--- compiler/unify_proc.m	25 Sep 2009 05:13:06 -0000	1.211
+++ compiler/unify_proc.m	20 Jul 2010 02:23:16 -0000
@@ -326,7 +326,7 @@
         !ModuleInfo) :-
     some [!PredInfo, !ProcInfo, !PredMap, !ProcMap, !Goal] (
         % Create a new proc_info for this procedure.
-        module_info_preds(!.ModuleInfo, !:PredMap),
+        module_info_get_preds(!.ModuleInfo, !:PredMap),
         map.lookup(!.PredMap, PredId, !:PredInfo),
         list.length(ArgModes, Arity),
         DeclaredArgModes = no,
Index: compiler/untupling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/untupling.m,v
retrieving revision 1.35
diff -u -b -r1.35 untupling.m
--- compiler/untupling.m	10 Jun 2010 00:58:17 -0000	1.35
+++ compiler/untupling.m	20 Jul 2010 04:26:22 -0000
@@ -163,7 +163,7 @@
     transform_map::out) is det.
 
 expand_args_in_module(!ModuleInfo, TransformMap) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl3(expand_args_in_pred, PredIds,
         !ModuleInfo, map.init, TransformMap, counter.init(0), _).
 
@@ -457,7 +457,7 @@
     module_info::out) is det.
 
 fix_calls_to_expanded_procs(TransformMap, !ModuleInfo) :-
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     list.foldl(fix_calls_in_pred(TransformMap), PredIds, !ModuleInfo).
 
 :- pred fix_calls_in_pred(transform_map::in, pred_id::in, module_info::in,
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.163
diff -u -b -r1.163 unused_args.m
--- compiler/unused_args.m	10 Jun 2010 00:58:17 -0000	1.163
+++ compiler/unused_args.m	20 Jul 2010 04:26:33 -0000
@@ -290,7 +290,7 @@
     (
         MakeAnalysisRegistry = yes,
         module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0),
-        module_info_predids(PredIds, !ModuleInfo),
+        module_info_get_valid_predids(PredIds, !ModuleInfo),
         list.foldl(
             maybe_record_intermod_unused_args(!.ModuleInfo, UnusedArgInfo),
             PredIds, AnalysisInfo0, AnalysisInfo1),
@@ -336,7 +336,7 @@
 init_var_usage(VarUsage, PredProcList, ProcCallInfo, !ModuleInfo) :-
     map.init(ProcCallInfo0),
     map.init(VarUsage0),
-    module_info_predids(PredIds, !ModuleInfo),
+    module_info_get_valid_predids(PredIds, !ModuleInfo),
     setup_local_var_usage(PredIds, VarUsage0, VarUsage, [], PredProcList,
         ProcCallInfo0, ProcCallInfo, !ModuleInfo).
 
@@ -1355,7 +1355,7 @@
     module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
         PredInfo0, ProcInfo0),
     proc_info_get_vartypes(ProcInfo0, VarTypes0),
-    module_info_preds(ModuleInfo0, Preds0),
+    module_info_get_preds(ModuleInfo0, Preds0),
     pred_info_get_procedures(PredInfo0, Procs0),
 
     proc_info_get_headvars(ProcInfo0, HeadVars0),
Index: compiler/unused_imports.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_imports.m,v
retrieving revision 1.23
diff -u -b -r1.23 unused_imports.m
--- compiler/unused_imports.m	14 Oct 2009 05:28:45 -0000	1.23
+++ compiler/unused_imports.m	20 Jul 2010 02:23:32 -0000
@@ -182,7 +182,7 @@
     module_info_get_instance_table(ModuleInfo, InstanceTable),
     map.foldl(instance_used_modules, InstanceTable, !UsedModules),
 
-    module_info_preds(ModuleInfo, PredTable),
+    module_info_get_preds(ModuleInfo, PredTable),
     map.foldl(pred_info_used_modules, PredTable, !UsedModules).
 
 %-----------------------------------------------------------------------------%
Index: compiler/xml_documentation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/xml_documentation.m,v
retrieving revision 1.25
diff -u -b -r1.25 xml_documentation.m
--- compiler/xml_documentation.m	14 Oct 2009 05:28:45 -0000	1.25
+++ compiler/xml_documentation.m	20 Jul 2010 02:23:37 -0000
@@ -310,7 +310,7 @@
             [], TypeXmls),
         TypeXml = elem("types", [], TypeXmls),
 
-        module_info_preds(ModuleInfo, PredTable),
+        module_info_get_preds(ModuleInfo, PredTable),
         map.foldl(pred_documentation(Comments), PredTable, [], PredXmls),
         PredXml = elem("preds", [], PredXmls),
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/assoc_list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/assoc_list.m,v
retrieving revision 1.26
diff -u -b -r1.26 assoc_list.m
--- library/assoc_list.m	25 Mar 2010 01:28:53 -0000	1.26
+++ library/assoc_list.m	29 Jul 2010 04:25:29 -0000
@@ -99,6 +99,42 @@
 :- func assoc_list.map_values(func(K, V) = W, assoc_list(K, V))
     = assoc_list(K, W).
 
+    % assoc_list.filter(Pred, List, TrueList) takes a closure with one
+    % input argument and for each member K - V of List X, calls the closure
+    % on the key. K - V is included in TrueList iff Pred(K) is true.
+    %
+:- pred assoc_list.filter(pred(K)::in(pred(in) is semidet),
+    assoc_list(K, V)::in, assoc_list(K, V)::out) is det.
+:- func assoc_list.filter(pred(K)::in(pred(in) is semidet),
+    assoc_list(K, V)::in) = (assoc_list(K, V)::out) is det.
+
+    % assoc_list.negated_filter(Pred, List, FalseList) takes a closure with one
+    % input argument and for each member K - V of List X, calls the closure
+    % on the key. K - V is included in FalseList iff Pred(K) is false.
+    %
+:- pred assoc_list.negated_filter(pred(K)::in(pred(in) is semidet),
+    assoc_list(K, V)::in, assoc_list(K, V)::out) is det.
+:- func assoc_list.negated_filter(pred(K)::in(pred(in) is semidet),
+    assoc_list(K, V)::in) = (assoc_list(K, V)::out) is det.
+
+    % assoc_list.filter(Pred, List, FalseList) takes a closure with one
+    % input argument and for each member K - V of List X, calls the closure
+    % on the key. K - V is included in TrueList iff Pred(K) is true.
+    % K - V is included in FalseList iff Pred(K) is false.
+    %
+:- pred assoc_list.filter(pred(K)::in(pred(in) is semidet),
+    assoc_list(K, V)::in, assoc_list(K, V)::out, assoc_list(K, V)::out) is det.
+
+    % assoc_list.merge(L1, L2, L):
+    %
+    % L is the result of merging the elements of L1 and L2, in ascending order.
+    % L1 and L2 must be sorted on the keys.
+    %
+:- pred assoc_list.merge(assoc_list(K, V)::in, assoc_list(K, V)::in,
+    assoc_list(K, V)::out) is det.
+:- func assoc_list.merge(assoc_list(K, V), assoc_list(K, V))
+    = assoc_list(K, V).
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -159,6 +195,15 @@
         assoc_list.search(KVs, Key, Value)
     ).
 
+AL ^ elem(K) = V :-
+    assoc_list.search(AL, K, V).
+
+AL ^ det_elem(K) = V :-
+    ( if   assoc_list.search(AL, K, V0)
+      then V = V0
+      else report_lookup_error("assoc_list.det_elem: key not found", K)
+    ).
+
 assoc_list.remove([K - V | KVs], Key, Value, Rest) :-
     ( K = Key ->
         Value = V,
@@ -215,11 +260,56 @@
     V = F(K, V0),
     KVs = assoc_list.map_values(F, KVs0).
 
-AL ^ elem(K) = V :-
-    assoc_list.search(AL, K, V).
+assoc_list.filter(_, [],  []).
+assoc_list.filter(P, [HK - HV | T], True) :-
+    ( P(HK) ->
+        assoc_list.filter(P, T, TrueTail),
+        True = [HK - HV | TrueTail]
+    ;
+        assoc_list.filter(P, T, True)
+    ).
 
-AL ^ det_elem(K) = V :-
-    ( if   assoc_list.search(AL, K, V0)
-      then V = V0
-      else report_lookup_error("assoc_list.det_elem: key not found", K)
+assoc_list.filter(P, List) = Trues :-
+    assoc_list.filter(P, List, Trues).
+
+assoc_list.negated_filter(_, [],  []).
+assoc_list.negated_filter(P, [HK - HV | T], False) :-
+    ( P(HK) ->
+        assoc_list.negated_filter(P, T, False)
+    ;
+        assoc_list.negated_filter(P, T, FalseTail),
+        False = [HK - HV | FalseTail]
+    ).
+
+assoc_list.negated_filter(P, List) = Falses :-
+    assoc_list.negated_filter(P, List, Falses).
+
+assoc_list.filter(_, [],  [], []).
+assoc_list.filter(P, [HK - HV | T], True, False) :-
+    ( P(HK) ->
+        assoc_list.filter(P, T, TrueTail, False),
+        True = [HK - HV | TrueTail]
+    ;
+        assoc_list.filter(P, T, True, FalseTail),
+        False = [HK - HV | FalseTail]
+    ).
+
+assoc_list.merge(As, Bs) = ABs :-
+    assoc_list.merge(As, Bs, ABs).
+
+assoc_list.merge([], [], []).
+assoc_list.merge([A | As], [], [A | As]).
+assoc_list.merge([], [B | Bs], [B | Bs]).
+assoc_list.merge([A | As], [B | Bs], Cs) :-
+    (
+        A = AK - _AV,
+        B = BK - _BV,
+        compare(>, AK, BK)
+    ->
+        assoc_list.merge([A | As], Bs, Cs0),
+        Cs = [B | Cs0]
+    ;
+        % If compare((=), AK, BK), take A first.
+        assoc_list.merge(As, [B | Bs], Cs0),
+        Cs = [A | Cs0]
     ).
Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.189
diff -u -b -r1.189 list.m
--- library/list.m	28 Apr 2010 00:48:45 -0000	1.189
+++ library/list.m	20 Jul 2010 02:37:58 -0000
@@ -1276,8 +1276,8 @@
     X::out) is semidet.
 
     % list.filter(Pred, List, TrueList) takes a closure with one
-    % input argument and for each member of List `X', calls the closure.
-    % Iff Pred(X) is true, then X is included in TrueList.
+    % input argument and for each member X of List, calls the closure.
+    % X is included in TrueList iff Pred(X) is true.
     %
 :- pred list.filter(pred(X)::in(pred(in) is semidet), list(X)::in,
     list(X)::out) is det.
@@ -1286,7 +1286,7 @@
 
     % list.negated_filter(Pred, List, FalseList) takes a closure with one
     % input argument and for each member of List `X', calls the closure.
-    % Iff Pred(X) is false, then X is included in FalseList.
+    % X is included in FalseList iff Pred(X) is true.
     %
 :- pred list.negated_filter(pred(X)::in(pred(in) is semidet), list(X)::in,
     list(X)::out) is det.
@@ -1294,9 +1294,9 @@
     = (list(X)::out) is det.
 
     % list.filter(Pred, List, TrueList, FalseList) takes a closure with one
-    % input argument and for each member of List `X', calls the closure.
-    % Iff Pred(X) is true, then X is included in TrueList.
-    % Iff Pred(X) is false, then X is included in FalseList.
+    % input argument and for each member X of List, calls the closure.
+    % X is included in TrueList iff Pred(X) is true.
+    % X is included in FalseList iff Pred(X) is true.
     %
 :- pred list.filter(pred(X)::in(pred(in) is semidet), list(X)::in,
     list(X)::out, list(X)::out) is det.
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/java_interface
cvs diff: Diffing samples/java_interface/java_calls_mercury
cvs diff: Diffing samples/java_interface/mercury_calls_java
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/speedtest
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/speedtest,v
retrieving revision 1.20
diff -u -b -r1.20 speedtest
--- tools/speedtest	4 Sep 2009 02:50:15 -0000	1.20
+++ tools/speedtest	29 Jul 2010 10:54:02 -0000
@@ -2,15 +2,20 @@
 #
 # A program to test different versions of the compiler.
 
-usage="Usage: speedtest [-c cmd] [-dns] batchname"
-limit=6
-cmd_llds="mmc -C -O2 --grade asm_fast.gc llds_out.m typecheck.m mercury_compile.m modules.m code_info.m polymorphism.m"
-cmd_mlds="mmc -C -O2 --grade hlc.gc llds_out.m typecheck.m mercury_compile.m modules.m code_info.m polymorphism.m"
-cmd="$cmd_llds"
+usage="Usage: speedtest [-dhlstz] [-c cmd] [-nN] [-ON] [-fFILE] batchname"
+
+short_modulelist="llds_out.m typecheck.m mercury_compile.m modules.m code_info.m polymorphism.m"
+long_modulelist="$short_modulelist options.m add_pragma.m simplify.m table_gen.m mlds_to_java.m mlds_to_il.m"
+
+cmd=""
 debug=false
-table_io=false
-size=false
+grade="--grade asm_fast.gc"
 framesizefile=""
+modulelist="$short_modulelist"
+limit=6
+opt="-O2"
+size=false
+table_io=false
 zip=false
 
 while test $# -gt 0
@@ -26,24 +31,32 @@
 		debug=true ;;
 
 	-h)
-		cmd="$cmd_mlds" ;;
-
-	-t)
-		table_io=true ;;
+		grade="--grade hlc.gc" ;;
 
 	-f)
 		framesizefile="$2" ; shift ;;
 	-f*)
 		framesizefile="` expr $1 : '-f\(.*\)' `" ;;
 
+	-l)
+		modulelist="$long_modulelist" ;;
+
 	-n)
 		limit="$2" ; shift ;;
 	-n*)
 		limit="` expr $1 : '-n\(.*\)' `" ;;
 
+	-O)
+		opt="-O$2" ; shift ;;
+	-O*)
+		opt="$1" ;;
+
 	-s)
 		size=true ;;
 
+	-t)
+		table_io=true ;;
+
 	-z)
 		zip=true ;;
 
@@ -57,6 +70,11 @@
 	shift
 done
 
+if test "$cmd" = ""
+then
+	cmd="mmc -C $opt $grade $modulelist"
+fi
+
 if test $# != 1
 then
 	echo $usage
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list