[m-dev.] diff: fix bug handling imported Aditi preds

Simon Taylor stayl at cs.mu.OZ.AU
Thu Apr 6 15:34:41 AEST 2000



Estimated hours taken: 1

compiler/make_hlds.m:
	Enable the Aditi passes even if there are only imported
	Aditi procedures. Without this change, magic.m was
	not being called to remove the `aditi' markers from
	the imported predicates, resulting in arg_infos not being
	computed for them.

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


Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.329
diff -u -u -r1.329 make_hlds.m
--- compiler/make_hlds.m	2000/04/05 06:28:17	1.329
+++ compiler/make_hlds.m	2000/04/06 02:00:27
@@ -569,33 +569,29 @@
 
 %-----------------------------------------------------------------------------%
 
-	% If there are local, exported or opt_imported Aditi procedures
-	% enable Aditi compilation. opt_imported procedures which are not
-	% specialised will be made imported by dead_proc_elim.m, and
-	% having Aditi compilation enabled for them will be harmless.
+	% If there are any Aditi procedures enable Aditi compilation.
+	% If there are only imported Aditi procedures, magic.m still
+	% needs to remove the `aditi' and `base_relation' markers
+	% so that the procedures are not ignored by the code
+	% generation annotation passes (e.g. arg_info.m).
 :- pred maybe_enable_aditi_compilation(item_status, term__context,
 		module_info, module_info, io__state, io__state).
 :- mode maybe_enable_aditi_compilation(in, in, in, out, di, uo) is det.
 
-maybe_enable_aditi_compilation(Status, Context, Module0, Module) -->
-	{ Status = item_status(ItemStatus, _) },
-	( { ItemStatus \= imported(_) } ->
-		globals__io_lookup_bool_option(aditi, Aditi),
-		( { Aditi = no } ->
-			prog_out__write_context(Context),
-			io__write_string("Error: compilation of Aditi procedures\n"),
-			prog_out__write_context(Context),
-			io__write_string("  requires the `--aditi' option.\n"),
-			io__set_exit_status(1),
-			{ module_info_incr_errors(Module0, Module) }
-		;
-			% There are local Aditi procedures - enable Aditi
-			% code generation.
-			{ module_info_set_do_aditi_compilation(Module0,
-				Module) }
-		)
+maybe_enable_aditi_compilation(_Status, Context, Module0, Module) -->
+	globals__io_lookup_bool_option(aditi, Aditi),
+	( { Aditi = no } ->
+		prog_out__write_context(Context),
+		io__write_string("Error: compilation of Aditi procedures\n"),
+		prog_out__write_context(Context),
+		io__write_string("  requires the `--aditi' option.\n"),
+		io__set_exit_status(1),
+		{ module_info_incr_errors(Module0, Module) }
 	;
-		{ Module = Module0 }
+		% There are local Aditi procedures - enable Aditi
+		% code generation.
+		{ module_info_set_do_aditi_compilation(Module0,
+			Module) }
 	).
 
 %-----------------------------------------------------------------------------%
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmakefile,v
retrieving revision 1.59
diff -u -u -r1.59 Mmakefile
--- tests/valid/Mmakefile	2000/04/05 06:11:36	1.59
+++ tests/valid/Mmakefile	2000/04/06 02:32:03
@@ -28,6 +28,7 @@
 
 OTHER_SOURCES= \
 	base_relation.m \
+	base_relation2.m \
 	common_struct_bug.m \
 	compl_unify_bug.m \
 	complicated_unify.m \
@@ -188,6 +189,7 @@
 
 MCFLAGS-aditi_update		= --aditi
 MCFLAGS-base_relation		= --aditi
+MCFLAGS-base_relation2		= --aditi
 MCFLAGS-compl_unify_bug		= -O3
 MCFLAGS-context_anc		= --aditi
 MCFLAGS-deforest_loop		= -O3 --intermodule-optimization
Index: tests/valid/base_relation2.m
===================================================================
RCS file: base_relation2.m
diff -N base_relation2.m
--- /dev/null	Thu Apr  6 15:26:10 2000
+++ base_relation2.m	Thu Apr  6 15:26:51 2000
@@ -0,0 +1,25 @@
+%-----------------------------------------------------------------------------%
+% File: base_relation2.m
+% Author: stayl
+%
+% Test calling an imported Aditi procedure from a module containing
+% no Aditi procedures -- the compiler of 6/4/2000 aborted on this
+% test case because the `aditi' marker was not removed from the
+% imported procedure, resulting in arg_infos not being computed
+% for the imported procedure.
+%-----------------------------------------------------------------------------%
+:- module base_relation2.
+
+:- interface.
+
+:- import_module aditi.
+
+:- pred query(aditi__state::aditi_ui, int::in, int::out) is nondet.
+
+%-----------------------------------------------------------------------------%
+:- implementation.
+
+:- import_module base_relation.
+
+query(DB, X, Y) :-
+	base(DB, X, Y).
--------------------------------------------------------------------------
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