[m-rev.] diff: fix goal features in tabling

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Sep 7 17:42:18 AEST 2004


Fix the failures of the tabling/loopcheck_nondet test case at optimization
levels that enabled --local-constraint-propagation. The problem was that
constraint propagation reran determinism analysis. This changed the
determinism of an impure disjunction from multi to det. This prevented
backtracking into the second disjunct, and this in turn caused the
transformation not to detect the infinite loop in the program.

compiler/table_gen.m:
	Attach the preserve_backtrack_info goal feature to all goals of
	determinism failure we construct, since we don't construct any goals
	we don't mean to execute.

	Also add some missing variables to nonlocal sets in goal_infos.

compiler/constraint.m:
	Preserve the context and all features of goals as far as possible.
	Before this change, the constraint propagation transformation deleted
	the hide_debug_event annotations from some goals, which could alter
	what events an mdb user could see with --trace-optimized.

compiler/pd_debug.m:
	Fix a bug in my previous cleanup that caused an infinite loop when
	using --debug-pd.

Zoltan.

cvs server: Diffing .
cvs server: Diffing analysis
cvs server: Diffing bindist
cvs server: Diffing boehm_gc
cvs server: Diffing boehm_gc/Mac_files
cvs server: Diffing boehm_gc/cord
cvs server: Diffing boehm_gc/cord/private
cvs server: Diffing boehm_gc/doc
cvs server: Diffing boehm_gc/include
cvs server: Diffing boehm_gc/include/private
cvs server: Diffing boehm_gc/tests
cvs server: Diffing browser
cvs server: Diffing bytecode
cvs server: Diffing compiler
Index: compiler/constraint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.56
diff -u -r1.56 constraint.m
--- compiler/constraint.m	14 Jun 2004 04:15:59 -0000	1.56
+++ compiler/constraint.m	7 Sep 2004 00:25:47 -0000
@@ -78,15 +78,20 @@
 
 propagate_goal(Goal0, Constraints, Goal, !Info) :-
 	% We need to treat all single goals as conjunctions so that
-	% propagate_conj can move the constraints to the
-	% left of the goal if that is allowed.
+	% propagate_conj can move the constraints to the left of the goal
+	% if that is allowed.
+	Goal0 = _ - GoalInfo0,
+	goal_info_get_features(GoalInfo0, Features0),
+	goal_info_get_context(GoalInfo0, Context),
 	goal_to_conj_list(Goal0, Goals0),
 	propagate_conj(Goals0, Constraints, Goals, !Info),
 	goal_list_nonlocals(Goals, NonLocals),
 	goal_list_instmap_delta(Goals, Delta),
 	goal_list_determinism(Goals, ConjDetism),
 	goal_list_purity(Goals, Purity),
-	goal_info_init(NonLocals, Delta, ConjDetism, Purity, GoalInfo),
+	goal_info_init(NonLocals, Delta, ConjDetism, pure, Context, GoalInfo1),
+	goal_info_set_features(GoalInfo1, Features0, GoalInfo2),
+	add_goal_info_purity_feature(GoalInfo2, Purity, GoalInfo),
 	conj_list_to_goal(Goals, GoalInfo, Goal).
 
 :- pred propagate_conj_sub_goal(hlds_goal::in,
Index: compiler/pd_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pd_debug.m,v
retrieving revision 1.11
diff -u -r1.11 pd_debug.m
--- compiler/pd_debug.m	2 Sep 2004 23:49:32 -0000	1.11
+++ compiler/pd_debug.m	7 Sep 2004 00:25:47 -0000
@@ -197,7 +197,7 @@
 %-----------------------------------------------------------------------------%
 
 pd_debug__output_goal(PDInfo, Msg, Goal, !IO) :-
-	pd_debug__do_io(pd_debug__output_goal(PDInfo, Msg, Goal), !IO).
+	pd_debug__do_io(pd_debug__output_goal_2(PDInfo, Msg, Goal), !IO).
 
 :- pred pd_debug__output_goal_2(pd_info::in, string::in, hlds_goal::in,
 	io::di, io::uo) is det.
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.66
diff -u -r1.66 table_gen.m
--- compiler/table_gen.m	5 Sep 2004 23:52:45 -0000	1.66
+++ compiler/table_gen.m	7 Sep 2004 00:25:47 -0000
@@ -658,11 +658,16 @@
 		CodeModel = model_non,
 		AfterGoalExpr = disj([MarkInactiveGoal, MarkActiveFailGoal]),
 		instmap_delta_init_reachable(AfterInstMapDelta),
-		goal_info_init_hide(set__init, AfterInstMapDelta,
-			multidet, impure, Context, AfterGoalInfo),
+		goal_info_init_hide(set__make_singleton_set(TableTipVar),
+			AfterInstMapDelta, multidet, impure, Context,
+			AfterGoalInfo),
 		AfterGoal = AfterGoalExpr - AfterGoalInfo,
 		FirstGoalExpr = conj([OrigGoal, AfterGoal]),
-		FirstGoal = FirstGoalExpr - OrigGoalInfo,
+		goal_info_get_nonlocals(OrigGoalInfo, OrigGINonLocals),
+		set__insert(OrigGINonLocals, TableTipVar, FirstNonlocals),
+		goal_info_set_nonlocals(OrigGoalInfo, FirstNonlocals,
+			FirstGoalInfo),
+		FirstGoal = FirstGoalExpr - FirstGoalInfo,
 		InactiveGoalExpr = disj([FirstGoal, MarkInactiveFailGoal])
 	),
 	goal_info_init_hide(InactiveNonLocals, InactiveInstmapDelta,
@@ -677,7 +682,9 @@
 			InactiveGoal)
 	],
 	SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms),
