[m-dev.] for review: alias branch improvements [2/2]

David Overton dmo at cs.mu.OZ.AU
Wed Jul 28 14:57:01 AEST 1999


On Tue, 27 Jul, 1999 at 10:14:06AM EST, Simon Taylor wrote:
>  
> > On 26-Jul-1999, David Overton <dmo at cs.mu.OZ.AU> wrote:
> > > On Sun, Jul 25, 1999 at 12:28:52PM EST, Fergus Henderson wrote:
> > > > Is it an invariant that all initial insts of procedures will have no
> > > > alias substitutions on them, or are you just assuming that this predicate
> > > > won't be called for procedures whose initial insts have alias substitutions?
> > > 
> > > It is an invariant.  It also applies to the final insts from the
> > > proc_info argument_modes.
> 
> What about procedures introduced by mode inference or deforestation for
> which there are no declared argument modes?
> 

Yes, these procedures are currently not handled correctly.  Mode inference
on the alias branch currently has other problems as well -- e.g. the
inferred final insts are copied straight into the argument_modes
even though they will probably contain inst_keys from the procedure's
inst_table that do not occur in the argument_modes inst_table.

I will fix this up and commit it as a separate change.

Here is the relative diff addressing Fergus's most recent comments:

--- /home/pgrad/dmo/mer/cmp/br2/hlds_pred.m	Tue Jul 27 11:49:47 1999
+++ ./hlds_pred.m	Wed Jul 28 14:43:09 1999
@@ -1380,6 +1380,8 @@
 	--->	address_is_taken
 	;	address_is_not_taken.
 
+	% The argument_modes should not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_init(arity, list(type), argument_modes,
 	maybe(argument_modes), maybe(list(is_live)), maybe(determinism),
 	prog_context, is_address_taken, proc_info).
@@ -1386,6 +1388,8 @@
 
 :- mode proc_info_init(in, in, in, in, in, in, in, in, out) is det.
 
+	% The argument_modes should not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_set(maybe(determinism), prog_varset, map(prog_var, type),
 	list(prog_var), argument_modes, maybe(list(is_live)), hlds_goal,
 	prog_context, stack_slots, determinism, bool, list(arg_info),
@@ -1395,6 +1399,8 @@
 :- mode proc_info_set(in, in, in, in, in, in, in, in, in, in, in, in, in, in,
 	in, in, in, in, in, out) is det.
 
+	% The argument_modes should not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_create(prog_varset, map(prog_var, type), list(prog_var),
 	argument_modes, determinism, hlds_goal, prog_context,
 	type_info_varmap, typeclass_info_varmap, is_address_taken,
@@ -1444,9 +1450,13 @@
 :- pred proc_info_set_headvars(proc_info, list(prog_var), proc_info).
 :- mode proc_info_set_headvars(in, in, out) is det.
 
+	% The argument_modes returned do not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_argmodes(proc_info, argument_modes).
 :- mode proc_info_argmodes(in, out) is det.
 
+	% The argument_modes should not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_set_argmodes(proc_info, argument_modes, proc_info).
 :- mode proc_info_set_argmodes(in, in, out) is det.
 
@@ -1533,9 +1543,13 @@
 	proc_info).
 :- mode proc_info_set_typeclass_info_varmap(in, in, out) is det.
 
+	% The argument_modes returned do not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_maybe_declared_argmodes(proc_info, maybe(argument_modes)).
 :- mode proc_info_maybe_declared_argmodes(in, out) is det.
 
+	% The argument_modes returned do not depend on any instmap alias
+	% substitutions.
 :- pred proc_info_declared_argmodes(proc_info, argument_modes).
 :- mode proc_info_declared_argmodes(in, out) is det.
 
--- /home/pgrad/dmo/mer/cmp/br2/inst_match.m	Tue Jul 27 11:49:48 1999
+++ ./inst_match.m	Tue Jul 27 11:51:06 1999
@@ -640,6 +640,7 @@
 	%	alias_map to include new aliasing information.
 	%	InstA must be at least as aliased as InstB for the predicate
 	%	to succeed.
+	%	InstMapA is the instmap associated with InstA.
 
 :- pred inst_matches_aliasing(bool, inst, inst, instmap, alias_map, alias_map).
 :- mode inst_matches_aliasing(in, in, in, in, in, out) is semidet.
--- /home/pgrad/dmo/mer/cmp/br2/prog_data.m	Tue Jul 27 11:49:52 1999
+++ ./prog_data.m	Wed Jul 28 14:54:36 1999
@@ -747,13 +747,16 @@
 
 :- func inc_other_inst_id(other_inst_id) = other_inst_id.
 
-	% Apply an other_inst_is_sub substitution to an other_inst_id.
+	% Apply an other_inst_id_sub substitution to an other_inst_id
+	% from another procedure to allow it to be compared with
+	% other_inst_ids from this procedure.
 
 :- func other_inst_id_apply_sub(other_inst_id_sub, other_inst_id)
 		= other_inst_id.
 
-	% Create an other_inst_id_sub to be used for comparing other_inst_ids
-	% from different procedures.
+	% Create an other_inst_id_sub to be used by other_inst_id_apply_sub.
+	% The input other_inst_id should be the last other_inst_id used in the
+	% procedure.  
 
 :- func other_inst_id_create_sub(other_inst_id) = other_inst_id_sub.
 
@@ -947,6 +950,6 @@
 
 other_inst_id_apply_sub(Sub, Id0) = Id0 + Sub.
 
-other_inst_id_create_sub(Id) = Id.
+other_inst_id_create_sub(Id) = Id + 1.
 
 %-----------------------------------------------------------------------------%
--- /home/pgrad/dmo/mer/cmp/br2/unify_proc.m	Tue Jul 27 11:49:57 1999
+++ ./unify_proc.m	Tue Jul 27 12:48:55 1999
@@ -381,12 +381,15 @@
 	% normalise_unify_id removes all unnecessary aliases and inst_table
 	% entries from the unify_proc_id.
 	% Aliases are retained only between corresponding nodes in the
-	% inst trees of the two arguments.  Such aliases allow us to
-	% produce more efficient code for the unification procedure
-	% since, if we know that two corresponding nodes are already
-	% aliased, we don't need to produce code to unify them.
-	% (In such cases the unification goal will be replaced by conj([])
-	% during mode checking by categorize_unify_var_var).
+	% inst trees of the two arguments.
+	% This is required in order to ensure that the unification
+	% procedure has the correct determinism.
+	% Such aliases also allow us to produce more efficient code for
+	% the unification procedure since, if we know that two
+	% corresponding nodes are already aliased, we don't need to
+	% produce code to unify them. (In such cases the unification
+	% goal will be replaced by conj([]) during mode checking by
+	% categorize_unify_var_var).
 
 	% normalise_unify_id also removes any instmap alias substitution
 	% dependencies from the insts.  This is important since these are
-- 
David Overton       Department of Computer Science & Software Engineering
MEngSc Student      The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list