[m-dev.] [reuse] diff: don't do structure_reuse on nonimported procs

Peter Ross petdr at miscrit.be
Wed Oct 11 22:03:27 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 7

Fix a bug where structure_reuse was being run on the special preds.

passes_aux.m:
    Change process_matching_nonimported_procs so that its filter
    predicate takes two arguments: the pred_id and pred_info when
    deciding whether to process a proc.

structure_reuse.m:
    Don't run structure_reuse on the special preds.

magic.m:
    Change to reflect the new signature of process_matching_nonimported_procs.


Index: magic.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.23
diff -u -r1.23 magic.m
--- magic.m	2000/09/07 01:46:29	1.23
+++ magic.m	2000/10/11 10:59:55
@@ -190,8 +190,9 @@
 	{ simplify__find_simplifications(no, Globals, Simplifications) },
 	process_matching_nonimported_procs(
 		update_module_io(
-			magic__ite_to_disj_and_simplify(Simplifications)),
-		_, hlds_pred__pred_info_is_aditi_relation,
+			magic__ite_to_disj_and_simplify(Simplifications)), _,
+		(pred(_PredId::in, PredInfo::in) is semidet :-
+			hlds_pred__pred_info_is_aditi_relation(PredInfo)),
 		ModuleInfo0, ModuleInfo1),
 
 	% We need to run dead_proc_elim before working out the
Index: passes_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.37
diff -u -r1.37 passes_aux.m
--- passes_aux.m	2000/08/08 04:44:47	1.37
+++ passes_aux.m	2000/10/11 10:59:55
@@ -110,15 +110,15 @@
 :- mode process_all_nonimported_procs(task, in, out, di, uo) is det.
 
 	% Process procedures for which a given test succeeds.
