[m-rev.] Re: for review: default modes for higher-order func insts

David Overton dmo at cs.mu.OZ.AU
Thu Oct 11 17:37:48 AEST 2001


On Wed, Oct 10, 2001 at 03:37:36PM +1000, Fergus Henderson wrote:
> On 10-Oct-2001, David Overton <dmo at cs.mu.OZ.AU> wrote:
> > > > compiler/inst_match.m:
> > > > 	In 'inst_matches_initial' and 'inst_matches_final', ensure that higher
> > > > 	order inst information is not lost from non-standard function insts.
> > > > 	Also allow 'inst_matches_{initial,final,binding}' to succeed
> > > > 	where the first inst is a standard function inst and the
> > > > 	second is ground.
> > > 
> > > I think you should also add some comments to inst_is_ground explaining
> > > what it does for non-standard function insts, and why.  Currently it
> > > succeeds, which I think is the right thing for most callers, but not for
> > > all.  There is at least one place where this issue with inst_is_ground
> > > leads to a bug with your current diff because of somewhere that
> > > you didn't change.
> > 
> > done.
> 
> Could you be more specific?
> Do you mean you added the comments, or you fixed the bug, or both?
> Which place had the bug?

I added the comments and fixed a bug in normalise_inst which is
included in my previous diff.  A fix for the bug you pointed out in
pd_util.m is included below.  I have checked all other calls to
inst_is_ground and inst_is_ground_or_any and could not find any other
potential problems.

> 
> > > You need go through every call to inst_is_ground and see whether it
> > > is OK for each call to succeed for non-standard function insts.  This will
> > > require searching up the call graph in some cases (e.g. you'll need to
> > > look at all callers of mode_is_fully_input and mode_is_fully_output).
> > 
> > done.
> 
> Did you modify any of the callers of mode_is_fully_input or
> mode_is_fully_output?  I didn't see that in the relative diff.

I couldn't find problems with the callers to mode_is_fully_{input,output}.


diff -u tests/hard_coded/ho_func_default_inst.m tests/hard_coded/ho_func_default_inst.m
--- tests/hard_coded/ho_func_default_inst.m
+++ tests/hard_coded/ho_func_default_inst.m
@@ -27,11 +27,10 @@
 
 :- func map = map(int, t).
 
-map = (((map__init
+map = ((map__init
 		^ elem(1) := foo1)
 		^ elem(2) := foo2)
-		^ elem(3) := foo3)
-		^ elem(4) := foo4.
+		^ elem(3) := foo3.
 
 :- pred write_func(t, io, io) is det.
 :- mode write_func(func(in) = out is det, di, uo) is det.
@@ -53,8 +52,3 @@
 :- mode foo3(in) = out(one) is det.
 
 foo3(_) = 1.
-
-:- func foo4(int) = int.
-:- mode foo4(in(one)) = out is det.
-
-foo4(1) = 4.
only in patch2:
--- compiler/pd_util.m	11 Aug 2001 14:09:50 -0000	1.15
+++ compiler/pd_util.m	11 Oct 2001 00:09:38 -0000
@@ -142,7 +142,7 @@
 :- import_module unused_args, inst_match, (inst), quantification, mode_util.
 :- import_module code_aux, purity, mode_info, unique_modes, pd_debug.
 :- import_module type_util, det_util, det_analysis, options, goal_util.
-:- import_module det_report.
+:- import_module det_report, inst_util.
 :- import_module assoc_list, int, require, set, term.
 
 pd_util__goal_get_calls(Goal0, CalledPreds) :-
@@ -898,6 +898,8 @@
 			Uniq = unique,
 			inst_is_unique(ModuleInfo, bound(unique, List))
 		),		
+		\+ inst_contains_nonstandard_func_mode(bound(shared, List),
+			ModuleInfo),
 		Inst = ground(Uniq, none)
 	).
 

-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list