[m-rev.] [reuse] diff: bugfix, alias-sets were not minimal.

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Thu Jun 24 13:01:45 AEST 2004


Hi,


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


Estimated hours taken: 16
Branches: reuse

This change essentially fixes two bugs: 
	- aliases weren't normalized as they should be, therefore, a previous
	  change is undone, and normalization is again done explicitly after
	  the analysis of a procedure.
	- the alias-sets systematically contained mutually subsumed aliases.
	  E.g. we'd have sets {A^\epsilon-B^\epsilon, A^{el}-B^{\el}}, which is
	  equivalent to the minimal set {A^\epsilon-B^\epsilon}. 
	  Two reasons:
	  	1. the operation to combine aliases (extend) 'added' the
		partial results instead of using the least upper bound
		2. the least upper bound added the results to one of the
		initial sets. 

pa_alias_as.m:
	- bugfix, "extend_unification": normalize the aliases generated from
	  the unification before adding them to the existing set of aliases.
	- add an IO-threaded extend_unification version (handy when wanting to
	  be more verbose)
	- add 'print-brief-aliases', to print a subset of the actual alias-set

pa_alias_set.m:
	- bugfix, "extend": instead of adding the alias-sets computed from the
	  different alternating closures, they must be combined using the least
	  upper bound (to avoid mutually subsumed aliases in the result). 
	- bugfix, "least upper bound": at some point the result is added to one
	  of the initial alias sets, causing mutually subsumed aliases to be
	  present simultanuously in the computed final lub-set. 
	- "apply_widening": don't normalize (temporarely done in pa_run). 
	- add 'print-brief-aliases', to print a subset of the actual alias-set

pa_run.m:
	- bugfix: explicitly normalize the computed alias-sets for a procedure.
	- thread the io-state in the analyse_goal-procedures. 
	- use state variables in analyse_goal. 


Index: pa_alias_as.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_as.m,v
retrieving revision 1.1.2.34
diff -u -r1.1.2.34 pa_alias_as.m
--- pa_alias_as.m	11 Jun 2004 02:56:52 -0000	1.1.2.34
+++ pa_alias_as.m	24 Jun 2004 02:38:23 -0000
@@ -34,7 +34,11 @@
 :- pred is_bottom(alias_as::in) is semidet.
 
 :- pred top(string::in, alias_as::out) is det.
-:- pred top(alias_as::in, string::in, alias_as::out) is det.
+
+	% top(String, AliasIn, AliasOut). 
+	% Set the current alias to be Top. If the current alias is already
+	% top, add the string to the list of strings explaining that top. 
+:- pred top(string::in, alias_as::in, alias_as::out) is det.
 :- pred is_top(alias_as::in) is semidet.
 
 	% Compute the size of the set of pairs of aliased data structures as
@@ -158,6 +162,10 @@
 
 	% Specialized extend for unifications. This corresponds to the "add"
 	% operation used in Nancy's Phd-textbook. 
+:- pred extend_unification(module_info::in, proc_info::in, pred_info::in,
+		hlds_goal__unification::in, hlds_goal__hlds_goal_info::in, 
+		alias_as::in, alias_as::out, 
+		io__state::di, io__state::uo) is det.
 :- pred extend_unification(module_info::in, proc_info::in, 
 		hlds_goal__unification::in, hlds_goal__hlds_goal_info::in, 
 		alias_as::in, alias_as::out) is det.
@@ -223,6 +231,9 @@
 :- pred print_aliases(alias_as, proc_info, pred_info, io__state, io__state).
 :- mode print_aliases(in, in, in, di, uo) is det.
 
+:- pred print_brief_aliases(int::in, alias_as::in, proc_info::in,
+		pred_info::in, io__state::di, io__state::uo) is det.
+
 %-----------------------------------------------------------------------------%
 % Parsing routines. 