-	goal_info_init_hide(InactiveNonLocals, InactiveInstmapDelta,
+	set__insert_list(InactiveNonLocals, [StatusVar, TableTipVar],
+		SwitchNonLocals),
+	goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta,
 		Detism, impure, Context, SwitchGoalInfo),
 	SwitchGoal = SwitchExpr - SwitchGoalInfo,
 
@@ -931,7 +938,8 @@
 	),
 
 	SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms),
-	goal_info_init_hide(InactiveNonLocals, InactiveInstmapDelta,
+	set__insert(InactiveNonLocals, StatusVar, SwitchNonLocals),
+	goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta,
 		Detism, impure, Context, SwitchGoalInfo),
 	SwitchGoal = SwitchExpr - SwitchGoalInfo,
 
@@ -1041,7 +1049,8 @@
 	],
 
 	SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms),
-	goal_info_init_hide(InactiveNonLocals, InactiveInstmapDelta,
+	set__insert(InactiveNonLocals, StatusVar, SwitchNonLocals),
+	goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta,
 		Detism, impure, Context, SwitchGoalInfo),
 	SwitchGoal = SwitchExpr - SwitchGoalInfo,
 
@@ -1396,7 +1405,8 @@
 		!VarTypes, !VarSet, SuspendGoal),
 
 	MainExpr = conj([OrigGoal | SaveAnswerGoals]),
-	set__insert(OrigNonLocals, SubgoalVar, MainNonLocals),
+	set__insert_list(OrigNonLocals, [SubgoalVar, StatusVar],
+		MainNonLocals),
 	create_instmap_delta([OrigGoal | SaveAnswerGoals], MainIMD0),
 	instmap_delta_restrict(MainIMD0, MainNonLocals, MainIMD),
 	goal_info_init_hide(MainNonLocals, MainIMD, nondet, impure, Context,
@@ -2860,7 +2870,12 @@
 generate_call(PredName, Detism, Args, Purity, InstMapSrc,
 		ModuleInfo, Context, Goal) :-
 	mercury_table_builtin_module(BuiltinModule),
-	Features = impure_or_semipure_to_features(Purity),
+	Features0 = impure_or_semipure_to_features(Purity),
+	( Detism = failure ->
+		Features = [preserve_backtrack_into | Features0]
+	;
+		Features = Features0
+	),
 	goal_util__generate_simple_call(BuiltinModule, PredName, predicate,
 		only_mode, Detism, Args, Features, InstMapSrc, ModuleInfo,
 		Context, Goal).
@@ -2875,7 +2890,12 @@
 		PrefixCode, Code, SuffixCode, Purity, InstMapSrc,
 		ModuleInfo, Context, Goal) :-
 	mercury_table_builtin_module(BuiltinModule),
