[m-dev.] diff: bug fixes for the existential_types_2 branch

David Glen JEFFERY dgj at cs.mu.OZ.AU
Thu Jul 1 15:58:08 AEST 1999


On 12-Jun-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 8
> 
> Various changes to fix test case failures in the existential_types_2
> branch.
> 
> compiler/simplify.m:
> 	Delete a bogus sanity check that I had added, since the check
> 	was failing even in cases which made perfect sense.
> 	(This one was stopping the compiler from bootstrapping.)
> 
> 	Delete an obsolete XXX comment about something that has already
> 	been fixed.
> 
> 	When converting polymorphic complicated unifications into
> 	calls to unification procedures, we need to insert the
> 	type_info variables into the goal_info non-locals set.
> 
> compiler/simplify.m:
> compiler/det_report.m:
> 	Fix a couple of old XXXs: issue warnings when optimizing away
> 	goals with determinism failure or det goals that have no outputs.
> 	This is needed to ensure that we still issue a warning for several
> 	of the goals in tests/warnings/simple_code.m.  The previous
> 	warnings were no longer being issued because this optimization was
> 	optimization away the relevant code before it could be warned about.
> 
> tests/warnings/simple_code.exp:
> 	Update to reflect the new warnings.
> 
> compiler/dependency_graph.m:
> 	Don't include imported modes of pseudo_imported predicates
> 	(i.e. (in,in) modes of unification predicates) in the dependency
> 	graph.  The treatment of pseudo_imported predicates in
> 	dependency_graph.m needs to match the way they are treated
> 	by polymorphism.m and other parts of the compiler.
> 
> compiler/polymorphism.m:
> 	Update the headvars field of the proc_info for imported procedures
> 	to include the type_info variables.  This is necessary because
> 	some parts of the compiler (e.g. unused_args.m) depend on the
> 	headvars field being valid even for imported procedures.
> 
> 	Also fix a bug introduced in my changes to polymorphism.m -- I was
> 	passing down the wrong HeadVars to polymorphism__produce_existq_tvars.
> 
> compiler/post_typecheck.m:
> compiler/purity.m:
> 	Ensure that we always bind any unbound type variables to `void'
> 	before running polymorphism, even if there were type errors.
> 	This avoids some internal errors in polymorphism.m.
> 
> compiler/mercury_compile.m:
> 	Fix a formatting error in one of the progress messages.
> 
> compiler/modes.m:
> compiler/unique_modes.m:
> 	Ensure that mode analysis always stops analysing things once the
> 	instmap becomes unreachable.  It already did this for conjunctions,
> 	most of the time, but there were several other cases
> 	(if-then-elses and switches) where it did not.
> 	The aim of this change is to stop mode inference from creating
> 	modes for procedures with initial insts `not_reached'.
> 	
> compiler/modecheck_unify.m:
> 	Handle the case where an unification is initially inferred as
> 	a non-complicated unification, and then gets re-modechecked
> 	with the instmap being unreachable.  The code here was assuming
> 	that a non-complicated unification can never get turned into
> 	a complicated unification on re-modechecking, but `not_reached'
> 	unifications where being classified as complicated.
> 	The above change to modes.m and unique_modes.m should avoid this
> 	situation, but I thought it was safest to fix the code here too,
> 	just in case.
> 
> compiler/modes.m:
> compiler/modecheck_call.m:
> compiler/mode_util.m:
> 	Pass the type down to normalise_inst and ensure that for type_info
> 	types, it never return a unique inst.  The aim is to stop mode
> 	inference from inferring unique modes for the type_info arguments
> 	introduce by polymorphism.m, since unique modes are never useful
> 	for those arguments, and allowing mode inference to infer
> 	unique modes for them leads to it inferring unnecessarily many modes.
> 
> 	(Without this change, the test case tests/valid/uniq_mode_inf_bug.m
> 	fails, due to a bug in the existing mode inference stuff unrelated 
> 	to my polymorphism / existential types changes.  The bug is that
> 	modecheck_queued_procs needs to run ordinary mode analysis to a
> 	fixpoint before running determinism analysis, etc.)
> 
> tests/hard_coded/Mmakefile:
> 	Fix a bug: compile lp.m with the same options as bigtest.m.
> 	Without this, bigtest was getting link errors due to unsatisfied
> 	symbols in lp.m.  The problem was due to bigtest.m being compiled
> 	with intermodule optimization, and lp.m being compiled without
> 	intermodule optimization.  This lead to bigtest.o containing
> 	inlined references to local routines in lp.m, but lp.o not exporting
> 	those symbols because intermodule optimization had not been enabled
> 	when it was compiled.




> -normalise_inst(Inst0, ModuleInfo, NormalisedInst) :-
> +normalise_inst(Inst0, Type, ModuleInfo, NormalisedInst) :-
>  	inst_expand(ModuleInfo, Inst0, Inst),
>  	( Inst = bound(_, _) ->
>  		(
>  			inst_is_ground(ModuleInfo, Inst),
> -			inst_is_unique(ModuleInfo, Inst)
> +			inst_is_unique(ModuleInfo, Inst),
> +			% don't infer unique modes for introduced type_infos
> +			% arguments, because that leads to an increase

s/type_infos/type_info

> Index: compiler/modes.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
> retrieving revision 1.230.2.1
> diff -u -r1.230.2.1 modes.m
> --- modes.m	1999/06/10 16:10:38	1.230.2.1
> +++ modes.m	1999/06/12 00:42:26

> @@ -1038,7 +1050,10 @@
>  
>  modecheck_goal_expr(call(PredId, ProcId0, Args0, _, Context, PredName),
>  		GoalInfo0, Goal) -->
> -	mode_checkpoint(enter, "call"),
> +	/*** CallString = "call" ***/
> +	{ prog_out__sym_name_to_string(PredName, PredNameString) },
> +	{ string__append("call ", PredNameString, CallString) },
> +	mode_checkpoint(enter, CallString),

I think that comment should be deleted.

> Index: compiler/polymorphism.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
> retrieving revision 1.163.2.1
> diff -u -r1.163.2.1 polymorphism.m
> --- polymorphism.m	1999/06/10 16:10:42	1.163.2.1
> +++ polymorphism.m	1999/06/12 00:42:26
> @@ -610,7 +610,7 @@
>  
>  	clauses_info_clauses(ClausesInfo0, Clauses0),
>  	list__map_foldl(polymorphism__process_clause(PredInfo0,
> -				HeadVars, UnconstrainedTVars,
> +				HeadVars0, HeadVars, UnconstrainedTVars,
>  				ExtraTypeInfoHeadVars,
>  				ExistTypeClassInfoHeadVars),
>  			Clauses0, Clauses, PolyInfo1, PolyInfo),
> @@ -627,17 +627,17 @@
>  				HeadVars, Clauses,
>  				TypeInfoMap, TypeClassInfoMap).
>  
> -:- pred polymorphism__process_clause(pred_info, list(prog_var), list(tvar),
> -		list(prog_var), list(prog_var),
> +:- pred polymorphism__process_clause(pred_info, list(prog_var), list(prog_var),
> +		list(tvar), list(prog_var), list(prog_var),
>  		clause, clause,	poly_info, poly_info).
> -:- mode polymorphism__process_clause(in, in, in, in, in,
> +:- mode polymorphism__process_clause(in, in, in, in, in, in,
>  		in, out, in, out) is det.
>  
> -polymorphism__process_clause(PredInfo, HeadVars, UnconstrainedTVars,
> +polymorphism__process_clause(PredInfo0, HeadVars0, HeadVars, UnconstrainedTVars,
>  			ExtraTypeInfoHeadVars, ExistTypeClassInfoHeadVars,
>  			Clause0, Clause) -->

I'm a little confused by this. Why do you pass in both HeadVars0 and HeadVars?
Seeing that they are both input args, I think better names could be chosen.

> Index: compiler/simplify.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
> retrieving revision 1.66.2.1
> diff -u -r1.66.2.1 simplify.m
> --- simplify.m	1999/06/10 16:10:50	1.66.2.1
> +++ simplify.m	1999/06/12 00:42:27
> @@ -310,7 +310,6 @@
>  		%
>  		% if --no-fully-strict,
>  		% replace goals with determinism failure with `fail'.
> -		% XXX we should warn about this (if the goal wasn't `fail')
>  		%
>  		Detism = failure,
>  		% ensure goal is pure or semipure
> @@ -319,16 +318,27 @@
>  		; code_aux__goal_cannot_loop(ModuleInfo, Goal0)
>  		)
>  	->
> +		% warn about this (if the goal wasn't `fail')
> +		goal_info_get_context(GoalInfo0, Context),
> +		(
> +			simplify_do_warn(Info0),
> +			Goal0 \= disj([], _) - _
> +		->
> +			simplify_info_add_msg(Info0,
> +				goal_cannot_succeed(Context), Info1)
> +		;
> +			Info1 = Info0
> +		),
> +		

This doesn't seem to be mentioned in the log message.

>  unique_modes__check_goal_2(call(PredId, ProcId0, Args, Builtin, CallContext,
>  		PredName), _GoalInfo0, Goal) -->
> -	mode_checkpoint(enter, "call"),
> +	/*** CallString = "call" ***/
> +	{ prog_out__sym_name_to_string(PredName, PredNameString) },
> +	{ string__append("call ", PredNameString, CallString) },
> +	mode_checkpoint(enter, CallString),

That comment looks strange too.

Other than that, it looks fine.


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
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