@@ -339,11 +350,11 @@
 	% string__append_list(["- ",Msg," -"],NewMsg).
 	NewMsg = Msg.
 
-top(Alias, Msg, top(Msgs)):-
+top(Msg, Alias, top(Msgs)):-
 	(
 		Alias = top(FirstMsgs)
 	->
-		Msgs = FirstMsgs
+		Msgs = [Msg|FirstMsgs]
 	;
 		Msgs = [Msg]
 	).
@@ -589,7 +600,10 @@
 extend_unification(HLDS, ProcInfo, Unif, GoalInfo, ASin, ASout):-
 	pa_alias__from_unification(HLDS, ProcInfo, Unif, GoalInfo, AUnif),
 	from_pair_alias_list(AUnif, AliasSetUnif), 
-	wrap(AliasSetUnif, ASUnif),
+	wrap(AliasSetUnif, ASUnif0),
+		% pa_alias__from_unification does not ensure that the created
+		% aliases are normalized, hence this must be explicitly done: 
+	normalize_wti(HLDS, ProcInfo, ASUnif0, ASUnif),
 	extend(HLDS, ProcInfo, ASUnif, ASin, ASout0), 
 	(
 		Unif = construct(_, _, _, _, _, _, _)
@@ -599,6 +613,31 @@
 		ASout = ASout0
 	).
 
+extend_unification(HLDS, ProcInfo, PredInfo, Unif, GoalInfo, ASin, ASout) --> 
+	{ pa_alias__from_unification(HLDS, ProcInfo, Unif, GoalInfo, AUnif) },
+	{ from_pair_alias_list(AUnif, AliasSetUnif) } ,
+	{ wrap(AliasSetUnif, ASUnif0) },
+		% pa_alias__from_unification does not ensure that the created
+		% aliases are normalized, hence this must be explicitly done: 
+	{ normalize_wti(HLDS, ProcInfo, ASUnif0, ASUnif) },
+	io__write_string("\n--> New aliases: "),
+	io__write_strings(["(size = ", 
+			int_to_string(pa_alias_as__size(ASUnif)), 
+			"/",
+			int_to_string(list__length(AUnif)),
+			") "]),
+	print_aliases(ASUnif, ProcInfo, PredInfo),
+	{
+	extend(HLDS, ProcInfo, ASUnif, ASin, ASout0), 
+	(
+		Unif = construct(_, _, _, _, _, _, _)
+	-> 
+		optimization_remove_deaths(ProcInfo, ASout0, GoalInfo, ASout)
+	;
+		ASout = ASout0
+	)}.
+
+
 :- pred optimization_remove_deaths(proc_info, alias_as, 
 					hlds_goal_info, alias_as).
 :- mode optimization_remove_deaths(in, in, in, out) is det.
@@ -927,6 +966,22 @@
 	->
 		io__write_string("["),
 		print(PredInfo, ProcInfo, Aliases, 
+				" ", ""),
+		io__write_string("]")
+	;
+		{ AS = top(_Msgs) }
+	->
+		io__write_string("top")
+	;
+		io__write_string("bottom")
+	).
+
+print_brief_aliases(Threshold, AS, ProcInfo, PredInfo) --> 
+	(
+		{ AS = real_as(Aliases) }
+	->
+		io__write_string("["),
+		print_brief(Threshold, PredInfo, ProcInfo, Aliases, 
 				" ", ""),
 		io__write_string("]")
 	;
Index: pa_alias_set.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_set.m,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 pa_alias_set.m
--- pa_alias_set.m	11 Jun 2004 02:56:52 -0000	1.1.2.12
+++ pa_alias_set.m	24 Jun 2004 02:38:24 -0000
@@ -117,6 +117,10 @@
 		string::in, string::in, 
 		io__state::di, io__state::uo) is det.
 
