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

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 11 04:06:33 AEDT 1999


On 19-Jan-1999, David Overton <dmo at cs.mu.OZ.AU> wrote:
> Modify `instmap__merge' and `inst_merge' to preserve as much definite 
> aliasing information as possible rather than just throwing it all away 
> at the end of branched goals.
> 
> compiler/instmap.m:
> 	Modify `instmap__merge' to retain aliasing information.
> 	Algorithm:
> 	For each pair of final instmaps in a branched goal, 
> 		- Remove singleton inst_keys from each instmap.
> 		- Expand any inst_key substitutions that appear in one
> 		  instmap but not the other (done by `instmap__merge_subs').
> 		- Call inst_merge for each non-local variable. 
> 		- Work out which inst_keys need to become shared
> 		  and make them shared (uses information collected 
> 		  by calls to `inst_merge').
> 		- Recursively merge the resultant instmap with the
> 		  final instmap of the next branch.

That description should be included in a comment in the source code.

hlds_data.m:
> +:- type substitution_inst
> +	--->	substitution_inst(inst_name, inst_key_set, inst_key_sub).
> +
> +:- type inst_key_set == set_bbbtree(inst_key).

Some comments here about what these types are supposed to represent
would be helpful.  In particular, what is the meaning of the
threefields of a substitution_inst?

inst_util.m:
> +:- type merge_subs == map(pair(inst_key), inst_key).
> +:- type live_counts == pair(inst_key_counts).

Likewise here.

>  :- pred make_shared_inst(inst, unify_inst_info, inst, unify_inst_info).
> -:- mode make_shared_inst(in, in, out, out) is det.
> +:- mode make_shared_inst(in, in, out, out) is semidet.

It might be better to add an extra bool parameter
(or make it a function returning bool), so ensure that
next time we add a new alternative to the `inst' type, we
will get a compile error if we forget to add new clauses
to this predicate.

Apart from that, I didn't spot anything obviously wrong in your code,
but I didn't look at it in great detail.

Cheers,
	Fergus.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list