-:- pred process_matching_nonimported_procs(task, pred(pred_info),
+:- pred process_matching_nonimported_procs(task, pred(pred_id, pred_info),
 	module_info, module_info, io__state, io__state).
-:- mode process_matching_nonimported_procs(task, pred(in) is semidet,
+:- mode process_matching_nonimported_procs(task, pred(in, in) is semidet,
 	in, out, di, uo) is det.
 
-:- pred process_matching_nonimported_procs(task, task, pred(pred_info),
+:- pred process_matching_nonimported_procs(task, task, pred(pred_id, pred_info),
 	module_info, module_info, io__state, io__state).
 :- mode process_matching_nonimported_procs(task, out(task),
-	pred(in) is semidet, in, out, di, uo) is det.
+	pred(in, in) is semidet, in, out, di, uo) is det.
 
 :- pred process_all_nonimported_nonaditi_procs(task, module_info, module_info,
 	io__state, io__state).
@@ -176,12 +176,12 @@
 :- import_module int, map, tree234, require, string.
 
 process_all_nonimported_procs(Task, ModuleInfo0, ModuleInfo) -->
-	{ True = lambda([_PredInfo::in] is semidet, true) },
+	{ True = lambda([_PredId::in, _PredInfo::in] is semidet, true) },
 	process_matching_nonimported_procs(Task, True, 
 		ModuleInfo0, ModuleInfo).
 
 process_all_nonimported_nonaditi_procs(Task, ModuleInfo0, ModuleInfo) -->
-	{ NotAditi = lambda([PredInfo::in] is semidet, (
+	{ NotAditi = lambda([_PredId::in, PredInfo::in] is semidet, (
 			\+ hlds_pred__pred_info_is_aditi_relation(PredInfo)
 		)) }, 
 	process_matching_nonimported_procs(Task, NotAditi, 
@@ -189,14 +189,14 @@
 
 process_all_nonimported_nonaditi_procs(Task0, Task,
 		ModuleInfo0, ModuleInfo) -->
-	{ NotAditi = lambda([PredInfo::in] is semidet, (
+	{ NotAditi = lambda([_PredId::in, PredInfo::in] is semidet, (
 			\+ hlds_pred__pred_info_is_aditi_relation(PredInfo)
 		)) }, 
 	process_matching_nonimported_procs(Task0, Task, NotAditi, 
 		ModuleInfo0, ModuleInfo).
 
 process_all_nonimported_procs(Task0, Task, ModuleInfo0, ModuleInfo) -->
-	{ True = lambda([_PredInfo::in] is semidet, true) },
+	{ True = lambda([_PredId::in, _PredInfo::in] is semidet, true) },
 	process_matching_nonimported_procs(Task0, Task, True, 
 		ModuleInfo0, ModuleInfo).
 
@@ -216,17 +216,17 @@
 	process_nonimported_procs_in_preds(PredIds, Task0, Task, Filter,
 		ModuleInfo0, ModuleInfo).
 
-:- pred process_nonimported_pred(pred_error_task, pred(pred_info), pred_id, 
-	module_info, module_info, io__state, io__state).
-:- mode process_nonimported_pred(in(pred_error_task), pred(in) is semidet, in,
-	in, out, di, uo) is det.
+:- pred process_nonimported_pred(pred_error_task, pred(pred_id, pred_info),
+	pred_id, module_info, module_info, io__state, io__state).
+:- mode process_nonimported_pred(in(pred_error_task), pred(in, in) is semidet,
+	in, in, out, di, uo) is det.
 
 process_nonimported_pred(Task, Filter, PredId, ModuleInfo0, ModuleInfo,
 		IO0, IO) :-
 	module_info_pred_info(ModuleInfo0, PredId, PredInfo0),
 	(
 		( pred_info_is_imported(PredInfo0)
-		; \+ call(Filter, PredInfo0)
+		; \+ call(Filter, PredId, PredInfo0)
 		)
 	->
 		ModuleInfo = ModuleInfo0,
@@ -241,9 +241,10 @@
 	).
 
 :- pred process_nonimported_procs_in_preds(list(pred_id), task, task,
-	pred(pred_info), module_info, module_info, io__state, io__state).
+	pred(pred_id, pred_info), module_info, module_info,
+	io__state, io__state).
 :- mode process_nonimported_procs_in_preds(in, task, out(task), 
-	pred(in) is semidet, in, out, di, uo) is det.
+	pred(in, in) is semidet, in, out, di, uo) is det.
 
 process_nonimported_procs_in_preds([], Task, Task, _, ModuleInfo, ModuleInfo)
 		--> [].
@@ -251,7 +252,7 @@
 		ModuleInfo0, ModuleInfo) -->
 	{ module_info_preds(ModuleInfo0, PredTable) },
 	{ map__lookup(PredTable, PredId, PredInfo) },
-	( { call(Filter, PredInfo) } ->
+	( { call(Filter, PredId, PredInfo) } ->
 		{ pred_info_non_imported_procids(PredInfo, ProcIds) },
 		process_nonimported_procs(ProcIds, PredId, Task0, Task1,
 			ModuleInfo0, ModuleInfo1)
Index: structure_reuse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/structure_reuse.m,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 structure_reuse.m
--- structure_reuse.m	2000/10/04 13:00:08	1.1.2.1
+++ structure_reuse.m	2000/10/11 10:59:56
@@ -51,11 +51,18 @@
 :- implementation.
 
 :- import_module passes_aux, sr_direct, sr_indirect.
+:- import_module list, map.
 
 structure_reuse(HLDS0, HLDS) -->
+	{ module_info_get_special_pred_map(HLDS0, SpecialPredMap) },
+	{ map__values(SpecialPredMap, SpecialPredIds) },
+
 		% Do the direct reuse analysis phase.
-	process_all_nonimported_procs(
+	process_matching_nonimported_procs(
 			update_module_io(sr_direct__process_proc),
+			(pred(PredId::in, _PredInfo::in) is semidet :-
+				\+ list__member(PredId, SpecialPredIds)
+			),
 			HLDS0, HLDS1),
 
 		% Do the fixpoint computation to determine all the indirect

--------------------------------------------------------------------------
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