[m-rev.] for review: allow deep profiling grades to bootcheck again

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Feb 26 02:42:29 AEDT 2002


For review by anyone.

Allow the deep profiling grade to bootstrap again.

compiler/deep_profiling.m:
	Fix an omission from a nonlocals set.

	Mark transformed some() goals that act as cuts as being non-removable.
	Without this, determinism analysis (reinvoked by simplify after the
	deep profiling transformation) could compute the wrong determinism
	for some some() goals with no output arguments. This happened if
	originally, the some() represented a cut, but after the goal being
	cut across was made inpure by the deep profiling transformation,
	determinism analysis decided that it needed to find all solutions
	to that goal to avoid removing some side effects.

compiler/det_analysis.m:
	Respect the non-removable markers placed by deep_profiling.m.

compiler/hlds_goal.m:
	Add a goal feature that acts as this marker.

tests/general/Mmakefile:
	In deep profiling grades, disable test cases that require catching
	exceptions, which we can't do (yet) in those grades.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.5
diff -u -b -r1.5 deep_profiling.m
--- compiler/deep_profiling.m	18 Jul 2001 07:52:23 -0000	1.5
+++ compiler/deep_profiling.m	5 Feb 2002 05:11:05 -0000
@@ -696,7 +696,7 @@
 		generate_call(ModuleInfo, "semi_fail_port_code_sr", 3,
 			[TopCSD, MiddleCSD, ActivationPtr1], no, failure,
 			FailPortCode),
-		NewNonlocals = list_to_set([MiddleCSD, ActivationPtr1])
+		NewNonlocals = list_to_set([TopCSD, MiddleCSD, ActivationPtr1])
 	;
 		MaybeActivationPtr = no,
 		generate_call(ModuleInfo, "semi_call_port_code_ac", 3,
@@ -706,7 +706,7 @@
 			[TopCSD, MiddleCSD], [], ExitPortCode),
 		generate_call(ModuleInfo, "semi_fail_port_code_ac", 2,
 			[TopCSD, MiddleCSD], no, failure, FailPortCode),
