[m-dev.] for review: fix bug in inter-module optimization

Simon Taylor stayl at cs.mu.OZ.AU
Fri Jan 28 16:46:39 AEDT 2000


 
> Could you explain the XXX comment a bit more?
> Why won't it work in that case?

Done.

> It would be a good idea to add a test case for the
> problem that the XXX comment is talking about,
> even if we don't pass it yet.

Done.
 
> If that XXX is really causing a bug, I think it would
> be important to fix the bug.

It's not.

> > +check_foo(Foo) :- Foo = Foo.
> 
> I suggest you make that
> 
> 	check_foo(Foo, Bar) :- Foo = Bar.

Done.


--- intermod.m	2000/01/28 04:58:39	1.2
+++ intermod.m	2000/01/28 05:36:23
@@ -962,8 +962,11 @@
 		TypeBody = du_type(Ctors, Tags, Enum, yes(UserEq)),
 		hlds_data__set_type_defn_body(TypeDefn0, TypeBody, TypeDefn),
 
-		% XXX this won't work if the predicate is
-		% exported to sub-modules.
+		% XXX If the predicate is exported to sub-modules, it
+		% won't be written to the `.opt' file. See the comments
+		% for intermod__add_proc.
+		% This doesn't cause problems because if there are
+		% sub-modules, nothing gets written to the `.opt' file.
 		intermod__add_proc(UserEqPredId, _, Info1, Info2)
 	    ;	
 		Info2 = Info1,
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.50
diff -u -u -r1.50 Mmakefile
--- Mmakefile	1999/12/03 12:55:21	1.50
+++ Mmakefile	2000/01/28 05:38:54
@@ -67,6 +67,8 @@
 	intermod_quote.m \
 	intermod_test.m \
 	intermod_typeclass.m \
+	intermod_user_equality.m \
+	intermod_user_equality_nested.m \
 	ite_to_disj.m \
 	lambda_inference.m\
 	lambda_instmap_bug.m \
@@ -197,6 +199,10 @@
 MCFLAGS-intermod_test2		= --intermodule-optimization
 MCFLAGS-intermod_typeclass	= --intermodule-optimization
 MCFLAGS-intermod_typeclass2	= --intermodule-optimization
+MCFLAGS-intermod_user_equality	= --intermodule-optimization
+MCFLAGS-intermod_user_equality2	= --intermodule-optimization
+MCFLAGS-intermod_user_equality_nested	= --intermodule-optimization
+MCFLAGS-intermod_user_equality_nested2	= --intermodule-optimization
 MCFLAGS-ite_to_disj		= --aditi
 MCFLAGS-livevals_seq		= -O5 --opt-space
 MCFLAGS-middle_rec_labels	= --middle-rec --no-follow-vars 
@@ -211,6 +217,7 @@
 
 # XXX mmake should automatically handle this dependency.
 intermod_nested_module2.date: intermod_nested_module2.date0
+intermod_user_equality_nested2.date: intermod_user_equality_nested2.date0
 
 check:	objs aditi_update.err
 
Index: tests/valid/intermod_user_equality_nested.m
===================================================================
RCS file: intermod_user_equality_nested.m
diff -N intermod_user_equality_nested.m
--- /dev/null	Fri Jan 28 16:37:45 2000
+++ intermod_user_equality_nested.m	Fri Jan 28 16:25:23 2000
@@ -0,0 +1,11 @@
+:- module intermod_user_equality_nested.
+
+:- interface.
+
+:- import_module intermod_user_equality_nested2.
+:- pred check_foo(foo::in, foo::in) is semidet.
+
+:- implementation.
+
+check_foo(Foo, Bar) :- Foo = Bar.
+
Index: tests/valid/intermod_user_equality_nested2.m
===================================================================
RCS file: intermod_user_equality_nested2.m
diff -N intermod_user_equality_nested2.m
--- /dev/null	Fri Jan 28 16:37:45 2000
+++ intermod_user_equality_nested2.m	Fri Jan 28 16:30:46 2000
@@ -0,0 +1,38 @@
+:- module intermod_user_equality_nested2.
+
+:- interface.
+
+:- type foo.
+
+:- typeclass class(T) where [
+	pred p(T::in, T::in) is semidet
+].
+
+:- instance class(foo).
+
+:- pred foo_field1(foo::in, int::out) is cc_nondet.
+
+	:- module intermod_user_equality_nested2__sub.
+
+	:- interface.
+
+	:- type bar
+		---> bar(foo).
+
+	:- end_module intermod_user_equality_nested2__sub.
+
+:- implementation.
+
+:- type foo
+	--->	ctor1(int, int)
+	;	ctor2(int, int)
+	where equality is foo_unify.
+
+:- instance class(foo) where [
+	pred(p/2) is foo_unify
+].
+
+:- pred foo_unify(foo::in, foo::in) is semidet.
+foo_unify(X, X).
+
+foo_field1(ctor1(X, _), X).
--------------------------------------------------------------------------
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