-	Features = impure_or_semipure_to_features(Purity),
+	Features0 = impure_or_semipure_to_features(Purity),
+	( Detism = failure ->
+		Features = [preserve_backtrack_into | Features0]
+	;
+		Features = Features0
+	),
 	goal_util__generate_foreign_proc(BuiltinModule, PredName, predicate,
 		only_mode, Detism, Attributes, Args, ExtraArgs,
 		PrefixCode, Code, SuffixCode, Features, InstMapSrc,
cvs server: Diffing compiler/notes
cvs server: Diffing debian
cvs server: Diffing deep_profiler
cvs server: Diffing deep_profiler/notes
cvs server: Diffing doc
cvs server: Diffing extras
cvs server: Diffing extras/aditi
cvs server: Diffing extras/cgi
cvs server: Diffing extras/complex_numbers
cvs server: Diffing extras/complex_numbers/samples
cvs server: Diffing extras/complex_numbers/tests
cvs server: Diffing extras/concurrency
cvs server: Diffing extras/curs
cvs server: Diffing extras/curs/samples
cvs server: Diffing extras/curses
cvs server: Diffing extras/curses/sample
cvs server: Diffing extras/dynamic_linking
cvs server: Diffing extras/error
cvs server: Diffing extras/graphics
cvs server: Diffing extras/graphics/mercury_glut
cvs server: Diffing extras/graphics/mercury_opengl
cvs server: Diffing extras/graphics/mercury_tcltk
cvs server: Diffing extras/graphics/samples
cvs server: Diffing extras/graphics/samples/calc
cvs server: Diffing extras/graphics/samples/gears
cvs server: Diffing extras/graphics/samples/maze
cvs server: Diffing extras/graphics/samples/pent
cvs server: Diffing extras/lazy_evaluation
cvs server: Diffing extras/lex
cvs server: Diffing extras/lex/samples
cvs server: Diffing extras/lex/tests
cvs server: Diffing extras/logged_output
cvs server: Diffing extras/moose
cvs server: Diffing extras/moose/samples
cvs server: Diffing extras/moose/tests
cvs server: Diffing extras/morphine
cvs server: Diffing extras/morphine/non-regression-tests
cvs server: Diffing extras/morphine/scripts
cvs server: Diffing extras/morphine/source
cvs server: Diffing extras/odbc
cvs server: Diffing extras/posix
cvs server: Diffing extras/quickcheck
cvs server: Diffing extras/quickcheck/tutes
cvs server: Diffing extras/references
cvs server: Diffing extras/references/samples
cvs server: Diffing extras/references/tests
cvs server: Diffing extras/stream
cvs server: Diffing extras/trailed_update
cvs server: Diffing extras/trailed_update/samples
cvs server: Diffing extras/trailed_update/tests
cvs server: Diffing extras/xml
cvs server: Diffing extras/xml/samples
cvs server: Diffing java
cvs server: Diffing java/runtime
cvs server: Diffing library
cvs server: Diffing profiler
cvs server: Diffing robdd
cvs server: Diffing runtime
cvs server: Diffing runtime/GETOPT
cvs server: Diffing runtime/machdeps
cvs server: Diffing samples
cvs server: Diffing samples/c_interface
cvs server: Diffing samples/c_interface/c_calls_mercury
cvs server: Diffing samples/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/c_interface/mercury_calls_c
cvs server: Diffing samples/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/c_interface/mercury_calls_fortran
cvs server: Diffing samples/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/diff
cvs server: Diffing samples/muz
cvs server: Diffing samples/rot13
cvs server: Diffing samples/solutions
cvs server: Diffing samples/tests
cvs server: Diffing samples/tests/c_interface
cvs server: Diffing samples/tests/c_interface/c_calls_mercury
cvs server: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/tests/c_interface/mercury_calls_c
cvs server: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs server: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/tests/diff
cvs server: Diffing samples/tests/muz
cvs server: Diffing samples/tests/rot13
cvs server: Diffing samples/tests/solutions
cvs server: Diffing samples/tests/toplevel
cvs server: Diffing scripts
cvs server: Diffing tests
cvs server: Diffing tests/benchmarks
cvs server: Diffing tests/debugger
cvs server: Diffing tests/debugger/declarative
cvs server: Diffing tests/dppd
cvs server: Diffing tests/general
cvs server: Diffing tests/general/accumulator
cvs server: Diffing tests/general/string_format
cvs server: Diffing tests/general/structure_reuse
cvs server: Diffing tests/grade_subdirs
cvs server: Diffing tests/hard_coded
cvs server: Diffing tests/hard_coded/exceptions
cvs server: Diffing tests/hard_coded/purity
cvs server: Diffing tests/hard_coded/sub-modules
cvs server: Diffing tests/hard_coded/typeclasses
cvs server: Diffing tests/invalid
cvs server: Diffing tests/invalid/purity
cvs server: Diffing tests/misc_tests
cvs server: Diffing tests/mmc_make
cvs server: Diffing tests/mmc_make/lib
cvs server: Diffing tests/recompilation
cvs server: Diffing tests/tabling
cvs server: Diffing tests/term
cvs server: Diffing tests/valid
cvs server: Diffing tests/warnings
cvs server: Diffing tools
cvs server: Diffing trace
cvs server: Diffing util
cvs server: Diffing vim
cvs server: Diffing vim/after
cvs server: Diffing vim/ftplugin
cvs server: Diffing vim/syntax
--------------------------------------------------------------------------
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