[m-rev.] diff: fix inter-module optimization bug

Simon Taylor stayl at cs.mu.OZ.AU
Mon Feb 17 17:12:34 AEDT 2003


Estimated hours taken: 2
Branches: main, release

Fix a bug in inter-mdule optimization reported by Michael Day.

compiler/intermod.m:
	Write declarations for `exported_to_submodules' predicates
	and functions to the `.opt' file.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/intermod_nested{,2}.m:
	Test case.


Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.125
diff -u -u -r1.125 intermod.m
--- compiler/intermod.m	7 Aug 2002 13:11:50 -0000	1.125
+++ compiler/intermod.m	17 Feb 2003 06:07:21 -0000
@@ -262,12 +262,20 @@
 			HigherOrderSizeLimit, Deforestation, ModuleInfo0) }
 	->
 		=(IntermodInfo0),
-		{ pred_info_typevarset(PredInfo0, TVarSet) },
-		{ clauses_info_vartypes(ClausesInfo0, VarTypes) },
+		% Write a declaration to the `.opt' file for
+		% `exported_to_submodules' predicates.
+		intermod__add_proc(PredId, DoWrite0),
 		{ clauses_info_clauses(ClausesInfo0, Clauses0) },
-		intermod_info_set_var_types(VarTypes),
-		intermod_info_set_tvarset(TVarSet),
-		intermod__traverse_clauses(Clauses0, Clauses, DoWrite),
+		( { DoWrite0 = yes } ->
+			{ clauses_info_vartypes(ClausesInfo0, VarTypes) },
+			{ pred_info_typevarset(PredInfo0, TVarSet) },
+			intermod_info_set_var_types(VarTypes),
+			intermod_info_set_tvarset(TVarSet),
+			intermod__traverse_clauses(Clauses0, Clauses, DoWrite)
+		;
+			{ Clauses = Clauses0 },
+			{ DoWrite = no }
+		),
 		( { DoWrite = yes } ->
 			{ clauses_info_set_clauses(ClausesInfo0, Clauses,
 				ClausesInfo) },
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.2.2.2
diff -u -u -r1.2.2.2 Mercury.options
--- tests/valid/Mercury.options	14 Jan 2003 13:50:27 -0000	1.2.2.2
+++ tests/valid/Mercury.options	17 Feb 2003 06:07:21 -0000
@@ -46,6 +46,8 @@
 MCFLAGS-intermod_impure2	= --intermodule-optimization
 MCFLAGS-intermod_lambda		= --intermodule-optimization
 MCFLAGS-intermod_lambda2	= --intermodule-optimization
+MCFLAGS-intermod_nested		= --intermodule-optimization
+MCFLAGS-intermod_nested2	= --intermodule-optimization
 MCFLAGS-intermod_nested_module	= --intermodule-optimization
 MCFLAGS-intermod_nested_module2	= --intermodule-optimization
 MCFLAGS-intermod_nested_module_bug = --intermodule-optimization
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.118.2.2
diff -u -u -r1.118.2.2 Mmakefile
--- tests/valid/Mmakefile	14 Jan 2003 13:50:27 -0000	1.118.2.2
+++ tests/valid/Mmakefile	17 Feb 2003 06:07:21 -0000
@@ -96,6 +96,7 @@
 	intermod_dcg_bug \
 	intermod_impure \
 	intermod_lambda \
+	intermod_nested \
 	intermod_nested_module \
 	intermod_nested_module_bug \
 	intermod_nested_uniq \
Index: tests/valid/intermod_nested.m
===================================================================
RCS file: tests/valid/intermod_nested.m
diff -N tests/valid/intermod_nested.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/intermod_nested.m	17 Feb 2003 06:07:21 -0000
@@ -0,0 +1,15 @@
+:- module intermod_nested.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io, io).
+:- mode main(di, uo) is det.
+
+:- implementation.
+
+:- import_module intermod_nested2.
+
+main --> [].
+
Index: tests/valid/intermod_nested2.m
===================================================================
RCS file: tests/valid/intermod_nested2.m
diff -N tests/valid/intermod_nested2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/intermod_nested2.m	17 Feb 2003 06:07:21 -0000
@@ -0,0 +1,22 @@
+:- module intermod_nested2.
+
+:- interface.
+
+	:- module intermod_nested2__bar.
+
+	:- interface.
+
+	:- type bar ---> bar.
+
+	:- end_module intermod_nested2__bar.
+
+:- implementation.
+
+:- import_module int.
+
+% Check that `exported_to_submodules' functions are declared
+% in the `.opt' file.
+:- func foo = int.
+
+foo = 1.
+
--------------------------------------------------------------------------
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