[m-rev.] diff: don't try to reuse no-tag values

Peter Wang novalazy at gmail.com
Wed Jan 30 11:49:04 AEDT 2008


Estimated hours taken: 1.5
Branches: main

Fix a bug where structure reuse tried to reuse the heap cells of no-tag
values.  No-tag values don't have any heap cells to reuse.

compiler/structure_reuse.direct.detect_garbage.m:
	When verifying that a deconstruction yields a garbage data structure,
	check whether the variable being deconstructed is of a no-tag type.

compiler/type_util.m:
	Add a version of `type_is_no_tag_type' that doesn't return any output.

Index: compiler/structure_reuse.direct.detect_garbage.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.direct.detect_garbage.m,v
retrieving revision 1.11
diff -u -r1.11 structure_reuse.direct.detect_garbage.m
--- compiler/structure_reuse.direct.detect_garbage.m	10 Jan 2008 04:29:53 -0000	1.11
+++ compiler/structure_reuse.direct.detect_garbage.m	30 Jan 2008 00:39:04 -0000
@@ -32,6 +32,7 @@
 
 :- implementation.
 
+:- import_module check_hlds.type_util.
 :- import_module libs.compiler_util.
 :- import_module parse_tree.prog_data.
 :- import_module transform_hlds.ctgc.datastruct.
@@ -188,6 +189,11 @@
             ConsId = cons(_, Arity),
             Arity \= 0,
 
+            % No-tag values don't have a cell to reuse.
+            proc_info_get_vartypes(ProcInfo, VarTypes),
+            map.lookup(VarTypes, Var, Type),
+            \+ type_is_no_tag_type(ModuleInfo, Type),
+
             % Check if the top cell datastructure of Var is not live.
             % If Sharing is top, then everything should automatically
             % be considered live, hence no reuse possible.
Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.189
diff -u -r1.189 type_util.m
--- compiler/type_util.m	22 Jan 2008 15:06:17 -0000	1.189
+++ compiler/type_util.m	30 Jan 2008 00:39:04 -0000
@@ -231,8 +231,12 @@
 :- pred is_existq_cons(module_info::in, mer_type::in, cons_id::in) is semidet.
 
     % Check whether a type is a no_tag type (i.e. one with only one
-    % constructor, and whose one constructor has only one argument),
-    % and if so, return its constructor symbol and argument type.
+    % constructor, and whose one constructor has only one argument).
+    %
+:- pred type_is_no_tag_type(module_info::in, mer_type::in) is semidet.
+
+    % As above, but return the constructor symbol and argument type on
+    % success.
     %
 :- pred type_is_no_tag_type(module_info::in, mer_type::in, sym_name::out,
     mer_type::out) is semidet.
@@ -970,6 +974,9 @@
 
 %-----------------------------------------------------------------------------%
 
+type_is_no_tag_type(ModuleInfo, Type) :-
+    type_is_no_tag_type(ModuleInfo, Type, _Ctor, _ArgType).
+
 type_is_no_tag_type(ModuleInfo, Type, Ctor, ArgType) :-
     type_to_ctor_and_args(Type, TypeCtor, TypeArgs),
     module_info_get_no_tag_types(ModuleInfo, NoTagTypes),

--------------------------------------------------------------------------
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