[m-rev.] for review: [CTGC] 2 bugfixes obtaining a working CTGC system

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Mon Oct 9 23:14:13 AEST 2006


Hi,

here are two bugfixes. 

The first one fixes compilation of compiler generated procedures. And the
second one is the fix such that constructions can actually reuse garbage cells
(If I had known that that was the only thing needed for fixing the problem...
). This results in a CTGC system that can detect reuse, and implement that
reuse in the final executables.

So, current status of the CTGC-part: tested with small benchmarks, with
detection of reuse, resulting in cell reuse at runtime. 

Outstanding issues: 
- problem with the mmake-sequence of doing structure reuse, intermodule
  optimization, and generating trans-opts. When MCFLAGS contains the 
  combination of the options --structure-reuse --intermodule-optimization
  and --make-trans-opt, then the compile-to-c stage will halt after generating
  the trans-opts again. So what should the options be, taking into account
  that structure reuse analysis will be needed in every mmake-phase of a 
  set of modules. It is needed when generating the trans-opts, and it is 
  again needed when generating the resulting C files;

- do the manual annotations of some of the (non-trivial foreign-code-)
  procedures in the library modules; 

- check the cell-cache part of the CTGC system; 

- some more testing;

These outstanding issues are planned to be dealt with this week. After that I
will have minimum to zero time to continue working on that system. 

Regards,
Nancy



===================================================================


Estimated hours taken: 2
Branches: main

Two bugfixes. 

compiler/structure_reuse.indirect.m:
	(bugfix) As structure reuse analysis is also performed when compiling
	to C, it may have to analyse compiler generated procedures. These 
	procedures apparently have declared head variables and actual 
	head variables, where the difference appears to be negative (actual -
	declared). This fix fixes the problem, not really nicely -- there
	should be an easier way to get hold of the original set of head
	variables (which should map to the headvariables appearing in any
	analysis derived declaration as in the .trans_opt files).

compiler/structure_reuse.versions.m:
	(bugfix) When producing the reuse versions of analysed procedures,
	constructions unifications with detected possibility for reuse should
	be annotated with the correct "how_to_construct" information so that
	reuse can really take place. 


Index: compiler/structure_reuse.indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.indirect.m,v
retrieving revision 1.7
diff -u -d -r1.7 structure_reuse.indirect.m
--- compiler/structure_reuse.indirect.m	31 Jul 2006 08:32:02 -0000	1.7
+++ compiler/structure_reuse.indirect.m	9 Oct 2006 10:58:55 -0000
@@ -203,7 +203,13 @@
     % We don't need to keep track of any information regarding inserted
     % type-info arguments and alike, so we remove them from the list
     % of headvariables: 
-    list.det_split_list(Diff, HeadVars, _AddedHeadVars, OrigHeadVars), 
+    (
+        Diff >= 0
+    ->
+        list.det_split_list(Diff, HeadVars, _AddedHeadVars, OrigHeadVars)
+    ;
+        OrigHeadVars = HeadVars
+    ),
 
     BG = ir_background_info(ModuleInfo, PredInfo, ProcInfo, 
         SharingTable, ReuseTable, OrigHeadVars).
Index: compiler/structure_reuse.versions.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/structure_reuse.versions.m,v
retrieving revision 1.3
diff -u -d -r1.3 structure_reuse.versions.m
--- compiler/structure_reuse.versions.m	31 Jul 2006 08:32:03 -0000	1.3
+++ compiler/structure_reuse.versions.m	9 Oct 2006 10:58:55 -0000
@@ -63,6 +63,7 @@
 :- import_module mdbcomp.prim_data.
 :- import_module parse_tree.prog_util.
 
+:- import_module bool.
 :- import_module map.
 :- import_module maybe.
 :- import_module pair.
@@ -223,14 +224,17 @@
     ;
         GoalExpr0 = generic_call(_, _, _, _)
     ;
-        GoalExpr0 = unify(_, _, _, _, _),
+        GoalExpr0 = unify(_, _, _, Unification0, _),
         ReuseDescription0 = goal_info_get_reuse(GoalInfo0),
         (
             ReuseDescription0 = potential_reuse(Descr)
         ->
             ReuseDescription = reuse(Descr),
+            unification_set_reuse(Descr, Unification0, 
+                Unification), 
+            GoalExpr = GoalExpr0 ^ unify_kind := Unification, 
             goal_info_set_reuse(ReuseDescription, GoalInfo0, GoalInfo),
-            !:Goal = GoalExpr0 - GoalInfo
+            !:Goal = GoalExpr - GoalInfo
         ;
             true
         )
@@ -266,6 +270,27 @@
         GoalExpr0 = shorthand(_),
         unexpected(this_file, "process_goal: shorthand goal.")
     ).
+
+:- pred unification_set_reuse(short_reuse_description::in, 
+    unification::in, unification::out) is det.
+
+unification_set_reuse(ShortReuseDescription, !Unification) :- 
+    (
+        !.Unification = construct(A, B, C, D, _HowToConstruct, F, G), 
+        ShortReuseDescription = cell_reused(DeadVar, _, PossibleConsIds, 
+            CellsToUpdate)
+    -> 
+        CellToReuse = cell_to_reuse(DeadVar, PossibleConsIds, 
+            list.map(needs_update_to_bool, CellsToUpdate)),
+        HowToConstruct = reuse_cell(CellToReuse),
+        !:Unification = construct(A, B, C, D, HowToConstruct, F, G)
+    ;
+        true
+    ).
+
+:- func needs_update_to_bool(needs_update) = bool. 
+needs_update_to_bool(needs_update) = no.
+needs_update_to_bool(does_not_need_update) = yes.
 
 :- pred determine_reuse_version(structure_reuse_map::in, pred_id::in,
     proc_id::in, sym_name::in, pred_id::out, proc_id::out, 


-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
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