-		NewNonlocals = list_to_set([MiddleCSD])
+		NewNonlocals = list_to_set([TopCSD, MiddleCSD])
 	),
 
 	ExitConjGoalInfo = goal_info_add_nonlocals_make_impure(GoalInfo0,
@@ -951,18 +951,26 @@
 	transform_goal([neg | Path], Goal0, Goal, AddedImpurity),
 	{ add_impurity_if_needed(AddedImpurity, Info0, Info) }.
 
-transform_goal(Path, some(QVars, CR, Goal0) - Info0,
-		some(QVars, CR, Goal) - Info, AddedImpurity) -->
+transform_goal(Path, some(QVars, CanRemove, Goal0) - Info0,
+		some(QVars, CanRemove, Goal) - Info, AddedImpurity) -->
 	{ Goal0 = _ - InnerInfo },
 	{ goal_info_get_determinism(Info0, OuterDetism) },
 	{ goal_info_get_determinism(InnerInfo, InnerDetism) },
 	{ InnerDetism = OuterDetism ->
+		Info1 = Info0,
 		MaybeCut = no_cut
 	;
+		% Given a subgoal containing both nondet code and impure code, 
+		% determinism analysis will remove the `some' wrapped around
+		% that subgoal if it is allowed to. If we get here, then the
+		% subgoal inside the `some' contains nondet code, and the deep
+		% profiling transformation will make it impure as well.
+
+		goal_info_add_feature(Info0, keep_this_commit, Info1),
 		MaybeCut = cut
 	},
 	transform_goal([exist(MaybeCut) | Path], Goal0, Goal, AddedImpurity),
-	{ add_impurity_if_needed(AddedImpurity, Info0, Info) }.
+	{ add_impurity_if_needed(AddedImpurity, Info1, Info) }.
 
 transform_goal(Path, if_then_else(IVars, Cond0, Then0, Else0, SM) - Info0,
 		if_then_else(IVars, Cond, Then, Else, SM) - Info,
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.151
diff -u -b -r1.151 det_analysis.m
--- compiler/det_analysis.m	22 Aug 2001 07:56:31 -0000	1.151
+++ compiler/det_analysis.m	5 Feb 2002 05:06:12 -0000
@@ -297,28 +297,44 @@
 	goal_info_get_instmap_delta(GoalInfo0, DeltaInstMap),
 
 	% If a pure or semipure goal has no output variables,
-	% then the goal is in single-solution context
+	% then the goal is in a single-solution context.
 
 	(
 		det_no_output_vars(NonLocalVars, InstMap0, DeltaInstMap,
 			DetInfo),
 		\+ goal_info_is_impure(GoalInfo0)
 	->
-		OutputVars = no,
+		AddPruning = yes,
 		SolnContext = first_soln
 	;
-		OutputVars = yes,
+		AddPruning = no,
 		SolnContext = SolnContext0
 	),
 
+	% Some other part of the compiler has determined that we need to keep
+	% the cut represented by this quantification. This can happen e.g.
+	% when deep profiling adds impure code to the goal inside the some;
+	% it doesn't want to change the behavior of the some, even though
+	% the addition of impurity would make the if-then-else treat it
+	% differently.
+
+	(
+		Goal0 = some(_, _, _),
+		goal_info_has_feature(GoalInfo0, keep_this_commit)
+	->
+		Prune = yes
+	;
+		Prune = AddPruning
+	),
+
 	det_infer_goal_2(Goal0, GoalInfo0, InstMap0, SolnContext, DetInfo,
 		NonLocalVars, DeltaInstMap, Goal1, InternalDetism0, Msgs1),
 
 	determinism_components(InternalDetism0, InternalCanFail,
 				InternalSolns0),
 	(
-		% if mode analysis notices that a goal cannot succeed,
-		% then determinism analysis should notice this too
+		% If mode analysis notices that a goal cannot succeed,
+		% then determinism analysis should notice this too.
 
 		instmap_delta_is_unreachable(DeltaInstMap)
 	->
@@ -328,20 +344,15 @@
 	),
 
 	(
-		% If a pure or semipure goal with multiple solutions
-		% has no output variables,
-		% then it really it has only one solution
-		% (we will need to do pruning)
-
 		( InternalSolns = at_most_many
 		; InternalSolns = at_most_many_cc
 		),
-		OutputVars = no
+		Prune = yes
 	->
 		Solns = at_most_one
 	;
-		% If a goal with multiple solutions occurs in a single-solution
-		% context, then we will need to do pruning
+		% If a goal with multiple solutions occurs in a
+		% single-solution context, then we will need to do pruning.
 
 		InternalSolns = at_most_many,
 		SolnContext = first_soln
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.92
diff -u -b -r1.92 hlds_goal.m
--- compiler/hlds_goal.m	20 Feb 2002 03:14:00 -0000	1.92
+++ compiler/hlds_goal.m	25 Feb 2002 05:01:42 -0000
@@ -745,6 +745,16 @@
 				% the value of this variable in its stack slot
 				% as soon as it is generated; this marker
 				% tells the code generator when this happens.
+	;	keep_this_commit
+				% This feature should be attached only to goals
+				% that represent commits (i.e. some() goals in
+				% which the inner and outer determinisms
+				% differ). It tells determinism analysis that
+				% some other part of the compiler wants the
+				% commit to stay, even if the usual rules of
+				% determinism analysis say that the
+				% nondeterminism inside the some() should be
+				% exposed to the environment outside.
 	;	tailcall.	% This goal represents a tail call. This marker
 				% is used by deep profiling.
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
Index: tests/general/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/general/Mmakefile,v
retrieving revision 1.38
diff -u -b -r1.38 Mmakefile
--- tests/general/Mmakefile	12 Feb 2002 15:47:57 -0000	1.38
+++ tests/general/Mmakefile	25 Feb 2002 13:29:41 -0000
@@ -16,7 +16,7 @@
 
 # Any program added here should also be added to the `.cvsignore' file.
 
-PROGS=		\
+ORDINARY_PROGS=	\
 		arithmetic \
 		array_test \
 		commit_bug \
@@ -41,7 +41,6 @@
 		io_regression \
 		liveness \
 		liveness2 \
-		map_corresponding \
 		mode_inf \
 		mode_inf_bug \
 		mode_inference_reorder \
@@ -70,8 +69,17 @@
 		string_to_float \
 		univ \
 		unreachable \
-		unsafe_uniqueness \
+		unsafe_uniqueness
+
+EXCEPTION_PROGS = \
+		map_corresponding \
 		unused_arg_determinism
+
+ifneq "$(findstring profdeep,$(GRADE))" ""
+	PROGS = $(ORDINARY_PROGS)
+else
+	PROGS = $(ORDINARY_PROGS) $(EXCEPTION_PROGS)
+endif
 
 # dnf.m does not work in non-gc grades, because it uses `pragma memo'
 # (i.e. tabling) and tabling is not yet implemented for non-gc grades.
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
--------------------------------------------------------------------------
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