[m-rev.] [reuse] no reuse of no-tag cons'es

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Mon Apr 23 22:46:31 AEST 2001


Hi,


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


Estimated hours taken: 1
Branches: reuse

Bugfix: do not try to reuse no-tag types. 

sr_choice.m:
sr_direct.m:
	Explicitly check whether the cons you want to reuse is a no_tag
	cons. If so, no reuse is possible. 


Index: sr_choice.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_choice.m,v
retrieving revision 1.1.2.20
diff -u -r1.1.2.20 sr_choice.m
--- sr_choice.m	2001/04/20 15:23:24	1.1.2.20
+++ sr_choice.m	2001/04/23 12:32:00
@@ -42,7 +42,7 @@
 	.
 
 :- pred sr_choice__process_goal(strategy::in, vartypes::in, module_info::in,
-		hlds_goal::in, hlds_goal::out,
+		proc_info::in, hlds_goal::in, hlds_goal::out,
 		maybe(list(reuse_condition))::out) is det.
 :- pred get_strategy(strategy::out, module_info::in, module_info::out,
 		io__state::di, io__state::uo) is det.
@@ -57,10 +57,11 @@
 :- import_module assoc_list, bool, globals, int. 
 :- import_module map, multi_map, options, require, set.
 
-process_goal(Strategy, VarTypes, ModuleInfo,
+process_goal(Strategy, VarTypes, ModuleInfo, ProcInfo, 
 		Goal0, Goal, MaybeReuseConditions) :-
 	Strategy = strategy(Constraint, SelectionRule),
-	apply_constraint(Constraint, VarTypes, ModuleInfo, Goal0, Goal1),
+	apply_constraint(Constraint, VarTypes, ModuleInfo, ProcInfo, 
+			Goal0, Goal1),
 	select_reuses(SelectionRule, Goal1, Goal2, ReusedVars, ReuseConditions),
 	determine_cgc(ReusedVars, Goal2, Goal),
 	( ReuseConditions = [] ->
@@ -76,6 +77,7 @@
 			map		:: multi_map(prog_var,
 							reuse_cell_data),
 			module_info	:: module_info,
+			proc_info	:: proc_info, 
 			vartypes	:: vartypes
 		).
 
@@ -87,17 +89,17 @@
 		).
 
 :- pred constraint_info_init(vartypes::in, module_info::in,
-		constraint_info::out) is det.
+		proc_info::in, constraint_info::out) is det.
 
-constraint_info_init(VarTypes, ModuleInfo,
-		constraint_info(Map, ModuleInfo, VarTypes)) :-
+constraint_info_init(VarTypes, ModuleInfo, ProcInfo, 
+		constraint_info(Map, ModuleInfo, ProcInfo, VarTypes)) :-
 	multi_map__init(Map).
 
 :- pred apply_constraint(constraint::in, vartypes::in, module_info::in,
-		hlds_goal::in, hlds_goal::out) is det.
+		proc_info::in, hlds_goal::in, hlds_goal::out) is det.
 
-apply_constraint(Constraint, VarTypes, ModuleInfo, Goal0, Goal) :-
-	constraint_info_init(VarTypes, ModuleInfo, ConstraintInfo),
+apply_constraint(Constraint, VarTypes, ModuleInfo, ProcInfo, Goal0, Goal) :-
+	constraint_info_init(VarTypes, ModuleInfo, ProcInfo, ConstraintInfo),
 	apply_constraint_2(Constraint, Goal0, Goal, ConstraintInfo, _).
 
 :- pred apply_constraint_2(constraint::in, hlds_goal::in, hlds_goal::out,
@@ -229,11 +231,16 @@
 		)}
 	;
 		{ Constraint = within_n_cells_difference(Difference) },
+		ProcInfo =^ proc_info,
+		ModuleInfo =^ module_info, 
 
 			% XXX recode this more efficiently at some stage.
 		{ P = (pred(Candidate::out) is nondet :- 
 			list__member(Candidate0, PossibleCandidates),
 			CandidateVar = Candidate0 ^ var,
+			
+			\+ no_tag_type(CandidateVar, ModuleInfo, ProcInfo),
+
 			multi_map__search(Map, CandidateVar, CandidateData),
 			ConsIds = list__remove_dups(
 					list__map((func(D) = D ^ cons_id),
@@ -261,6 +268,12 @@
 	{ goal_info_set_reuse(GoalInfo0,
 			choice(construct(set__list_to_set(Candidates))),
 			GoalInfo) }.
+
+:- pred no_tag_type(prog_var::in, module_info::in, proc_info::in) is semidet. 
+no_tag_type(Var, ModuleInfo, ProcInfo):- 
+	proc_info_vartypes(ProcInfo, VarTypes), 
+	map__lookup(VarTypes, Var, VarType), 
+	type_is_no_tag_type(ModuleInfo, VarType, _, _). 
 
 apply_constraint_unification(_Constraint, Unif, GoalInfo, GoalInfo) -->
 	{ Unif = deconstruct(Var, ConsId, Vars, _Modes, _CanFail, _CanCGC) },
Index: sr_direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_direct.m,v
retrieving revision 1.1.2.13
diff -u -r1.1.2.13 sr_direct.m
--- sr_direct.m	2001/03/23 10:41:30	1.1.2.13
+++ sr_direct.m	2001/04/23 12:32:00
@@ -66,7 +66,7 @@
 	sr_choice__get_strategy(Strategy, ModuleInfo0, ModuleInfo),
 	{ proc_info_vartypes(ProcInfo0, VarTypes) },
 	{ sr_choice__process_goal(Strategy, VarTypes, ModuleInfo,
-			Goal1, Goal, MaybeReuseConditions) },
+			ProcInfo0, Goal1, Goal, MaybeReuseConditions) },
 	(
 		{ VeryVerbose = yes } 
 	->
--------------------------------------------------------------------------
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