+:- pred print_brief(int::in, pred_info::in, proc_info::in, alias_set::in, 
+		string::in, string::in, 
+		io__state::di, io__state::uo) is det.
+
 	% print(PredInfo, ProcInfo, AliasSet, StartingString,
 	% MiddleString, EndString)
 	% Prints each alias as a parsable pair of datastructs. Each alias
@@ -126,6 +130,11 @@
 		string::in, string::in, string::in, 
 		io__state::di, io__state::uo) is det.
 
+:- pred print_brief(maybe(int)::in, pred_info::in, proc_info::in,
+		alias_set::in, string::in, 
+		string::in, string::in, 
+		io__state::di, io__state::uo) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -474,8 +483,10 @@
 	altclos_two(ModuleInfo, ProcInfo, OldNewAliasSet, NewAliasSet, 
 		_, FullNewOldNewAliasSet), 
 
+		% Compute the least upper bound of all the different
+		% alias-sets.
 	list__foldl(
-		add,
+		least_upper_bound(ModuleInfo, ProcInfo),
 		[ NewAliasSet, FullOldNewAliasSet, 
 		  FullNewOldNewAliasSet ], 
 		OldAliasSet, 
@@ -641,9 +652,8 @@
 	( 
 		Threshold \= 0
 	-> 
-		normalize(ModuleInfo, ProcInfo, AliasSet0, AliasSet01),
 		(
-			size(AliasSet01) > Threshold
+			size(AliasSet0) > Threshold
 		-> 
 			alias_set_map_values_with_key(
 				alias_set2_apply_widening(ModuleInfo, ProcInfo),
@@ -663,12 +673,36 @@
 print(PredInfo, ProcInfo, AliasSet, StartingString, EndString) -->
 	print(PredInfo, ProcInfo, AliasSet, StartingString, ", ", EndString).
 
+print_brief(Threshold, PredInfo, ProcInfo, AliasSet, 
+		StartingString, EndString) --> 
+	print_brief(yes(Threshold), PredInfo, ProcInfo, AliasSet, 
+		StartingString, ", ", EndString).
+
 print(PredInfo, ProcInfo, AliasSet, StartingString, MiddleString, 
 		EndString) --> 
+	print_brief(no, PredInfo, ProcInfo, AliasSet, 
+		StartingString, MiddleString, EndString).
+
+print_brief(MaybeThreshold, PredInfo, ProcInfo, AliasSet, 
+		StartingString, MiddleString, EndString) --> 
 	{ to_pair_alias_list(AliasSet, AliasList) },
-	io__write_list(AliasList, MiddleString, 
+	(
+		{ MaybeThreshold = yes(Limit) }
+ 	-> 
+		{ list__take_upto(Limit, AliasList, NewList) }
+	; 
+		{ NewList = AliasList }
+	),
+	io__write_list(NewList, MiddleString, 
 		pa_alias__print(ProcInfo, PredInfo, StartingString, 
-			EndString)).
+			EndString)),
+	(
+		{ MaybeThreshold = yes(_) }
+	-> 
+		io__write_string("...")
+	;
+		[]
+	).
 
 
 :- pred alias_set_fold(pred(alias_set2, alias_set2), 
@@ -929,9 +963,13 @@
 		Map0, 
 		Map1,
 		Map),
-	alias_set2_add(alias_sel_set(0,Map), SelectorSet0, SelectorSet).
+	alias_set2_recount(alias_sel_set(0,Map), SelectorSet).
+	% alias_set2_add(alias_sel_set(0,Map), SelectorSet0, SelectorSet).
 
-	% alias_set2_lub(ModuleInfo, Type, Pair, Map0, Map):-
+	% alias_set2_lub(ModuleInfo, Type, Selector, DataSet, Map0, Map):-
+	% Add the data set "Data Set" for the selector "Selector" into the 
+	% selectorset Map0 (type --> map(selector,dataset)).
+	
 	% Least upper bound between a real selectorset (Map0), and one
 	% single entry of another selectorset (Pair).
 	% precondition: the first selectorset is minimal (i.e., does
@@ -962,7 +1000,8 @@
 			data_set_add(DataSetA, DataSet, DataSetNew),
 			map__det_update(M1, Sel0, DataSetNew, M)
 		;	
-			map__det_insert(M1, Sel0, DataSet0, M)
+			% map__det_insert(M1, Sel0, DataSet0, M)
+			map__det_insert(M1, Sel0, DataSet, M)
 		)
 	).
 
@@ -1008,8 +1047,15 @@
 			data_set_difference(OtherDataSet0, 
 						FirstDataSet0TS, 
 						OtherDataSet), 
-			map__det_update(OtherMap0, OtherSel, OtherDataSet, 
-						OtherMap),
+			(
+				data_set_empty(OtherDataSet)
+			-> 
+				map__delete(OtherMap0, OtherSel, OtherMap)
+			;
+				map__det_update(OtherMap0, OtherSel, 
+						OtherDataSet, 
+						OtherMap)
+			),
 			FirstDataSet = FirstDataSet0
 		;
 			FirstDataSet = FirstDataSet0, 
Index: pa_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_run.m,v
retrieving revision 1.1.2.30
diff -u -r1.1.2.30 pa_run.m
--- pa_run.m	11 Jun 2004 06:01:15 -0000	1.1.2.30
+++ pa_run.m	24 Jun 2004 02:38:26 -0000
@@ -189,7 +189,7 @@
 	globals__io_lookup_bool_option(very_verbose,Verbose),
 	globals__io_lookup_int_option(possible_alias_widening, WideningLimit),
 
-	{ module_info_pred_proc_info(HLDS, PRED_PROC_ID,_PredInfo,
+	{ module_info_pred_proc_info(HLDS, PRED_PROC_ID, PredInfo,
 			ProcInfo_tmp) },
 
 	% XXX annotate all lbu/lfu stuff
@@ -230,18 +230,12 @@
 	(
 		{ predict_bottom_aliases(HLDS, ProcInfo) }
 	->
-		( 
-			{ Verbose = yes }
-		-> 
-			io__write_string("% bottom predicted")
-		; 
-			[]
-		),
+		maybe_write_string(Verbose, "% bottom predicted"),
 		{ Alias1 = Alias0 }, % = bottom 
 		{ FPtable1 = FPtable0 }
 	; 
-		{ analyse_goal(ProcInfo, HLDS, Goal, 
-			FPtable0, FPtable1, Alias0, Alias1) }
+		analyse_goal(ProcInfo, PredInfo, HLDS, Goal, 
+			FPtable0, FPtable1, Alias0, Alias1) 
 	),
 
 	{ 
@@ -250,8 +244,15 @@
 	pa_alias_as__project(HeadVars, Alias1, Alias2),
 	ProjectSize = pa_alias_as__size(Alias2),
 
+	Goal = _ - GoalInfo,
+	goal_info_get_instmap_delta(GoalInfo, InstMapDelta),
+	instmap__init_reachable(InitIM),
+	instmap__apply_instmap_delta(InitIM, InstMapDelta, InstMap),
+	pa_alias_as__normalize(HLDS, ProcInfo, InstMap, Alias2, Alias3),
+	NormSize = pa_alias_as__size(Alias3),
+
 	pa_alias_as__apply_widening(HLDS, ProcInfo, WideningLimit, 
-			Alias2, Alias, Widening),
+			Alias3, Alias, Widening),
 		
 	pa_fixpoint_table_new_as(HLDS, ProcInfo, 
 				PRED_PROC_ID, Alias, FPtable1, FPtable)
@@ -269,10 +270,12 @@
 			),
 			string__int_to_string(TabledSize, TabledS), 
 			string__int_to_string(FullSize, FullS), 
-			string__int_to_string(ProjectSize, ProjectS)
+			string__int_to_string(ProjectSize, ProjectS),
+			string__int_to_string(NormSize, NormS)
 		},
 		io__write_strings(["\t\t: ", TabledS, "->", 
-					FullS, "/", ProjectS, 
+					FullS, "/", ProjectS, "/",
+					NormS,
 					"(", Stable, ")"]), 
 		(
 			{ Widening = bool__yes }
@@ -323,19 +326,17 @@
 	% encountered).
 	% analyse_goal(ProcInfo, HLDS, Goal, TableIn, TableOut,
 	%		AliasIn, AliasOut).
-:- pred analyse_goal(proc_info, module_info, hlds_goal,
-				pa_fixpoint_table, pa_fixpoint_table,
-				alias_as, alias_as).
-:- mode analyse_goal(in, in, in, in, out, in, out) is det.
-
-analyse_goal(ProcInfo, HLDS, 
-		Goal, FPtable0, FPtable, Alias0, Alias) :- 
-
-	Goal = GoalExpr - GoalInfo ,
-	analyse_goal_expr(GoalExpr, GoalInfo, 
-				ProcInfo, HLDS, 
-				FPtable0, FPtable, Alias0, Alias1),
-
+:- pred analyse_goal(proc_info::in, pred_info::in, module_info::in, 
+		hlds_goal::in, pa_fixpoint_table::in, pa_fixpoint_table::out,
+		alias_as::in, alias_as::out, 
+		io__state::di, io__state::uo) is det.
+
+analyse_goal(ProcInfo, PredInfo, HLDS, Goal, FPtable0, FPtable, 
+		Alias0, Alias, !IO) :- 
+	Goal = GoalExpr - GoalInfo, 
+	analyse_goal_expr(GoalExpr, GoalInfo, ProcInfo, PredInfo, HLDS, 
+		FPtable0, FPtable, Alias0, Alias, !IO).
+/***
 	% extra: after the analysis of the current goal, 
 	% project the obtained alias-set (Alias1) to the set 
 	% LFUi + LBUi + HeadVars
@@ -349,34 +350,48 @@
 		pa_alias_as__project_on_live_vars(ProcInfo, GoalInfo, 
 				Alias1, Alias) 
 	).
+***/
 
 	
-:- pred analyse_goal_expr(hlds_goal_expr, 
-			   hlds_goal_info, 
-				proc_info, module_info, 
-				pa_fixpoint_table, pa_fixpoint_table,
-				alias_as, alias_as).
-:- mode analyse_goal_expr(in, in, in, in, in, out, in, out) is det.
-
-analyse_goal_expr(conj(Goals), _Info, ProcInfo, HLDS , T0, T, A0, A) :-
-	list__foldl2(analyse_goal(ProcInfo, HLDS),  Goals, 
-		T0, T, A0, A).
-
-analyse_goal_expr(call(PredID, ProcID, ARGS, _,_, _PName), _Info, 
-			ProcInfo, HLDS, T0, T, A0, A):- 
-	PRED_PROC_ID = proc(PredID, ProcID),
-	lookup_call_alias(PRED_PROC_ID, HLDS, T0, T, CallAlias), 
+:- pred analyse_goal_expr(hlds_goal_expr::in, hlds_goal_info::in, 
+		proc_info::in, pred_info::in, module_info::in, 
+		pa_fixpoint_table::in, pa_fixpoint_table::out,
+		alias_as::in, alias_as::out, 
+		io__state::di, io__state::uo) is det.
+
+analyse_goal_expr(conj(Goals), _Info, ProcInfo, PredInfo, 
+		HLDS , !Table, !Alias, !IO) :- 
+	list__foldl3(analyse_goal(ProcInfo, PredInfo, HLDS),  Goals, 
+		!Table, !Alias, !IO). 
+
+analyse_goal_expr(call(PredId, ProcId, ARGS, _,_, _PName), _Info, 
+		ProcInfo, _PredInfo, HLDS, !Table, !Alias, !IO) :- 
+% 	write_proc_progress_message("\n--> Call to ", 
+%			PredId, ProcId, HLDS, !IO),
+	PredProcId = proc(PredId, ProcId),
+	lookup_call_alias(PredProcId, HLDS, !Table, CallAlias),
+%	module_info_pred_info(HLDS, PredId, PredInfoLookedUp),
+%	io__write_string("--> Looked up aliases: ", !IO), 
+%	io__write_strings(["(size = ", int_to_string(size(CallAlias)), 
+%			") "], !IO),
+%	print_brief_aliases(5, CallAlias, ProcInfo, PredInfoLookedUp, !IO),
+%	io__write_string("\n--> Existing aliases: ", !IO),
+%	io__write_strings(["(size = ", int_to_string(size(!.Alias)), 
+%			") "], !IO),
+%	print_brief_aliases(5, !.Alias, ProcInfo, PredInfo, !IO),
+	
 	proc_info_vartypes(ProcInfo, VarTypes), 
-	list__map(
-		map__lookup(VarTypes), 
-		ARGS, 
-		ActualTypes),
-	rename_call_alias(PRED_PROC_ID, HLDS, ARGS, ActualTypes, 
+	list__map(map__lookup(VarTypes), ARGS, ActualTypes),
+	rename_call_alias(PredProcId, HLDS, ARGS, ActualTypes, 
 				CallAlias, RenamedCallAlias),
-	pa_alias_as__extend(HLDS, ProcInfo, RenamedCallAlias, A0, A).
+	pa_alias_as__extend(HLDS, ProcInfo, RenamedCallAlias, !Alias).
+%	io__write_string("\n--> Extended aliases: ", !IO),
+%	io__write_strings(["(size = ", int_to_string(size(!.Alias)), 
+%			") "],!IO),
+%	print_brief_aliases(5, !.Alias, ProcInfo, PredInfo, !IO).
 
 analyse_goal_expr(generic_call(GenCall,_,_,_), Info, 
-				_ProcInfo, _HLDS , T, T, A0, A):- 
+		_ProcInfo, _P, _HLDS , !Table, !Alias, !IO) :-
 	(
 		GenCall = higher_order(_, _, _),
 		Text = "higher_order"
@@ -391,89 +406,115 @@
 	term__context_line(Context, ContextLine), 
 	term__context_file(Context, ContextFile), 
 	string__int_to_string(ContextLine, ContextLineS), 
-
 	string__append_list(["generic_call:",Text," (",ContextFile, ":", 
 				ContextLineS, ")"], Msg), 
-	
-	pa_alias_as__top(A0, Msg, A). 
+	pa_alias_as__top(Msg, !Alias). 
 	% error("(pa) generic_call not handled") .
 
 analyse_goal_expr(switch(_Var,_CF,Cases), Info, 
-				ProcInfo, HLDS, T0, T, A0, A):-
-	list__map_foldl(analyse_case(ProcInfo, HLDS, A0), 
-				Cases, SwitchAliases, T0, T),
+		ProcInfo, PredInfo, HLDS, !Table, !Alias, !IO) :- 
+	list__map_foldl2(analyse_case(ProcInfo, PredInfo, HLDS, !.Alias), 
+				Cases, SwitchAliases, !Table, !IO),
 	pa_alias_as__least_upper_bound_list(HLDS, ProcInfo, Info, 
-				SwitchAliases, A).
+				SwitchAliases, !:Alias).
 
-:- pred analyse_case(proc_info, module_info, 
-			alias_as, case, alias_as, 
-		   	pa_fixpoint_table,
-			pa_fixpoint_table).
-:- mode analyse_case(in, in, in, in, out, in, out) is det.
-
-analyse_case(ProcInfo, HLDS, Alias0, CASE, Alias, T0, T):-
-	CASE = case(_, Goal),
-	analyse_goal(ProcInfo, HLDS, Goal, T0, T, Alias0, Alias).
-
-analyse_goal_expr(unify(_,_,_,Unification,_), Info, ProcInfo, HLDS, 
-			T, T, A0, A):-
-	pa_alias_as__extend_unification(HLDS, ProcInfo, Unification, 
-				Info, A0, A).
-
-analyse_goal_expr(disj(Goals), Info, ProcInfo, HLDS, T0, T, A0, A):-
-	list__map_foldl(
-		pred(Goal::in, Alias::out, FPT0::in, FPT::out) is det :- 
-			(analyse_goal(ProcInfo, HLDS, Goal, 
-					FPT0, FPT, A0, Alias)),
+:- pred analyse_case(proc_info::in, pred_info::in, module_info::in, 
+		alias_as::in, case::in, alias_as::out, 
+		pa_fixpoint_table::in, pa_fixpoint_table::out, 
+		io__state::di, io__state::uo) is det.
+
+analyse_case(ProcInfo, PredInfo, HLDS, Alias0, Case, Alias, !Table, !IO) :-
+	Case = case(_, Goal),
+	analyse_goal(ProcInfo, PredInfo, HLDS, Goal, 
+		!Table, Alias0, Alias, !IO).
+
+analyse_goal_expr(unify(_,_,_,Unification,_), Info, ProcInfo, _PredInfo, 
+		HLDS, !Table, !Alias, !IO) :- 
+	% io__write_string("\n--> Unification.", !IO),
+	% io__write_string("\n--> Existing aliases: ", !IO),
+	% io__write_strings(["(size = ", int_to_string(size(A0)), 
+			% ") "], !IO),
+	% io__write_string("\n", !IO),
+	% print_aliases(A0, ProcInfo, PredInfo, !IO),
+	pa_alias_as__extend_unification(HLDS, ProcInfo, 
+		Unification, Info, !Alias). 
+	% io__write_string("\n--> Extended aliases: ", !IO),
+	% io__write_strings(["(size = ", int_to_string(size(A)), 
+			% ") "], !IO),
+	% print_aliases(A, ProcInfo, PredInfo, !IO).
+
+analyse_goal_expr(disj(Goals), Info, ProcInfo, PredInfo, HLDS, 
+		!Table, !Alias, !IO) :-
+%	io__write_string("\n--> Disjunction", !IO),
+	list__map_foldl2(
+		pred(Goal::in, Alias::out, FPT0::in, FPT::out, 
+			IO0::di, IO::uo) is det :- 
+			(analyse_goal(ProcInfo, PredInfo, HLDS, Goal, 
+					FPT0, FPT, !.Alias, Alias, IO0, IO)),
 		Goals,
 		DisjAliases,
-		T0, T),
+		!Table, !IO), 
+%	io__write_string("\n-->Disjunction, lub."),
+%	list__foldl(
+%		pred(AA::in, IO0::di, IO::uo) is det :-
+%			( io__write_string("\n--> --> Branch.", IO0, IO1),
+%			io__write_strings(["(size = ", 
+%					int_to_string(size(AA)), 
+%				") "], IO1, IO2),
+%			io__write_string("\n", IO2, IO3),
+%			print_aliases(AA, ProcInfo, PredInfo, IO3, IO) ),
+%			DisjAliases),
 	pa_alias_as__least_upper_bound_list(HLDS, ProcInfo, Info, 
-				DisjAliases, A).
+		DisjAliases, !:Alias).
+%	io__write_string("\n--> LUB"),
+%	io__write_strings(["(size = ", int_to_string(size(A)), 
+%			") "]),
+%	io__write_string("\n"),
+%	print_aliases(A, ProcInfo, PredInfo).
+
+analyse_goal_expr(not(Goal), _Info, ProcInfo, PredInfo, 
+		HLDS, !Table, !Alias, !IO) :- 
+	analyse_goal(ProcInfo, PredInfo, HLDS, Goal, !Table, !Alias, !IO). 
 
