[m-rev.] trivial diff: ctgc cleanups

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Jun 5 14:44:16 AEST 2006


Estimated hours taken: 1
Branches: main

Minor style cleanups for the CTGC system.  There are no changes to any
algorithms.

compiler/ctgc.*.m:
compiler/prog_ctgc.m:
compiler/structure_reuse.*.m:
compiler/structure_sharing.*.m:
	Minor style cleanups.

compiler/builtin_ops.m:
compiler/check_hlds.m:
compiler/exception_analysis.m:
compiler/hlds_rtti.m:
compiler/process_util.m:
	s/__/./ in a couple of spots and fix a few other formatting problems.

Julien.

Index: compiler/builtin_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/builtin_ops.m,v
retrieving revision 1.22
diff -u -r1.22 builtin_ops.m
--- compiler/builtin_ops.m	17 Mar 2006 01:40:11 -0000	1.22
+++ compiler/builtin_ops.m	5 Jun 2006 04:08:28 -0000
@@ -5,7 +5,7 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: builtin_ops.m -- defines the builtin operator types.
 % Main author: fjh.
 %
@@ -13,10 +13,11 @@
 % operators.  Several of the different back-ends -- the bytecode back-end,
 % the LLDS, and the MLDS -- all use the same set of builtin operators.
 % These operators are defined here.
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

-:- module backend_libs__builtin_ops.
+:- module backend_libs.builtin_ops.
 :- interface.

 :- import_module hlds.hlds_pred.
Index: compiler/check_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_hlds.m,v
retrieving revision 1.13
diff -u -r1.13 check_hlds.m
--- compiler/check_hlds.m	24 Mar 2006 03:03:39 -0000	1.13
+++ compiler/check_hlds.m	5 Jun 2006 02:58:19 -0000
@@ -15,8 +15,8 @@
 :- import_module mdbcomp.
 :- import_module parse_tree.

-% :- import_module check_hlds__type_analysis.
-% :- import_module check_hlds__mode_analysis.
+% :- import_module check_hlds.type_analysis.
+% :- import_module check_hlds.mode_analysis.

 %-----------------------------------------------------------------------------%

Index: compiler/ctgc.datastruct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ctgc.datastruct.m,v
retrieving revision 1.7
diff -u -r1.7 ctgc.datastruct.m
--- compiler/ctgc.datastruct.m	29 May 2006 13:04:32 -0000	1.7
+++ compiler/ctgc.datastruct.m	5 Jun 2006 02:59:05 -0000
@@ -5,13 +5,14 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: ctgc.datastruct.m.
 % Main author: nancy.
-
+%
 % Definition of predicates and functions for the manipulation of
 % datastructures.
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.datastruct.
@@ -177,9 +178,8 @@
     Data = list.append(NotSubsumedData, Data1).

 datastructs_project(Vars, DataIn) =
