[m-dev.] diff: fix --no-special-preds bug

Simon Taylor stayl at cs.mu.OZ.AU
Fri Sep 1 20:53:58 AEDT 2000



Estimated hours taken: 1

Fix a bug which caused a code generator abort for some procedures
containing complicated in-in unifications. The problem was that
the type-infos added by simplify.m for the call to unify/2 were
not being added to the nonlocals set of the call. saved_vars.m
then removed the type-info variables because they were constants
local to the conjunction which were not used by any goal in the
conjunction. 

compiler/simplify.m:
	Make sure type-info variables constructed for a call
	to unify/2 are included in the non-locals of the call.

tests/valid/Mmakefile:
tests/valid/unify_typeinfo_bug.m:
	Test case.


Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.80
diff -u -u -r1.80 simplify.m
--- compiler/simplify.m	2000/08/09 07:47:48	1.80
+++ compiler/simplify.m	2000/09/01 00:01:30
@@ -1226,7 +1226,7 @@
 	is det.
 
 simplify__call_generic_unify(TypeInfoVar, XVar, YVar, ModuleInfo, Context,
-		GoalInfo, Call) :-
+		GoalInfo0, Call) :-
 	ArgVars = [TypeInfoVar, XVar, YVar],
 	module_info_get_predicate_table(ModuleInfo, PredicateTable),
 	mercury_public_builtin_module(MercuryBuiltin),
@@ -1245,6 +1245,9 @@
 	SymName = unqualified("unify"),
 	code_util__builtin_state(ModuleInfo, PredId, ProcId, BuiltinState),
 	CallContext = call_unify_context(XVar, var(YVar), Context),
+	goal_info_get_nonlocals(GoalInfo0, NonLocals0),
+	set__insert(NonLocals0, TypeInfoVar, NonLocals),
+	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
 	Call = call(PredId, ProcId, ArgVars, BuiltinState, yes(CallContext),
 		SymName) - GoalInfo.
 
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.71
diff -u -u -r1.71 Mmakefile
--- tests/valid/Mmakefile	2000/08/19 23:54:44	1.71
+++ tests/valid/Mmakefile	2000/09/01 09:45:42
@@ -140,6 +140,7 @@
 	type_inf_ambig_test.m \
 	unbound_tvar_in_lambda.m \
 	undead_proc.m \
+	unify_typeinfo_bug.m \
 	uniq_unify.m \
 	uniq_mode_inf_bug.m \
 	unreachable_code.m \
@@ -248,6 +249,7 @@
 MCFLAGS-simplify_bug		= -O-1
 MCFLAGS-two_way_unif		= -O-1
 MCFLAGS-type_inf_ambig_test	= --infer-all
+MCFLAGS-unify_typeinfo_bug	= -O3 --no-special-preds
 MCFLAGS-uniq_mode_inf_bug	= --infer-all
 MCFLAGS-vn_float		= -O5
 MCFLAGS-zero_arity		= --infer-modes
Index: tests/valid/unify_typeinfo_bug.m
===================================================================
RCS file: unify_typeinfo_bug.m
diff -N unify_typeinfo_bug.m
--- /dev/null	Fri Sep  1 20:19:01 2000
+++ unify_typeinfo_bug.m	Fri Sep  1 20:44:27 2000
@@ -0,0 +1,27 @@
+:- module unify_typeinfo_bug.
+
+:- interface.
+
+:- import_module list, map.
+
+:- type t
+	---> t(map(int, string), list(int)).
+
+:- pred unify_t(t, t).
+:- mode unify_t(in, in) is semidet.
+
+:- implementation.
+
+:- import_module std_util.
+
+unify_t(t(A1, B1), t(A2, B2)) :-
+	unify_map(A1, A2),
+	B1 = B2.
+
+:- pred unify_map(map(int, string), map(int, string)).
+:- mode unify_map(in, in) is semidet.
+
+unify_map(A, B) :-
+	univ(A) = univ(B).
+
+
--------------------------------------------------------------------------
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