[m-dev.] for review: retain aliasing information when merging instmaps of branched goals

Simon Taylor stayl at cs.mu.OZ.AU
Thu Jan 28 16:41:41 AEDT 1999


David Overton wrote:
> 
> On Sun, Jan 24, 1999 at 03:02:07AM EST, Simon Taylor wrote:
> > 
> > What happens if a variable whose inst contains the only live reference to
> > an inst_key is passed into a branched goal, is assigned to another variable
> > within the branched goal and is dead after the branched goal?
> > The instmap after the branched goal should include the information that the
> > new and old variables are aliases.
> 
> The instmap can only contain this aliasing information if the
> assignment occurs in every branch.  E.g.,
 
> I had not allowed for this case.  I've included a relative diff for
> inst_util.m that will retain the Y - Z alias after the branched goal
> even if Y is dead.

Thanks.

> The other possibility is when an alias occurs only in one branch:
> 
> :- mode p(in, di, di, uo).
> 	
> p(X, A, B, C) :-
> 	(
> 		X = yes,
> 		C = A
> 	;
> 		X = no,
> 		C = B
> 	).
> 
> At the end of the first branch, C is aliased to A and at the end of
> the second branch C is aliased to B.  Inst_merge removes these aliases
> because they only occur in one branch.  However, because each inst_key
> is only referenced by only one live variable at the end of the branch,
> uniqueness is maintained.  (If A or B were still live after the
> branched goal then all 3 vars would become shared.)
> 
> My question is, after the disjunction do you need to know that A/B may
> _possibly_ be aliased to a live variable to ensure that the memory
> associated with them is not re-used?

Yes. Is it possible/correct to record A and B as `clobbered' after the
disjunction if the introduced aliasing is not the same in all branches
which could succeed? If so, then that would do the job. I don't think 
it's quite that simple, because all three variables could be made `shared'
later in the goal.

Simon.



More information about the developers mailing list