-analyse_goal_expr(not(Goal), _Info, ProcInfo, HLDS , T0, T, A0, A):-
-	analyse_goal(ProcInfo, HLDS, Goal, T0, T, A0, A).
-
-analyse_goal_expr(some(Vars,_,Goal), _Info, ProcInfo, HLDS , T0, T, A0, A):-
+analyse_goal_expr(some(Vars,_,Goal), _Info, ProcInfo, PredInfo, 
+		HLDS, !Table, !Alias, !IO) :- 
 	(
 		Vars = []
 	->
 		% XXX
-		analyse_goal(ProcInfo, HLDS, Goal, T0, T, A0, A)
+		analyse_goal(ProcInfo, PredInfo, HLDS, Goal, 
+			!Table, !Alias, !IO) 
 	;
-		require__error("(pa_run) analyse_goal_expr: some should have empty vars.")
+		Msg = "(pa_run) analyse_goal_expr: empty vars expected.",
+		require__error(Msg)
 	).
 	% pa_alias_as__top("some not handled", A).
 	% error("(pa) some goal not handled") .
 
 analyse_goal_expr(if_then_else(_VARS, IF, THEN, ELSE), _Info, 
-			ProcInfo,
-			HLDS , T0, T, A0, A) :- 
-	analyse_goal(ProcInfo, HLDS, IF, T0, T1, A0, A1),
-	analyse_goal(ProcInfo, HLDS, THEN, T1, T2, A1, A2),
-	analyse_goal(ProcInfo, HLDS, ELSE, T2, T, A0, A3),
+		ProcInfo, PredInfo, HLDS, !Table, A0, A, !IO) :- 
+	analyse_goal(ProcInfo, PredInfo, HLDS, IF, !Table, A0, A1, !IO),
+	analyse_goal(ProcInfo, PredInfo, HLDS, THEN, !Table, A1, A2, !IO),
+	analyse_goal(ProcInfo, PredInfo, HLDS, ELSE, !Table, A0, A3, !IO),
 	pa_alias_as__least_upper_bound(HLDS, ProcInfo, A2, A3, A).
 
 analyse_goal_expr(foreign_proc(Attrs, PredId, ProcId, 
 			Vars, MaybeModes, Types, _), 
-			Info, ProcInfo, HLDS, 
-			T, T, Ain, A) :- 
+		Info, ProcInfo, _PredInfo, HLDS, !Table, !Alias, !IO) :- 
 	extend_foreign_code(HLDS, ProcInfo, Attrs, PredId, ProcId, 
-			Vars, MaybeModes, Types, Info, Ain, A). 
+			Vars, MaybeModes, Types, Info, !Alias).
 
-	% error("(pa) pragma_c_code not handled") .
-analyse_goal_expr(par_conj(_Goals), Info, _, _ , T, T, A0, A) :-  
+analyse_goal_expr(par_conj(_Goals), Info, _, _ , _, !Table, !Alias, !IO) :- 
 	goal_info_get_context(Info, Context), 
 	term__context_line(Context, ContextLine), 
 	term__context_file(Context, ContextFile), 
 	string__int_to_string(ContextLine, ContextLineS), 
-
 	string__append_list(["par_conj:",
 				" (",ContextFile, ":", 
 				ContextLineS, ")"], Msg), 
-	pa_alias_as__top(A0, Msg, A).
+	pa_alias_as__top(Msg, !Alias).
 
-analyse_goal_expr(shorthand(_), _, _,  _ , _, _, _, _) :- 
+analyse_goal_expr(shorthand(_), _, _,  _, _, !T, !A, !IO) :- 
 	error("pa_run__analyse_goal_expr: shorthand goal").
 
 %-----------------------------------------------------------------------------%


-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
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