-    list__filter(
-        pred(Data::in) is semidet :-
-          (list__member(Data^sc_var, Vars)),
+    list.filter(
+        (pred(Data::in) is semidet :- list.member(Data ^ sc_var, Vars)),
         DataIn).

 %-----------------------------------------------------------------------------%
Index: compiler/ctgc.livedata.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ctgc.livedata.m,v
retrieving revision 1.1
diff -u -r1.1 ctgc.livedata.m
--- compiler/ctgc.livedata.m	29 May 2006 13:04:32 -0000	1.1
+++ compiler/ctgc.livedata.m	5 Jun 2006 04:35:25 -0000
@@ -5,6 +5,7 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
+%
 % File: ctgc.livedata.m.
 % Main author: nancy.
 %
@@ -15,6 +16,7 @@
 % of the program w.r.t. the program point (goal) looked at.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.livedata.
 :- interface.
@@ -75,6 +77,8 @@

 :- pred nodes_are_not_live(module_info::in, proc_info::in,
     list(datastruct)::in, livedata::in) is semidet.
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- implementation.
@@ -84,13 +88,14 @@

 :- import_module set.

+%-----------------------------------------------------------------------------%

 :- type livedata
     --->    livedata_bottom      % There are no live data structures.
     ;       livedata_top         % All data structures may be live.
     ;       livedata_live(list(datastruct)).
-                        % Only the listed datastructures can possibly
-                        % be live.
+                                 % Only the listed datastructures can
+                                 % possibly be live.

 %-----------------------------------------------------------------------------%

@@ -141,6 +146,7 @@
     livedata_subsumes_topcell(LiveData, datastruct_init(ProgVar)).

 :- pred livedata_subsumes_topcell(livedata::in, datastruct::in) is semidet.
+
 livedata_subsumes_topcell(LiveData, TopCell) :-
     (
         LiveData = livedata_top
@@ -161,6 +167,7 @@

 :- pred livedata_subsumes_datastruct_with_selector(module_info::in,
     proc_info::in, livedata::in, datastruct::in) is semidet.
+
 livedata_subsumes_datastruct_with_selector(ModuleInfo, ProcInfo, LiveData,
         Datastruct) :-
     (
@@ -185,7 +192,7 @@
             FilteredData = [],
             ProjectedLiveData = livedata_bottom
         ;
-            FilteredData = [_|_],
+            FilteredData = [_ | _],
             ProjectedLiveData = livedata_live(FilteredData)
         )
     ).
@@ -199,6 +206,7 @@

 livedata_init_at_goal(ModuleInfo, ProcInfo, GoalInfo, SharingAs) = LiveData :-
     % Collect the
+    % (XXX collect the what?)
     Lfu = goal_info_get_lfu(GoalInfo),
     Lbu = goal_info_get_lbu(GoalInfo),
     Lu = set.to_sorted_list(set.union(Lfu, Lbu)),
@@ -294,6 +302,9 @@
 %-----------------------------------------------------------------------------%

 :- func this_file = string.
+
 this_file = "ctgc.livedata.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.livedata.
+%-----------------------------------------------------------------------------%
Index: compiler/ctgc.selector.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ctgc.selector.m,v
retrieving revision 1.4
diff -u -r1.4 ctgc.selector.m
--- compiler/ctgc.selector.m	29 Mar 2006 08:06:40 -0000	1.4
+++ compiler/ctgc.selector.m	5 Jun 2006 04:36:45 -0000
@@ -5,12 +5,13 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: ctgc.selector.m.
 % Main author: nancy.
-
+%
 % Definition of predicates and functions for the manipulation of selectors.
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.selector.
@@ -86,9 +87,10 @@

 selector_init(Cons, Index) = [termsel(Cons, Index)].
 selector_init_from_list(Types)
-    = list.map(func(T) = US :- US = typesel(T), Types).
+    = list.map((func(T) = typesel(T)), Types).

-selector_termshift(S1, S2, S) :- list.append(S1, S2, S).
+selector_termshift(S1, S2, S) :-
+    list.append(S1, S2, S).

 subsumed_by(ModuleInfo, S1, S2, MainType, Extension):-
     % First make sure that both selectors are in a normalized form.
@@ -288,7 +290,7 @@
 do_normalize_selector(ModuleInfo, VarType, BranchMap0,
         SelectorAcc0, !Selector) :-
     (
-        !.Selector = [ UnitSelector | SelRest ],
+        !.Selector = [UnitSelector | SelRest],
         Class = classify_type(ModuleInfo, VarType),
         ( Class = type_cat_user_ctor ->
             % If it is either a term-selector of a non existentially typed
Index: compiler/exception_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/exception_analysis.m,v
retrieving revision 1.26
diff -u -r1.26 exception_analysis.m
--- compiler/exception_analysis.m	30 May 2006 03:19:38 -0000	1.26
+++ compiler/exception_analysis.m	5 Jun 2006 04:38:10 -0000
@@ -446,7 +446,7 @@
                     % The possible values of the higher-order variable are all
                     % procedures that are known not to throw exceptions.
                 ;
-                    ConditionalProcs = [_|_],
+                    ConditionalProcs = [_ | _],
                     %
                     % For 'conditional' procedures we need to make sure that
                     % if any type variables are bound at the generic_call
Index: compiler/hlds_rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_rtti.m,v
retrieving revision 1.3
diff -u -r1.3 hlds_rtti.m
--- compiler/hlds_rtti.m	29 Mar 2006 08:06:49 -0000	1.3
+++ compiler/hlds_rtti.m	12 May 2006 09:09:42 -0000
@@ -614,7 +614,7 @@
     TypeMap0 = !.RttiVarMaps ^ ti_type_map,
     ConstraintMap0 = !.RttiVarMaps ^ tci_constraint_map,
     map.foldl(apply_constraint_key_transformation(Pred), TciMap0,
-    map.init, TciMap),
+        map.init, TciMap),
     Pred2 = (pred(_::in, V::in, W::out) is det :-
             Pred(V, W)
     ),
@@ -690,12 +690,12 @@
             % treat them specially.

             % The type_info is either stored in a variable, or in a
-            % typeclass_info. Either get the type_info variable or
+            % typeclass_info.  Either get the type_info variable or
             % the typeclass_info variable.
             LookupVar = (pred(TVar::in, TVarVar::out) is det :-
-                    map.lookup(TVarMap, TVar, Locn),
-                    type_info_locn_var(Locn, TVarVar)
-                ),
+                map.lookup(TVarMap, TVar, Locn),
+                type_info_locn_var(Locn, TVarVar)
+            ),
             list.map(LookupVar, TypeVars, TypeInfoVarsHead),

             get_typeinfo_vars_2(Vars, VarTypes, TVarMap, TypeInfoVarsTail),
Index: compiler/process_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/process_util.m,v
retrieving revision 1.20
diff -u -r1.20 process_util.m
--- compiler/process_util.m	29 Mar 2006 08:07:15 -0000	1.20
+++ compiler/process_util.m	5 Jun 2006 02:57:53 -0000
@@ -5,15 +5,16 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: process_util.m.
 % Main author: stayl.
-
+%
 % Process and signal handling, mainly for use by make.m and its sub-modules.
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

-:- module libs__process_util.
+:- module libs.process_util.

 :- interface.

@@ -96,12 +97,12 @@
     check_for_signal(Signalled, Signal, !IO),
     ( Signalled = 1 ->
         Succeeded = no,
-        globals__io_lookup_bool_option(verbose_make, Verbose, !IO),
+        globals.io_lookup_bool_option(verbose_make, Verbose, !IO),
         (
             Verbose = yes,
-            io__write_string("** Received signal ", !IO),
-            io__write_int(Signal, !IO),
-            io__write_string(", cleaning up.\n", !IO)
+            io.write_string("** Received signal ", !IO),
+            io.write_int(Signal, !IO),
+            io.write_string(", cleaning up.\n", !IO)
         ;
             Verbose = no
         ),
@@ -277,7 +278,7 @@
         ( ForkStatus = 1 ->
             Success = no
         ;
-            Status = io__handle_system_command_exit_status(CallStatus),
+            Status = io.handle_system_command_exit_status(CallStatus),
             Success = (Status = ok(exited(0)) -> yes ; no)
         )
     ;
Index: compiler/prog_ctgc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_ctgc.m,v
retrieving revision 1.8
diff -u -r1.8 prog_ctgc.m
--- compiler/prog_ctgc.m	2 May 2006 08:15:34 -0000	1.8
+++ compiler/prog_ctgc.m	5 Jun 2006 04:37:01 -0000
@@ -590,4 +590,3 @@

 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
-
Index: compiler/structure_reuse.analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.analysis.m,v
retrieving revision 1.2
diff -u -r1.2 structure_reuse.analysis.m
--- compiler/structure_reuse.analysis.m	29 May 2006 13:04:34 -0000	1.2
+++ compiler/structure_reuse.analysis.m	5 Jun 2006 02:57:02 -0000
@@ -6,8 +6,8 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.analysis.m
-% Main authors: nancy
+% File: structure_reuse.analysis.m.
+% Main authors: nancy.
 %
 % Implementation of the structure reuse analysis (compile-time garbage
 % collection system): each procedure is analysed to see whether some
@@ -21,7 +21,7 @@
 %
 % The following example shows instances of direct and indirect reuse:
 %
-% list__append(H1, H2, H3) :-
+% list.append(H1, H2, H3) :-
 %   (
 %       H1 => [],
 %       H3 := H2
@@ -34,21 +34,21 @@
 %       H1 => [X | Xs],
 %
 %           % If the condition about the structure sharing of H1
-%           % is true then we can call the version of list__append
+%           % is true then we can call the version of list.append
 %           % which does reuse. Calling the optimised version here leads
 %           % to a new condition to be met by the headvars of any
 %           % call to the resulting optimised version of append.
 %           % This is an indirect reuse.
-%       list__append(Xs, H2, Zs),
+%       list.append(Xs, H2, Zs),
 %
 %           % Reuse the dead cell H1.  This is a direct reuse.
 %       H3 <= [X | Zs]
 %   ).
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.analysis.
-
 :- interface.

 :- import_module hlds.hlds_module.
@@ -58,6 +58,9 @@
 :- pred structure_reuse_analysis(module_info::in, module_info::out,
     io::di, io::uo) is det.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module check_hlds.goal_path.
@@ -75,6 +78,7 @@

 :- import_module string.

+%-----------------------------------------------------------------------------%

 structure_reuse_analysis(!ModuleInfo, !IO):-
     globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
@@ -131,12 +135,14 @@
 annotate_in_use_information(_PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :-
     forward_use_information(!ProcInfo),
     backward_use_information(ModuleInfo, !ProcInfo),
-    goal_path.fill_goal_path_slots(ModuleInfo, !ProcInfo).
-
+    fill_goal_path_slots(ModuleInfo, !ProcInfo).

 %-----------------------------------------------------------------------------%

 :- func this_file = string.
+
 this_file = "structure_reuse.analysis.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.analysis.
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.direct.choose_reuse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.direct.choose_reuse.m,v
retrieving revision 1.1
diff -u -r1.1 structure_reuse.direct.choose_reuse.m
--- compiler/structure_reuse.direct.choose_reuse.m	10 May 2006 10:56:56 -0000	1.1
+++ compiler/structure_reuse.direct.choose_reuse.m	5 Jun 2006 04:28:28 -0000
@@ -6,8 +6,8 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.direct.choose_reuse.m
-% Main authors: nancy
+% File: structure_reuse.direct.choose_reuse.m.
+% Main authors: nancy.
 %
 % Given a dead cell table listing the deconstructions that may leave garbage
 % (dead cells), we compute the concrete assignments of which constructions can
@@ -61,7 +61,8 @@
 % To cut the decision between different dead cells with the same
 % value, we select the dead cell that has the least number of
 % opportunities to be reused.
-% E.g.
+%
+% e.g.
 %   X can be reused by 5 different constructions,
 %       but reaches its highest value for a construction C1
 %       (value 10).
@@ -80,6 +81,7 @@
 %
 % Note that cells being deconstructed in the different branches of a
 % disjunction can now also be reused after the the disjunction.
+%
 % e.g.:
 %   (
 %       ..., X => f(... ), ...      % X dies
@@ -87,18 +89,23 @@
 %       ..., X => g(... ), ...      % X dies
 %   ),
 %   Y <= f(... ), ...           % Y can reuse X
+%
 % In this example, it is allowed to reuse X for Y. And it will also be
 % discovered by the analysis.
 %
 %-----------------------------------------------------------------------------%
-:- module transform_hlds.ctgc.structure_reuse.direct.choose_reuse.
+%-----------------------------------------------------------------------------%

+:- module transform_hlds.ctgc.structure_reuse.direct.choose_reuse.
 :- interface.

 :- pred determine_reuse(reuse_strategy::in, module_info::in, proc_info::in,
     dead_cell_table::in, hlds_goal::in, hlds_goal::out, reuse_as::out,
     io::di, io::uo) is det.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module check_hlds.type_util.
@@ -111,12 +118,14 @@
 :- import_module pair.
 :- import_module svmulti_map.

-determine_reuse(Strategy, ModuleInfo, ProcInfo, DeadCellTable,
-    !Goal, ReuseAs, !IO):-
+%-----------------------------------------------------------------------------%
+
+determine_reuse(Strategy, ModuleInfo, ProcInfo, DeadCellTable, !Goal,
+        ReuseAs, !IO):-
     % Check for local reuse:
-    process_goal(
-        background_info_init(Strategy, ModuleInfo, ProcInfo), DeadCellTable,
-        RemainingDeadCellTable, !Goal, reuse_as_init, ReuseAs, !IO),
+    BackGroundInfo = background_info_init(Strategy, ModuleInfo, ProcInfo),
+    process_goal(BackGroundInfo, DeadCellTable, RemainingDeadCellTable,
+        !Goal, reuse_as_init, ReuseAs, !IO),

     % Check for cell caching.
     check_for_cell_caching(RemainingDeadCellTable, !Goal, !IO).
@@ -150,21 +159,21 @@
     %
 :- type deconstruction_spec
     --->    decon(
-            decon_var   :: dead_var,
-            decon_pp    :: program_point,
-            decon_cons_id   :: cons_id,
-            decon_args  :: prog_vars,
-            decon_conds :: reuse_as
-        ).
+                decon_var       :: dead_var,
+                decon_pp        :: program_point,
+                decon_cons_id   :: cons_id,
+                decon_args      :: prog_vars,
+                decon_conds     :: reuse_as
+            ).

     % Details of a construction possibly reusing some specific garbage cells
     % generated at a deconstruction.
     %
 :- type construction_spec
     --->    con(
-            con_pp      :: program_point,
-            con_reuse   :: reuse_type
-        ).
+                con_pp      :: program_point,
+                con_reuse   :: reuse_type
+            ).

     % The reuse-type is a basic identification of whether the cons-ids involved
     % in the reuse are the same, what the arities of the old and new cells are,
@@ -172,18 +181,18 @@
     %
 :- type reuse_type
     --->    reuse_type(
-            same_cons       :: bool,
-            reuse_fields    :: list(needs_update),
-                % States whether the corresponding argument in the list of
-                % arguments of the reused cons needs to be updated when reused
-                % or not.
-                % Note that list.length(reuse_fields) is the arity of the
-                % reused term.
-            reuse_value     :: float
-                % A metrics measuring the value of the reuse. A high value
-                % should represent a 'good' reuse (yielding possibly good
-                % results on the general memory behaviour of the procedure)
-                % compared to a reuse with a lower value.
+                same_cons       :: bool,
+                reuse_fields    :: list(needs_update),
+                    % States whether the corresponding argument in the list of
+                    % arguments of the reused cons needs to be updated when
+                    % reused or not.
+                    % Note that list.length(reuse_fields) is the arity of the
+                    % reused term.
+                reuse_value     :: float
+                    % A metric measuring the value of the reuse. A high value
+                    % should represent a 'good' reuse (yielding possibly good
+                    % results on the general memory behaviour of the procedure)
+                    % compared to a reuse with a lower value.
         ).

         % A match is a description of a list of deconstructions and a list of
@@ -212,8 +221,8 @@
 :- func deconstruction_spec_init(dead_var, program_point, cons_id,
     prog_vars, reuse_as) = deconstruction_spec.

-deconstruction_spec_init(Var, PP, ConsId, Args, Cond) =  DS :-
-    DS = decon(Var, PP, ConsId, Args, Cond).
+deconstruction_spec_init(Var, PP, ConsId, Args, Cond)
+    = decon(Var, PP, ConsId, Args, Cond).

     % Pre-condition: the set of variables to which the list of deconstructions
     % relate (the dead vars) should be a singleton set. In other words,
@@ -221,33 +230,34 @@
     % dying variable.
     %
 :- func match_init(list(deconstruction_spec)) = match.
-match_init(DS) =  match(DS, [], 0.00, 0).
+
+match_init(DS) = match(DS, [], 0.0, 0).

     % Verify that a match is still 'empty', i.e. has no constructions that can
     % reuse the dead cell available from the deconstructions listed in the
     % match.
     %
 :- pred match_has_no_construction_candidates(match::in) is semidet.
+
 match_has_no_construction_candidates(match(_, [], _, _)).

     % Determine the variable whose term is involved in the reuse if the
     % match would be implemented.
     %
 :- func match_get_dead_var(match) = dead_var.
+
 match_get_dead_var(Match) = Var :-
-    GetVar = (pred(D::in, V::out) is det :-
-            V = D ^ decon_var),
-    list.map(GetVar, Match ^ decon_specs, DeadVars0),
-    list.remove_dups(DeadVars0, DeadVars),
+    GetVar = (func(D) = D ^ decon_var),
+    DeadVars0 = list.map(GetVar, Match ^ decon_specs),
+    DeadVars  = list.remove_dups(DeadVars0),
     (
-        DeadVars = [Var|Rest],
+        DeadVars = [Var | Rest],
         (
-            Rest = [_|_]
-        ->
+            Rest = []
+        ;
+            Rest = [_ | _],
             unexpected(choose_reuse.this_file, "match_get_dead_var: " ++
                 "too many dead vars.")
-        ;
-            true
         )
     ;
         DeadVars = [],
@@ -299,16 +309,17 @@
     Match = match(DeconSpecs0, ConSpecs, Value, Degree).

 %-----------------------------------------------------------------------------%
+%
 % Manipulating the values of matches...
 %

 :- func highest_match_degree_ratio(match_table) = match.
+
 highest_match_degree_ratio(MatchTable) = Match :-
     multi_map.values(MatchTable, Matches),
-    list.sort(reverse_compare_matches_value_degree,
-            Matches, Sorted),
+    list.sort(reverse_compare_matches_value_degree, Matches, Sorted),
     (
-        Sorted = [Match|_]
+        Sorted = [Match | _]
     ;
         Sorted = [],
         unexpected(choose_reuse.this_file, "highest_match_degree_ratio: " ++
@@ -317,48 +328,55 @@

 :- pred compare_matches_value_degree(match::in, match::in,
         comparison_result::out) is det.
-compare_matches_value_degree(Match1, Match2, Result) :-
-    match_value_degree(Match1, V1),
-    match_value_degree(Match2, V2),
-    compare(Result, V1, V2).
+
+compare_matches_value_degree(MatchA, MatchB, Result) :-
+    VA = match_value_degree(MatchA),
+    VB = match_value_degree(MatchB),
+    compare(Result, VA, VB).
+
 :- pred reverse_compare_matches_value_degree(match::in, match::in,
-        comparison_result::out) is det.
-reverse_compare_matches_value_degree(Match1, Match2, Result) :-
-    compare_matches_value_degree(Match2, Match1, Result).
+        comparison_result::out) is det.

-:- pred match_value_degree(match::in, float::out) is det.
-match_value_degree(Match, V) :-
-    (
-        Match ^ match_value \= 0.00
-    ->
-        V = Match ^ match_value / float(Match ^ match_degree)
+reverse_compare_matches_value_degree(MatchA, MatchB, Result) :-
+    compare_matches_value_degree(MatchB, MatchA, Result).
+
+:- func match_value_degree(match) = float.
+
+match_value_degree(Match) =
+    ( Match ^ match_value \= 0.0 ->
+        Match ^ match_value / float(Match ^ match_degree)
     ;
-        V = 0.00
+        0.0
     ).

 :- pred compare_matches_value(match::in, match::in,
         comparison_result::out) is det.
+
 compare_matches_value(Match1, Match2, Result) :-
     V1 = Match1 ^ match_value,
     V2 = Match2 ^ match_value,
     compare(Result, V1, V2).
+
 :- pred reverse_compare_matches_value(match::in, match::in,
         comparison_result::out) is det.
+
 reverse_compare_matches_value(Match1, Match2, Result) :-
     compare_matches_value(Match2, Match1, Result).

 :- pred match_allows_reuse(match::in) is semidet.
+
 match_allows_reuse(Match) :-
     Constructions = Match ^ con_specs,
     Value = Match ^ match_value,
     Constructions = [_|_],
-    Value > 0.00.
-
+    Value > 0.0.
+
 :- pred highest_match_in_list(list(match)::in, match::in, match::out) is det.
+
 highest_match_in_list(Matches, Match0, Match) :-
-    list__sort(reverse_compare_matches_value, [Match0 | Matches], Sorted),
+    list.sort(reverse_compare_matches_value, [Match0 | Matches], Sorted),
     (
-        Sorted = [Match|_]
+        Sorted = [Match | _]
     ;
         Sorted = [],
         unexpected(choose_reuse.this_file, "highest_match_in_list: " ++
@@ -369,33 +387,37 @@
     % compute the average reuse value of that deconstruction. This means
     % merging all the constructions together into one list, and using the
     % average value of the reuses of each of the matches. The final degree
-    % of the match is set to the sum of all degrees.
+    % of the match is set to the sum of all degrees.
+    %
 :- pred average_match(list(match)::in, match::out) is det.
+
 average_match(List, AverageMatch):-
     (
-        List = [First|Rest],
-        list__length(List, Length),
-        P = (pred(M::in, Acc0::in, Acc::out) is det :-
-            DeconSpecs = Acc0 ^ decon_specs,
-            ConSpecs = append(Acc0 ^ con_specs, M ^ con_specs),
-            Val = Acc0 ^ match_value + M ^ match_value,
-            Deg = Acc0 ^ match_degree + M ^ match_degree,
-            Acc = match(DeconSpecs, ConSpecs, Val, Deg)),
-        list__foldl(P, Rest, First, Match0),
+        List = [First | Rest],
+        list.length(List, Length),
+        P = (pred(M::in, !.Acc::in, !:Acc::out) is det :-
+            DeconSpecs = !.Acc ^ decon_specs,
+            ConSpecs = append(!.Acc ^ con_specs, M ^ con_specs),
+            Val = !.Acc ^ match_value + M ^ match_value,
+            Deg = !.Acc ^ match_degree + M ^ match_degree,
+            !:Acc = match(DeconSpecs, ConSpecs, Val, Deg)
+        ),
+        list.foldl(P, Rest, First, Match0),
         AverageMatch = (Match0 ^ match_value :=
-                (Match0 ^ match_value / float(Length)))
+            (Match0 ^ match_value / float(Length)))
     ;
         List = [],
-        unexpected(choose_reuse.this_file, "average_match: empty list.\n")
+        unexpected(choose_reuse.this_file, "average_match: empty list.")
     ).

 %-----------------------------------------------------------------------------%
-% Process one single goal:
+%
+% Process a single goal
+%
 %   * determine a match table
 %   * find the best match
 %   * annotate the goal with the reuse described by that match
 %   * and reprocess the goal until no matches are found.
-%

 :- pred process_goal(background_info::in, dead_cell_table::in,
     dead_cell_table::out, hlds_goal::in, hlds_goal::out, reuse_as::in,
@@ -403,50 +425,52 @@

 process_goal(Background, !DeadCellTable, !Goal, !ReuseAs, !IO):-
     globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+    %
+    % Compute a match table.
+    %
+    compute_match_table(Background, !.DeadCellTable, !.Goal, MatchTable, !IO),

-        % Compute a match table.
-    compute_match_table(Background, !.DeadCellTable, !.Goal,
-        MatchTable, !IO),
-
-        % As long as the match table is not empty, pick out the match
-        % with the highest value, annotate the goal accordingly, and
-        % repeat the procedure.
-        % If the match table is empty, the work is finished.
-    (
-        multi_map__is_empty(MatchTable)
-    ->
+    % As long as the match table is not empty, pick out the match with the
+    % highest value, annotate the goal accordingly, and repeat the procedure.
+    % If the match table is empty, the work is finished.
+    %
+    ( multi_map.is_empty(MatchTable) ->
         true
     ;
-        % 1. select the deconstructions-constructions with
-        % highest value.
+        % Select the deconstructions-constructions with highest value.
+        %
         Match = highest_match_degree_ratio(MatchTable),

-        % 2. dump all the matches recorded in the table, highlight the
+        % Maybe dump all the matches recorded in the table, highlight the
         % match with the highest value.
-        maybe_write_string(VeryVerbose, "% Reuse results: \n",
-            !IO),
-        maybe_dump_match_table(VeryVerbose, MatchTable,
-            Match, !IO),
+        %
+        maybe_write_string(VeryVerbose, "% Reuse results: \n", !IO),
+        maybe_dump_match_table(VeryVerbose, MatchTable, Match, !IO),

-        % 3. realise the reuses by explicitly annotating the
-        % procedure goal.
+        % Realise the reuses by explicitly annotating the procedure goal.
+        %
         annotate_reuses_in_goal(Background, Match, !Goal),
-        % remove the deconstructions from the available map of
-        % dead cells:
+        %
+        % Remove the deconstructions from the available map of dead cells.
+        %
         remove_deconstructions_from_dead_cell_table(Match, !DeadCellTable),

-        % 4. Add the conditions involved in the reuses to the
-        % existing conditions.
-        reuse_as_least_upper_bound(Background ^ module_info,
-            Background ^ proc_info, match_get_condition(Background, Match),
-            !ReuseAs),
-        % 5. Process the goal for further reuse-matches.
-        process_goal(Background, !DeadCellTable, !Goal,
-            !ReuseAs, !IO)
+        % Add the conditions involved in the reuses to the existing
+        % conditions.
+        %
+        ModuleInfo = Background ^ module_info,
+        ProcInfo   = Background ^ proc_info,
+        reuse_as_least_upper_bound(ModuleInfo, ProcInfo,
+            match_get_condition(Background, Match), !ReuseAs),
+
+        % Process the goal for further reuse-matches.
+        %
+        process_goal(Background, !DeadCellTable, !Goal, !ReuseAs, !IO)
     ).

 :- pred remove_deconstructions_from_dead_cell_table(match::in,
     dead_cell_table::in, dead_cell_table::out) is det.
+
 remove_deconstructions_from_dead_cell_table(Match, !DeadCellTable):-
     DeconSpecs = Match ^ decon_specs,
     list.foldl(remove_deconstruction_from_dead_cell_table, DeconSpecs,
@@ -454,12 +478,13 @@

 :- pred remove_deconstruction_from_dead_cell_table(deconstruction_spec::in,
     dead_cell_table::in, dead_cell_table::out) is det.
+
 remove_deconstruction_from_dead_cell_table(DeconSpec, !DeadCellTable):-
     dead_cell_table_remove(DeconSpec ^ decon_pp, !DeadCellTable).

 %-----------------------------------------------------------------------------%
 %
-% Compute the match table for a given goal.
+% Compute the match table for a given goal
 %
 % The table is computed by traversing the whole goal. For each
 % deconstruction encountered that is also listed in the dead_cell_table,
@@ -475,11 +500,10 @@
         Goal, ContinuationGoals, multi_map.init, MatchTable, !IO).

 :- pred compute_match_table_goal_list(background_info::in, dead_cell_table::in,
-    list(hlds_goal)::in, match_table::in, match_table::out, io::di,
-    io::uo) is det.
+    hlds_goals::in, match_table::in, match_table::out, io::di, io::uo) is det.

-compute_match_table_goal_list(Background, DeadCellTable, Goals,
-        !Table, !IO) :-
+compute_match_table_goal_list(Background, DeadCellTable, Goals, !Table,
+        !IO) :-
     (
         Goals = []
     ;
@@ -489,7 +513,7 @@
     ).

 :- pred compute_match_table_with_continuation(background_info::in,
-    dead_cell_table::in, hlds_goal::in, list(hlds_goal)::in,
+    dead_cell_table::in, hlds_goal::in, hlds_goals::in,
     match_table::in, match_table::out, io::di, io::uo) is det.

 compute_match_table_with_continuation(Background, DeadCellTable,
@@ -545,9 +569,9 @@
             !IO)
     ;
         GoalExpr = switch(_, _, Cases),
-        compute_match_table_in_disjunction(Background, DeadCellTable,
-            list.map(func(C) = G :- (G = C ^ case_goal), Cases),
-                Cont, !Table, !IO),
+        Goals = list.map((func(C) = C ^ case_goal), Cases),
+        compute_match_table_in_disjunction(Background, DeadCellTable,
+            Goals, Cont, !Table, !IO),
         compute_match_table_goal_list(Background, DeadCellTable, Cont, !Table,
             !IO)
     ;
@@ -584,6 +608,7 @@

 :- pred compute_match_table_in_disjs(background_info::in, dead_cell_table::in,
     hlds_goals::in, list(match_table)::out, io::di, io::uo) is det.
+
 compute_match_table_in_disjs(Background, DeadCellTable, Branches, Tables,
         !IO) :-
     list.map_foldl(compute_match_table(Background, DeadCellTable),
@@ -592,6 +617,7 @@
 :- pred compute_match_table_in_disjunction(background_info::in,
     dead_cell_table::in, hlds_goals::in, hlds_goals::in,
     match_table::in, match_table::out, io::di, io::uo) is det.
+
 compute_match_table_in_disjunction(Background, DeadCellTable, DisjGoals, Cont,
         !Table, !IO) :-
     % Compute a match table for each of the branches of the disjunction.
@@ -612,11 +638,12 @@

 :- pred process_possible_common_dead_vars(background_info::in, hlds_goals::in,
     list(match_table)::in, list(match_table)::out, io::di, io::uo) is det.
+
 process_possible_common_dead_vars(Background, Cont, DisjTables,
         ExtraTables, !IO) :-
     CommonDeadVars = common_vars(DisjTables),
     (
-        CommonDeadVars = [_|_]
+        CommonDeadVars = [_ | _]
     ->
         list.filter_map(process_common_var(Background, Cont, DisjTables),
             CommonDeadVars, ExtraTables)
@@ -624,7 +651,8 @@
         ExtraTables = []
     ).

-:- func common_vars(list(match_table)) = list(dead_var).
+:- func common_vars(list(match_table)) = dead_vars.
+
 common_vars(Tables) = CommonVars :-
     (
         Tables = [ First | RestTables ],
@@ -635,7 +663,8 @@
         CommonVars = []
     ).

-:- func common_var_with_list(match_table, prog_vars) = list(dead_var).
+:- func common_var_with_list(match_table, prog_vars) = dead_vars.
+
 common_var_with_list(Table, List0) = List :-
     map.keys(Table, Keys),
     Set = set.intersect(list_to_set(List0), list_to_set(Keys)),
@@ -643,6 +672,7 @@

 :- pred process_common_var(background_info::in, hlds_goals::in,
     list(match_table)::in, dead_var::in, match_table::out) is semidet.
+
 process_common_var(Background, Cont, DisjTables, CommonDeadVar, Table) :-
     Match0 = match_init(deconstruction_specs(CommonDeadVar, DisjTables)),
     find_best_match_in_conjunction(Background, Cont, Match0, Match),
@@ -652,18 +682,21 @@

 :- func deconstruction_specs(prog_var, list(match_table)) =
     list(deconstruction_spec).
+
 deconstruction_specs(DeadVar, Tables) = DeconstructionSpecs :-
     list.foldl(deconstruction_specs_2(DeadVar), Tables, [],
         DeconstructionSpecs).

 :- pred deconstruction_specs_2(prog_var::in, match_table::in,
     list(deconstruction_spec)::in, list(deconstruction_spec)::out) is det.
+
 deconstruction_specs_2(DeadVar, Table, !DeconstructionSpecs) :-
     multi_map.lookup(Table, DeadVar, Matches),
     NewSpecs = list.condense(list.map(match_get_decon_specs, Matches)),
     append(NewSpecs, !DeconstructionSpecs).

 :- func match_get_decon_specs(match) = list(deconstruction_spec).
+
 match_get_decon_specs(Match) = Match ^ decon_specs.

 %-----------------------------------------------------------------------------%
@@ -672,11 +705,10 @@
 % matches.
 %

-    %
-    % Compute the value of a dead cell with respect to its possible reuses in a
-    % conjunction of goals. If reuse is possible, add the specification of the
-    % construction where it can be reused to the list of constructions recorded
-    % in the match.
+    % Compute the value of a dead cell with respect to its possible reuses in
+    % a conjunction of goals. If reuse is possible, add the specification of
+    % the construction where it can be reused to the list of constructions
+    % recorded in the match.
     %
     % In a conjunction, a dead cell can only be reused in at most one of its
     % direct children. This means that for each child a new value is computed.
@@ -689,8 +721,8 @@
     %
     % XXX What is the thing with the degrees here?
     %
-:- pred find_best_match_in_conjunction(background_info::in,
-    hlds_goals::in, match::in, match::out) is det.
+:- pred find_best_match_in_conjunction(background_info::in, hlds_goals::in,
+    match::in, match::out) is det.

 find_best_match_in_conjunction(Background, Goals, !Match) :-
     Match0 = !.Match,
@@ -708,11 +740,12 @@
     %
 :- pred find_match_in_disjunction(background_info::in, hlds_goals::in,
     match::in, match::out) is det.
+
 find_match_in_disjunction(Background, Branches, !Match) :-
     (
         Branches = []
     ;
-        Branches = [_|_],
+        Branches = [_ | _],
         list.map(find_match_in_goal(Background, !.Match), Branches,
             BranchMatches),
         average_match(BranchMatches, !:Match)
@@ -737,8 +770,9 @@
             empty_reuse_description(goal_info_get_reuse(GoalInfo))

         ->
-                % Is it possible for the construction to reuse the dead cell
-                % specified by the match?
+            % Is it possible for the construction to reuse the dead cell
+            % specified by the match?
+            %
             verify_match(Background, Var, Cons, Args,
                 program_point_init(GoalInfo), !Match)
         ;
@@ -758,9 +792,8 @@
         find_match_in_disjunction(Background, Goals, !Match)
     ;
         GoalExpr = switch(_, _, Cases),
-        find_match_in_disjunction(Background,
-            list.map(func(C) = G :- (G = C ^ case_goal), Cases),
-            !Match)
+        Goals = list.map((func(C) = C ^ case_goal), Cases),
+        find_match_in_disjunction(Background, Goals, !Match)
     ;
         GoalExpr = not(_)
     ;
@@ -780,17 +813,22 @@
     ).

 :- func count_candidates(list(match)) = int.
+
 count_candidates(Matches) = list.foldl(add_degree, Matches, 0).

 :- func add_degree(match, int) = int.
+
 add_degree(Match, Degree0) = Degree0 + Match ^ match_degree.

 :- pred empty_reuse_description(reuse_description::in) is semidet.
+
 empty_reuse_description(empty).

 %-----------------------------------------------------------------------------%
-% Verify the value of a match for a given construction.
 %
+% Verify the value of a match for a given construction
+%
+
 % The value is computed using the following rule:
 %
 % Gain = (Alfa + Gamma) * ArityNewCell + Beta
@@ -804,14 +842,20 @@
 % * Beta: cost of setting the value of the cons_id field;

 :- func alfa_value = int is det.
-:- func gamma_value = int is det.
-:- func beta_value = int is det.
+
 alfa_value = 5.
+
+:- func gamma_value = int is det.
+
 gamma_value = 1.
+
+:- func beta_value = int is det.
+
 beta_value = 1.

 :- pred verify_match(background_info::in, prog_var::in, cons_id::in,
     prog_vars::in, program_point::in, match::in, match::out) is det.
+
 verify_match(Background, NewVar, NewCons, NewArgs, PP, !Match) :-
     DeconSpecs = !.Match ^ decon_specs,
     list.filter_map(compute_reuse_type(Background, NewVar, NewCons, NewArgs),
@@ -836,15 +880,14 @@
     % deconstructed dead data structure.
     %
 :- pred compute_reuse_type(background_info::in, prog_var::in, cons_id::in,
-    prog_vars::in, deconstruction_spec::in,
-    reuse_type::out) is semidet.
+    prog_vars::in, deconstruction_spec::in, reuse_type::out) is semidet.

 compute_reuse_type(Background, NewVar, NewCons, NewCellArgs, DeconSpec,
             ReuseType) :-
     DeconSpec = decon(DeadVar, _, DeadCons, DeadCellArgs, _),

     ModuleInfo = Background ^ module_info,
-    Vartypes   = Background ^ vartypes,
+    Vartypes = Background ^ vartypes,
     NewArity = list.length(NewCellArgs),
     DeadArity = list.length(DeadCellArgs),

@@ -871,15 +914,12 @@
     % fields that do not require an update if the construction unification
     % would reuse the deconstructed cell.
     %
-    has_secondary_tag(ModuleInfo, Vartypes, NewVar,
-        NewCons, SecTag),
-    has_secondary_tag(ModuleInfo, Vartypes, DeadVar,
-        DeadCons, DeadSecTag),
-    ReuseFields = already_correct_fields(SecTag, NewCellArgs,
+    has_secondary_tag(ModuleInfo, Vartypes, NewVar, NewCons, SecTag),
+    has_secondary_tag(ModuleInfo, Vartypes, DeadVar, DeadCons, DeadSecTag),
+    ReuseFields = already_correct_fields(SecTag, NewCellArgs,
         DeadSecTag - DeadCellArgs),
     UpToDateFields = list.length(
         list.delete_all(ReuseFields, needs_update)),
-
     %
     % Finally, compute the value of this reuse-configuration.
     %
@@ -907,6 +947,7 @@
         (V1 + V2) / 2.00 ).

 :- func ands(list(needs_update), list(needs_update)) = list(needs_update).
+
 ands(L1, L2) = L :-
     (
         length(L1) =< length(L2)
@@ -920,6 +961,7 @@
     L = list.map_corresponding(needs_update_and, L1b, L2b).

 :- func needs_update_and(needs_update, needs_update) = needs_update.
+
 needs_update_and(needs_update, needs_update) = needs_update.
 needs_update_and(needs_update, does_not_need_update) = needs_update.
 needs_update_and(does_not_need_update, needs_update) = needs_update.
@@ -928,18 +970,18 @@


 %-----------------------------------------------------------------------------%
-        %
-        % has_secondary_tag(Var, ConsId, HasSecTag) is true iff the
+
+        % has_secondary_tag(Var, ConsId, HasSecTag) returns `yes' iff the
         % variable, Var, with cons_id, ConsId, requires a remote
         % secondary tag to distinguish between its various functors.
         %
 :- pred has_secondary_tag(module_info::in, vartypes::in,
-                prog_var::in, cons_id::in, bool::out) is det.
+    prog_var::in, cons_id::in, bool::out) is det.

 has_secondary_tag(ModuleInfo, VarTypes, Var, ConsId, SecondaryTag) :-
     (
         map.lookup(VarTypes, Var, Type),
-        type_util.type_to_type_defn_body(ModuleInfo, Type, TypeBody),
+        type_to_type_defn_body(ModuleInfo, Type, TypeBody),
         TypeBody = du_type(_, ConsTagValues, _, _, _, _),
         map.search(ConsTagValues, ConsId, ConsTag),
         MaybeSecondaryTag = get_secondary_tag(ConsTag),
@@ -950,7 +992,6 @@
         SecondaryTag = no
     ).

-    %
     % already_correct_fields(HasSecTagC, VarsC, HasSecTagR - VarsR)
     % takes a list of variables, VarsC, which are the arguments for the cell to
     % be constructed and the list of variables, VarsR, which are the arguments
@@ -960,8 +1001,8 @@
     % correct value stored in it.  To do this correctly we
     % need to know whether each cell has a secondary tag field.
     %
-:- func already_correct_fields(bool, prog_vars,
-        pair(bool, prog_vars)) = list(needs_update).
+:- func already_correct_fields(bool, prog_vars, pair(bool, prog_vars)) =
+    list(needs_update).

 already_correct_fields(SecTagC, CurrentCellVars, SecTagR - ReuseCellVars)
         = NeedsNoUpdate ++ list.duplicate(LengthC - LengthB, needs_update) :-
@@ -982,7 +1023,6 @@
 already_correct_fields_2(no, CurrentCellVars, no, ReuseCellVars)
     = equals(CurrentCellVars, ReuseCellVars).

-    %
     % equals(ListA, ListB) produces a list of 'needs_update' that indicates
     % whether the corresponding elements from ListA and ListB are equal.  If
     % ListA and ListB are of different lengths, the resulting list is the
@@ -1005,7 +1045,6 @@
 drop_one([]) = [].
 drop_one([_ | Xs]) = Xs.

-
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 %
@@ -1079,9 +1118,9 @@
     annotate_reuses_in_goal(Background, Match, Goal0, Goal),
     !:Case = case(A, Goal).

-:- pred annotate_reuse_for_unification(background_info::in,
-    match::in, unification::in,
-    hlds_goal_info::in, hlds_goal_info::out) is det.
+:- pred annotate_reuse_for_unification(background_info::in, match::in,
+    unification::in, hlds_goal_info::in, hlds_goal_info::out) is det.
+
 annotate_reuse_for_unification(Background, Match, Unification, !GoalInfo):-
     CurrentProgramPoint = program_point_init(!.GoalInfo),
     (
@@ -1145,34 +1184,41 @@

 :- pred match_find_deconstruction_spec(match::in, program_point::in,
     deconstruction_spec::out) is semidet.
+
 match_find_deconstruction_spec(Match, ProgramPoint, DeconstructionSpec) :-
     list.filter(deconstruction_spec_with_program_point(ProgramPoint),
         Match ^ decon_specs, [DeconstructionSpec]).

 :- pred match_find_construction_spec(match::in, program_point::in,
     construction_spec::out) is semidet.
+
 match_find_construction_spec(Match, ProgramPoint, ConstructionSpec) :-
     list.filter(construction_spec_with_program_point(ProgramPoint),
         Match ^ con_specs, [ConstructionSpec]).

 :- pred deconstruction_spec_with_program_point(program_point::in,
     deconstruction_spec::in) is semidet.
+
 deconstruction_spec_with_program_point(DeconstructionSpec ^ decon_pp,
     DeconstructionSpec).

 :- pred construction_spec_with_program_point(program_point::in,
     construction_spec::in) is semidet.
+
 construction_spec_with_program_point(ConstructionSpec ^ con_pp,
     ConstructionSpec).

 %-----------------------------------------------------------------------------%
-% Predicates to print intermediate results as stored in a match_table.
+%
+% Predicates to print intermediate results as stored in a match_table
 %

 :- func line_length = int.
+
 line_length = 79.

 :- pred dump_line(string::in, io::di, io::uo) is det.
+
 dump_line(Msg, !IO) :-
     Prefix = "%---",
     Start = string.append(Prefix, Msg),
@@ -1186,15 +1232,14 @@

 maybe_dump_match_table(VeryVerbose, MatchTable, HighestMatch, !IO) :-
     (
-        VeryVerbose = yes
-    ->
+        VeryVerbose = yes,
         dump_line("reuse table", !IO),
         io.write_string("%\t|\tvar\t|\tvalue\t|\tdegree\n", !IO),
         dump_match("%-sel- ", HighestMatch, !IO),
         dump_full_table(MatchTable, !IO),
         dump_line("", !IO)
     ;
-        true
+        VeryVerbose = no
     ).

 :- pred dump_match(string::in, match::in, io::di, io::uo) is det.
@@ -1205,7 +1250,7 @@
     io.write_string("\t|\t", !IO),
     Val = Match ^ match_value,
     (
-        Val \= 0.00
+        Val \= 0.0
     ->
         io.format("%.2f", [f(Val)], !IO)
     ;
@@ -1220,14 +1265,10 @@

 :- pred dump_match_details(match::in, io::di, io::uo) is det.
 dump_match_details(Match, !IO) :-
-    Conds = list.map(
-        (func(DeconSpec) = Cond :-
-            Cond = DeconSpec ^ decon_conds),
-            Match ^ decon_specs),
-    (
-        list.takewhile(
-            reuse_as_all_unconditional_reuses,
-            Conds, _, [])
+    Conds = list.map((func(DeconSpec) = DeconSpec ^ decon_conds),
+        Match ^ decon_specs),
+    (
+        list.takewhile(reuse_as_all_unconditional_reuses, Conds, _, [])
     ->
         CondsString = "A"
     ;
@@ -1254,12 +1295,15 @@
         dump_line("full table (end)", !IO)
     ).

-:- pred maybe_dump_full_table(bool::in, match_table::in, io::di,
-        io::uo) is det.
+:- pred maybe_dump_full_table(bool::in, match_table::in,
+    io::di, io::uo) is det.
+
 maybe_dump_full_table(no, _M, !IO).
-maybe_dump_full_table(yes, M, !IO) :- dump_full_table(M, !IO).
+maybe_dump_full_table(yes, M, !IO) :-
+    dump_full_table(M, !IO).

 %-----------------------------------------------------------------------------%
+
     % After determining all local reuses of dead datastructures (a data
     % structure becomes dead and is reused in one and the same procedure), we
     % determine the 'global reuses': deconstructions that yield dead data
@@ -1271,7 +1315,7 @@

 check_for_cell_caching(DeadCellTable0, !Goal, !IO) :-
     dead_cell_table_remove_conditionals(DeadCellTable0, DeadCellTable),
-    globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+    globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
     (
         \+ dead_cell_table_is_empty(DeadCellTable)
     ->
@@ -1367,9 +1411,13 @@
     ;
         true
     ).
+
 %-----------------------------------------------------------------------------%
+
 :- func this_file = string.
+
 this_file = "structure_reuse.direct.choose_reuse.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.direct.choose_reuse.
-
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.direct.detect_garbage.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.direct.detect_garbage.m,v
retrieving revision 1.2
diff -u -r1.2 structure_reuse.direct.detect_garbage.m
--- compiler/structure_reuse.direct.detect_garbage.m	29 May 2006 13:04:34 -0000	1.2
+++ compiler/structure_reuse.direct.detect_garbage.m	5 Jun 2006 04:16:15 -0000
@@ -6,16 +6,16 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.direct.detect_garbage.m
-% Main authors: nancy
+% File: structure_reuse.direct.detect_garbage.m.
+% Main authors: nancy.
 %
 % Detect where datastructures become garbage in a given procedure: construct
 % a dead cell table.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.direct.detect_garbage.
-
 :- interface.

     % Using the sharing table listing all the structure sharing of all
@@ -27,12 +27,17 @@
 :- pred determine_dead_deconstructions(module_info::in, proc_info::in,
     sharing_as_table::in, hlds_goal::in, dead_cell_table::out) is det.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module check_hlds.type_util.

 :- import_module pair.

+%-----------------------------------------------------------------------------%
+
 determine_dead_deconstructions(ModuleInfo, ProcInfo, SharingTable,
     Goal, DeadCellTable):-
     % In this process we need to know the sharing at each program point,
@@ -123,9 +128,9 @@
     ).

 :- pred determine_dead_deconstructions_2_disj(module_info::in,
-    proc_info::in, sharing_as_table::in, list(hlds_goal)::in,
-    sharing_as::in, sharing_as::out, dead_cell_table::in,
-    dead_cell_table::out) is det.
+    proc_info::in, sharing_as_table::in, hlds_goals::in,
+    sharing_as::in, sharing_as::out,
+    dead_cell_table::in, dead_cell_table::out) is det.

 determine_dead_deconstructions_2_disj(ModuleInfo, ProcInfo,
     SharingTable, Goals, !SharingAs, !DeadCellTable) :-
@@ -135,12 +140,12 @@

 :- pred determine_dead_deconstructions_2_disj_goal(module_info::in,
     proc_info::in, sharing_as_table::in, sharing_as::in, hlds_goal::in,
-    sharing_as::in, sharing_as::out, dead_cell_table::in,
-    dead_cell_table::out) is det.
+    sharing_as::in, sharing_as::out,
+    dead_cell_table::in, dead_cell_table::out) is det.

 determine_dead_deconstructions_2_disj_goal(ModuleInfo, ProcInfo,
-    SharingTable, SharingBeforeDisj, Goal, !SharingAs,
-    !DeadCellTable) :-
+        SharingTable, SharingBeforeDisj, Goal, !SharingAs,
+        !DeadCellTable) :-
     determine_dead_deconstructions_2(ModuleInfo, ProcInfo, SharingTable,
         Goal, SharingBeforeDisj, GoalSharing, !DeadCellTable),
     !:SharingAs = sharing_as_least_upper_bound(ModuleInfo, ProcInfo,
@@ -158,7 +163,7 @@
     sharing_as::in, dead_cell_table::in, dead_cell_table::out) is det.

 unification_verify_reuse(ModuleInfo, ProcInfo, GoalInfo, Unification,
-    PP, Sharing, !DeadCellTable):-
+        PP, Sharing, !DeadCellTable):-
     (
         Unification = deconstruct(Var, ConsId, _, _, _, _),
         LFU = goal_info_get_lfu(GoalInfo),
@@ -211,9 +216,11 @@
     list.member(datastruct_init(Var), LiveData).

 %-----------------------------------------------------------------------------%
+
 :- func this_file = string.

 this_file = "structure_sharing.direct.detect_garbage.m".
-

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.direct.detect_garbage.
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.direct.m,v
retrieving revision 1.1
diff -u -r1.1 structure_reuse.direct.m
--- compiler/structure_reuse.direct.m	10 May 2006 10:56:56 -0000	1.1
+++ compiler/structure_reuse.direct.m	5 Jun 2006 04:20:13 -0000
@@ -6,23 +6,24 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.direct.m
-% Main authors: nancy
+% File: structure_reuse.direct.m.
+% Main authors: nancy.
 %
-% Procedures and types related to the detection of so called direct reuses
-% within the CTGC system. A "direct reuse" is a combination of the location of
-% a deconstruction unification (where a datastructure may become garbage under
-% certain conditions) and a set of locations of construction unifications where
-% the garbage datastructure can be reused locally.
+% This module efined procedure and type related to the dectection of so called
+% direct reuses within the CTGC system.  A "direct reuse" is a combination of
+% the location of a deconstruction unification (where a datastructure may
+% become garbage under certain conditions) and a set of locations of
+% construction unifications where the garbage datastructure can be reused
+% locally.
 %
 % Direct reuse analysis requires two steps:
-% - detecting where datastructures may become garbage;
-% - and finding where these garbage datastructures can be reused.
+%   - Detecting where datastructures may become garbage.
+%   - Finding where these garbage datastructures can be reused.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.direct.
-
 :- interface.

 :- import_module hlds.hlds_module.
@@ -31,10 +32,15 @@

 :- import_module io.

+%-----------------------------------------------------------------------------%
+
 :- pred direct_reuse_pass(sharing_as_table::in, module_info::in,
     module_info::out, reuse_as_table::in, reuse_as_table::out,
     io::di, io::uo) is det.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module hlds.hlds_goal.
@@ -56,14 +62,16 @@
 :- import_module list.
 :- import_module map.
 :- import_module set.
-:- import_module std_util.
 :- import_module string.
+:- import_module svmap.
 :- import_module term.
 :- import_module varset.

 :- include_module transform_hlds.ctgc.structure_reuse.direct.detect_garbage.
 :- include_module transform_hlds.ctgc.structure_reuse.direct.choose_reuse.

+%-----------------------------------------------------------------------------%
+
     % The strategy for determining the reuse possibilities, i.e., either
     % reuse is only allowed between terms that have exactly the same cons_id,
     % or reuse is also allowed between terms that have different cons_id, yet
@@ -115,7 +123,7 @@
     reuse_as_table::out, io::di, io::uo) is det.

 direct_reuse_process_pred(Strategy, SharingTable, PredId, !ModuleInfo,
-    !ReuseTable, !IO):-
+        !ReuseTable, !IO):-
     module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
     list.foldl3(direct_reuse_process_proc(Strategy, SharingTable, PredId),
         pred_info_non_imported_procids(PredInfo0), !ModuleInfo,
@@ -158,12 +166,14 @@

     % Determine the deconstructions in which data may potentially become
     % garbage.
+    %
     determine_dead_deconstructions(ModuleInfo, !.ProcInfo, SharingTable,
         Goal0, DeadCellTable),
     dead_cell_table_maybe_dump(VeryVerbose, DeadCellTable, !IO),

     % Determine how the detected dead datastructures can be reused.
     % This annotates the goal with potential reuses.
+    %
     determine_reuse(Strategy, ModuleInfo, !.ProcInfo, DeadCellTable,
         Goal0, Goal, ReuseAs, !IO),

@@ -211,28 +221,28 @@
     % the associated reuse_condition.
     %
 :- func dead_cell_table_search(program_point, dead_cell_table)
-        = reuse_condition is semidet.
+    = reuse_condition is semidet.

     % Add a program point and its associated reuse_condition to the table.
     %
 :- pred dead_cell_table_set(program_point::in, reuse_condition::in,
-        dead_cell_table::in, dead_cell_table::out) is det.
+    dead_cell_table::in, dead_cell_table::out) is det.

     % Remove a program point from the table.
     %
 :- pred dead_cell_table_remove(program_point::in,
-        dead_cell_table::in, dead_cell_table::out) is det.
+    dead_cell_table::in, dead_cell_table::out) is det.

     % Remove all program points from the table for which the reuse_conditions
     % are "conditional".
     %
 :- pred dead_cell_table_remove_conditionals(dead_cell_table::in,
-        dead_cell_table::out) is det.
+    dead_cell_table::out) is det.

     % Dump the contents of the table.
     %
 :- pred dead_cell_table_maybe_dump(bool::in, dead_cell_table::in,
-        io__state::di, io__state::uo) is det.
+    io::di, io::uo) is det.

 program_point_init(Info) = PP :-
     goal_info_get_context(Info, Context),
@@ -273,19 +283,25 @@
     io.write_char('l').

 dead_cell_table_init = map.init.
-dead_cell_table_is_empty(Table) :- map.is_empty(Table).
+
+dead_cell_table_is_empty(Table) :-
+    map.is_empty(Table).
+
 dead_cell_table_search(PP, Table) = Table ^ elem(PP).
-dead_cell_table_set(PP, RC, Table0, Table) :-
-    map.set(Table0, PP, RC, Table).
+
+dead_cell_table_set(PP, RC, !Table) :-
+    svmap.set(PP, RC, !Table).
+
 dead_cell_table_remove(PP, !Table) :-
-    map.det_remove(!.Table, PP, _, !:Table).
+    svmap.det_remove(PP, _, !Table).
+
 dead_cell_table_remove_conditionals(!Table) :-
     map.foldl(dead_cell_table_add_unconditional, !.Table,
         dead_cell_table_init, !:Table).

 :- pred dead_cell_table_add_unconditional(program_point::in,
-        reuse_condition::in, dead_cell_table::in,
-        dead_cell_table::out) is det.
+    reuse_condition::in, dead_cell_table::in, dead_cell_table::out) is det.
+
 dead_cell_table_add_unconditional(PP, C, !Table) :-
     (
         reuse_condition_is_conditional(C)
@@ -306,23 +322,25 @@
     ).

 :- pred dead_cell_entry_dump(program_point::in, reuse_condition::in,
-        io__state::di, io__state::uo) is det.
+    io::di, io::uo) is det.
+
 dead_cell_entry_dump(PP, Cond, !IO) :-
     (
         reuse_condition_is_conditional(Cond)
     ->
-        write_string("\t\t|  cond  |\t", !IO)
+        io.write_string("\t\t|  cond  |\t", !IO)
     ;
-        write_string("\t\t| always |\t", !IO)
+        io.write_string("\t\t| always |\t", !IO)
     ),
     dump_program_point(PP, !IO),
-    write_string("\n", !IO).
-
+    io.write_string("\n", !IO).

 %-----------------------------------------------------------------------------%
+
 :- func this_file = string.

 this_file = "structure_sharing.direct.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.direct.
-
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.domain.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.domain.m,v
retrieving revision 1.2
diff -u -r1.2 structure_reuse.domain.m
--- compiler/structure_reuse.domain.m	29 May 2006 13:04:34 -0000	1.2
+++ compiler/structure_reuse.domain.m	5 Jun 2006 04:22:02 -0000
@@ -6,16 +6,16 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.domain.m
-% Main authors: nancy
+% File: structure_reuse.domain.m.
+% Main authors: nancy.
 %
 % Definition of the abstract domain for keeping track of opportunities for
 % structure reuse.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.domain.
-
 :- interface.

 :- import_module hlds.goal_util.
@@ -31,6 +31,8 @@
 :- import_module set.
 :- import_module list.

+%-----------------------------------------------------------------------------%
+
     % A reuse condition stores all the necessary information to check if
     % a procedure call is safe w.r.t. a structure reuse opportunity within
     % the body of the called procedure.
@@ -43,6 +45,7 @@
 :- type reuse_as.

 %-----------------------------------------------------------------------------%
+%
 % reuse_condition
 %

@@ -209,6 +212,7 @@
 % :- func load_structure_reuse_table(module_info) = reuse_as_table.

 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- implementation.

@@ -221,6 +225,8 @@
 :- import_module set.
 :- import_module string.

+%-----------------------------------------------------------------------------%
+
 :- type reuse_condition
     --->    always      % The reuse is always safe and does not actually
                         % have a condition.
@@ -254,7 +260,7 @@

 %-----------------------------------------------------------------------------%
 %
-% reuse_condition.
+% reuse_condition
 %

 reuse_condition_init(ModuleInfo, ProcInfo, DeadVar, LFU, LBU,
@@ -273,7 +279,7 @@
     %   obtained datastructures are kept as the nodes for our condition.
     TopCell = ctgc.datastruct.datastruct_init(DeadVar),
     (
-        list__member(DeadVar, HeadVars)
+        list.member(DeadVar, HeadVars)
     ->
         Nodes = [TopCell]
     ;
@@ -290,7 +296,7 @@
     ->
         Condition = always
     ;
-        set__union(LFU, LBU, LU),
+        set.union(LFU, LBU, LU),
             % XXX the old implementation did not bother about extending at
             % this place, which was contrary to the theory. Check the effect
             % of this change!
@@ -451,6 +457,7 @@

 :- pred reuse_conditions_add_condition(module_info::in, proc_info::in,
     reuse_condition::in, reuse_conditions::in, reuse_conditions::out) is det.
+
 reuse_conditions_add_condition(ModuleInfo, ProcInfo, Condition, !Conds):-
     (
         reuse_condition_subsumed_by_list(ModuleInfo, ProcInfo,
@@ -458,14 +465,15 @@
     ->
         true
     ;
-        !:Conds = [Condition|!.Conds]
+        !:Conds = [Condition | !.Conds]
     ).

 :- pred reuse_conditions_add_conditions(module_info::in, proc_info::in,
     reuse_conditions::in, reuse_conditions::in, reuse_conditions::out) is det.
+
 reuse_conditions_add_conditions(ModuleInfo, ProcInfo, NewConds, !Conds):-
     (
-        NewConds = [Cond|RemainingConds],
+        NewConds = [Cond | RemainingConds],
         reuse_conditions_add_condition(ModuleInfo, ProcInfo, Cond, !Conds),
         reuse_conditions_add_conditions(ModuleInfo, ProcInfo,
             RemainingConds, !Conds)
@@ -610,9 +618,6 @@
         nodes_are_not_live(ModuleInfo, ProcInfo, DeadNodes,
             UpdatedLiveData)
     ).
-
-
-

 %-----------------------------------------------------------------------------%
 %
@@ -654,9 +659,11 @@
         reuse_as_short_description(ReuseAs) ++ "\n", !IO).

 %-----------------------------------------------------------------------------%
+
 :- func this_file = string.
+
 this_file = "structure_reuse.domain.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.domain.
-
-
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.indirect.m,v
retrieving revision 1.1
diff -u -r1.1 structure_reuse.indirect.m
--- compiler/structure_reuse.indirect.m	29 May 2006 13:04:35 -0000	1.1
+++ compiler/structure_reuse.indirect.m	5 Jun 2006 04:23:42 -0000
@@ -5,14 +5,16 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-% File: structure_reuse.indirect.m
-% Main authors: nancy
 %
-% Determine the indirect reuse. This requires a fixpoint computation.
+% File: structure_reuse.indirect.m.
+% Main authors: nancy.
+%
+% Determine the indirect reuse.  This requires a fixpoint computation.
+%
+%------------------------------------------------------------------------------%
 %------------------------------------------------------------------------------%

 :- module structure_reuse.indirect.
-
 :- interface.

 :- import_module hlds.hlds_module.
@@ -21,6 +23,8 @@

 :- import_module io.

+%------------------------------------------------------------------------------%
+
     % Direct reuse analysis derives information about deconstructions that
     % under certain circumstances (formalised as "reuse conditions") form
     % the last ever (memory) access to the deconstructed term.
@@ -66,6 +70,8 @@
 :- import_module set.
 :- import_module string.

+%------------------------------------------------------------------------------%
+
 indirect_reuse_pass(SharingTable, !ModuleInfo, !ReuseTable, !IO):-
     %
     % Perform a bottom-up traversal of the SCCs in the module,
@@ -76,8 +82,8 @@
     (
         MaybeDepInfo = yes(DepInfo),
         hlds_dependency_info_get_dependency_ordering(DepInfo, SCCs),
-        list.foldl3(indirect_reuse_analyse_scc(SharingTable),
-            SCCs, !ModuleInfo, !ReuseTable, !IO)
+        list.foldl3(indirect_reuse_analyse_scc(SharingTable), SCCs,
+            !ModuleInfo, !ReuseTable, !IO)
     ;
         MaybeDepInfo = no,
         unexpected(this_file, "No dependency information.")
@@ -99,8 +105,8 @@

 :- pred indirect_reuse_analyse_scc_until_fixpoint(sharing_as_table::in,
     list(pred_proc_id)::in, reuse_as_table::in,
-    module_info::in, module_info::out, sr_fixpoint_table::in,
-    sr_fixpoint_table::out, io::di, io::uo) is det.
+    module_info::in, module_info::out,
+    sr_fixpoint_table::in, sr_fixpoint_table::out, io::di, io::uo) is det.

 indirect_reuse_analyse_scc_until_fixpoint(SharingTable, SCC,
         ReuseTable, !ModuleInfo, !FixpointTable, !IO):-
@@ -115,6 +121,7 @@
     ).

 %-----------------------------------------------------------------------------%
+
 :- pred indirect_reuse_analyse_pred_proc(sharing_as_table::in,
     reuse_as_table::in, pred_proc_id::in, module_info::in, module_info::out,
     sr_fixpoint_table::in, sr_fixpoint_table::out, io::di, io::uo) is det.
@@ -215,7 +222,7 @@
     (
         AnalysisInfoList = []
     ;
-        AnalysisInfoList = [_|_],
+        AnalysisInfoList = [_ | _],
         list.foldl(analysis_info_lub(BaseInfo), AnalysisInfoList,
             !AnalysisInfo),
         !:AnalysisInfo = !.AnalysisInfo ^ fptable := FixpointTable
@@ -388,9 +395,8 @@
 %-----------------------------------------------------------------------------%

 :- pred verify_indirect_reuse(ir_background_info::in, pred_id::in, proc_id::in,
-    list(prog_var)::in, hlds_goal_info::in, hlds_goal_info::out,
-    ir_analysis_info::in, ir_analysis_info::out,
-    io::di, io::uo) is det.
+    prog_vars::in, hlds_goal_info::in, hlds_goal_info::out,
+    ir_analysis_info::in, ir_analysis_info::out, io::di, io::uo) is det.

 verify_indirect_reuse(BaseInfo, CalleePredId, CalleeProcId, CalleeArgs,
         !GoalInfo, !AnalysisInfo, !IO):-
@@ -545,12 +551,11 @@

 update_reuse_in_table(FixpointTable, PPId, !ReuseTable) :-
     reuse_as_table_set(PPId,
-        sr_fixpoint_table_get_final_as(PPId, FixpointTable),
-        !ReuseTable).
+        sr_fixpoint_table_get_final_as(PPId, FixpointTable), !ReuseTable).

 %-----------------------------------------------------------------------------%
 %
-% Structure reuse fixpoint table.
+% Structure reuse fixpoint table
 %

 :- type sr_fixpoint_table == fixpoint_table(pred_proc_id, reuse_as).
@@ -632,7 +637,6 @@
 sr_fixpoint_table_init(Keys, ReuseTable) = Table :-
     Table = init_fixpoint_table(get_reuse_as(ReuseTable), Keys).

-
 sr_fixpoint_table_new_run(!Table) :-
     fixpoint_table.new_run(!Table).

Index: compiler/structure_reuse.lbu.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.lbu.m,v
retrieving revision 1.1
diff -u -r1.1 structure_reuse.lbu.m
--- compiler/structure_reuse.lbu.m	10 May 2006 10:56:56 -0000	1.1
+++ compiler/structure_reuse.lbu.m	5 Jun 2006 04:25:45 -0000
@@ -6,8 +6,8 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.lbu.m
-% Main authors: nancy
+% File: structure_reuse.lbu.m.
+% Main authors: nancy.
 %
 % Implementation of the process of annotating each program point within
 % a procedure with local backward use information.
@@ -24,16 +24,19 @@
 % switches and if-then-elses.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.lbu.
-
 :- interface.

 :- import_module hlds.hlds_module.
 :- import_module hlds.hlds_pred.

-:- pred backward_use_information(module_info::in, proc_info::in,
-    proc_info::out) is det.
+:- pred backward_use_information(module_info::in,
+    proc_info::in, proc_info::out) is det.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- implementation.

@@ -47,6 +50,8 @@
 :- import_module set.
 :- import_module string.

+%-----------------------------------------------------------------------------%
+
 backward_use_information(ModuleInfo, !ProcInfo):-
     proc_info_get_goal(!.ProcInfo, Goal0),

@@ -86,7 +91,7 @@
             detism_allows_multiple_solns(Det)
         ->
             % Implementation of Instantiation 2 from Nancy's Phd.
-            % In this instantation, a non deterministic procedure
+            % In this instantation, a non-deterministic procedure
             % call only adds its LFU-variables to the current set
             % of lbu-variables. Cf. Phd Nancy Mazur.

@@ -163,9 +168,8 @@
         unexpected(this_file, "backward_use_in_goal_2: shorthand goal.")
     ).

-
-
 :- func get_backtrack_vars(hlds_goal_info) = set(prog_var).
+
 get_backtrack_vars(Info) = Vars :-
     goal_info_get_resume_point(Info, ResPoint),
     (
@@ -177,14 +181,15 @@
     ).

 :- pred detism_allows_multiple_solns(prog_data__determinism::in) is semidet.
+
 detism_allows_multiple_solns(nondet).
 detism_allows_multiple_solns(multidet).
 detism_allows_multiple_solns(cc_nondet).
 detism_allows_multiple_solns(cc_multidet).

 :- pred backward_use_in_conj(module_info::in, proc_info::in,
-    list(hlds_goal)::in, list(hlds_goal)::out, set(prog_var)::in,
-    set(prog_var)::out) is det.
+    hlds_goals::in, hlds_goals::out, set(prog_var)::in, set(prog_var)::out)
+    is det.

 backward_use_in_conj(ModuleInfo, ProcInfo, !Goals, !LBU) :-
     list.map_foldl(backward_use_in_goal(ModuleInfo, ProcInfo), !Goals, !LBU).
@@ -210,8 +215,8 @@
     set.union(NewLBU, !LBU).

 :- pred backward_use_in_disj(module_info::in, proc_info::in,
-    list(hlds_goal)::in, list(hlds_goal)::out,
-    set(prog_var)::in, set(prog_var)::out) is det.
+    hlds_goals::in, hlds_goals::out, set(prog_var)::in, set(prog_var)::out)
+    is det.

 backward_use_in_disj(ModuleInfo, ProcInfo, !Goals, !LBU) :-
     % Every disj-goal is analysed with the same initial set of LBU-vars.
@@ -230,6 +235,9 @@
 %-----------------------------------------------------------------------------%

 :- func this_file = string.
+
 this_file = "structure_reuse.lbu.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.lbu.
+%-----------------------------------------------------------------------------%
Index: compiler/structure_reuse.lfu.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.lfu.m,v
retrieving revision 1.1
diff -u -r1.1 structure_reuse.lfu.m
--- compiler/structure_reuse.lfu.m	10 May 2006 10:56:56 -0000	1.1
+++ compiler/structure_reuse.lfu.m	5 Jun 2006 04:28:48 -0000
@@ -6,8 +6,8 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% File: structure_reuse.lfu.m
-% Main authors: nancy
+% File: structure_reuse.lfu.m.
+% Main authors: nancy.
 %
 % Implementation of the process of annotating each program point within
 % a procedure with local forward use information.
@@ -18,15 +18,18 @@
 % forward execution.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_reuse.lfu.
-
 :- interface.

 :- import_module hlds.hlds_pred.

 :- pred forward_use_information(proc_info::in, proc_info::out) is det.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module hlds.hlds_goal.
@@ -40,6 +43,8 @@
 :- import_module pair.
 :- import_module string.

+%-----------------------------------------------------------------------------%
+
 forward_use_information(!ProcInfo) :-
     proc_info_get_goal(!.ProcInfo, Goal0),

@@ -72,11 +77,10 @@
     ;
         forward_use_in_composite_goal(!Goal, !InstantiatedVars, !DeadVars)
     ).
-

 :- pred compute_instantiated_and_dead_vars(hlds_goal_info::in,
-    set(prog_var)::in, set(prog_var)::out, set(prog_var)::in,
-    set(prog_var)::out) is det.
+    set(prog_var)::in, set(prog_var)::out,
+    set(prog_var)::in, set(prog_var)::out) is det.

 compute_instantiated_and_dead_vars(Info, !Inst, !Dead) :-
     % Inst = Inst0 + birth-set
@@ -191,6 +195,9 @@
 %-----------------------------------------------------------------------------%

 :- func this_file = string.
+
 this_file = "structure_reuse.lfu.m".

+%-----------------------------------------------------------------------------%
 :- end_module transform_hlds.ctgc.structure_reuse.lfu.
+%-----------------------------------------------------------------------------%
Index: compiler/structure_sharing.analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_sharing.analysis.m,v
retrieving revision 1.12
diff -u -r1.12 structure_sharing.analysis.m
--- compiler/structure_sharing.analysis.m	29 May 2006 13:04:35 -0000	1.12
+++ compiler/structure_sharing.analysis.m	5 Jun 2006 04:29:30 -0000
@@ -5,13 +5,14 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: structure_sharing.analysis.m.
 % Main authors: nancy.
-
+%
 % Implementation of the structure sharing analysis needed for compile-time
 % garbage collection (CTGC).
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_sharing.analysis.
Index: compiler/structure_sharing.domain.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_sharing.domain.m,v
retrieving revision 1.9
diff -u -r1.9 structure_sharing.domain.m
--- compiler/structure_sharing.domain.m	29 May 2006 13:04:35 -0000	1.9
+++ compiler/structure_sharing.domain.m	5 Jun 2006 04:33:13 -0000
@@ -5,18 +5,18 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: structure_sharing.domain.m.
 % Main author: nancy.
-
+%
 % This module defines the abstract domain for representing structure sharing
 % between data structures.
-
+%
 % This domain forms a complete lattice. It has a bottom element (representing
 % the definite absence of any possible structure sharing), and a top element
 % (that represents any possible structure sharing), a least upper bound
 % operation, and a comparison predicate (is_subsumed_by).
-
+%
 % The auxiliary functions needed for using the domain within the abstract
 % semantics on which the implementation of the analysis is based are:
 %
@@ -36,7 +36,7 @@
 %
 %   * add: add the sharing created by a primitive operation (unification)
 %     to any existing sharing.
-
+%
 % Additional operations:
 %   * extend_datastruct: compute the set of datastructures referring to the
 %     same memory space as a given datastructure, using sharing information;
@@ -45,7 +45,8 @@
 %
 %   * conversion operations between the public and private representation
 %     for sharing sets.
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module transform_hlds.ctgc.structure_sharing.domain.
@@ -273,6 +274,7 @@
 :- func load_structure_sharing_table(module_info) = sharing_as_table.

 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- implementation.

@@ -790,7 +792,6 @@
         int_to_string(pred_id_to_int(PredId)) ++ "," ++
         int_to_string(proc_id_to_int(ProcId))).

-
 %-----------------------------------------------------------------------------%

 load_structure_sharing_table(ModuleInfo) = SharingTable :-
@@ -822,6 +823,7 @@
         MaybePublicSharing = no
     ).
 %-----------------------------------------------------------------------------%
+
     % Succeeds if the sharing of a procedure can safely be approximated by
     % "bottom", simply by looking at the modes and types of the arguments.
     %
@@ -1859,7 +1861,7 @@
     set(pair(T1, T2))::out) is det.

 set_cross_product(SetA, SetB, CrossProduct):-
-    solutions.solutions_set(cross_product(SetA, SetB), CrossProduct).
+    solutions_set(cross_product(SetA, SetB), CrossProduct).

 :- pred cross_product(set(T1)::in, set(T2)::in, pair(T1, T2)::out) is nondet.


--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list