[m-rev.] for review: optimizing shallow traced modules

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Jul 4 13:55:37 AEST 2002


For review by anyone.

Zoltan.

Estimated hours taken: 8

Optimize shallow traced modules by not adding calls to MR_trace to shallow
traced procedures which cannot be called from a deep traced environment.
A shallow traced procedure can be optimized in this way if it is neither
exported from its defining module nor has its address taken.

The main purpose of this optimization is not the avoidance of the cost of the
MR_trace calls as much as it is the restoration of tail recursion optimization.
Previosly, compiling a program in a debug grade would disable all tail
recursion in the program (since debug grades require at least shallow tracing
every module. This was a problem because it limited the sizes of the inputs
the debugged program could process before running out of memory. As long as
the procedures that recurse on the input are in the implementation section
of a shallow traced module, this should no longer happen.

compiler/trace_params.m:
	Introduce the concept of a procedure's effective trace level. This is
	identical to the global trace level, except if the procedure is not
	exported and doesn't have its address taken, and the global trace level
	is shallow. In that case, we say that the procedure's effective trace
	level is none.

	Computing a procedure's effective trace level requires its proc_info
	and its parent pred_info, so require callers to supply these as
	parameters.

compiler/code_info.m:
	Store the current pred_info as well as the current proc_info, for
	trace parameter lookups.

compiler/continuation_info.m:
compiler/code_gen.m:
	Record the required trace parameters of a procedure in its layout
	structure, since it can no longer be computed from the global trace
	level.

compiler/stack_layout.m:
	Use the trace parameters in procedures' layout structures, instead of
	trying to compute them from the global trace level.

compiler/inlining.m:
compiler/liveness.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/trace.m:
	Use procedures' effective trace level instead of the global trace level
	where relevant.

compiler/llds.m:
	Record the required trace parameter of a procedure in its c_procedure
	representation, since it can no longer be computed from the global
	trace level.

compiler/optimize.m:
compiler/jumpopt.m:
	Use a required trace parameter of a procedure in its c_procedure
	representation, since it can no longer be computed from the global
	trace level.

	Delete an obsolete field.

compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
	Trivial changes to conform to updated interfaces.

tests/debugger/shallow.m:
tests/debugger/shallow2.m:
tests/debugger/shallow.{inp,exp*}:
	Divide the old test case in shallow.m in two. The top level predicates
	stay in shallow.m and continue to be shallow traced. The two bottom
	predicates move to shallow2.m and are now deep traced.

	The new test input checks whether the debugger can walk across the
	stack frames of procedures in shallow traced modules whose effective
	trace level is "none" (such as queen/2).

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/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.102
diff -u -b -r1.102 code_gen.m
--- compiler/code_gen.m	2002/04/04 06:00:08	1.102
+++ compiler/code_gen.m	2002/06/19 16:19:32
@@ -275,9 +275,9 @@
 		% procedures, always needed for model_semi procedures, and
 		% needed for model_non procedures only if we are doing
 		% execution tracing.
-	code_info__init(SaveSuccip, Globals, PredId, ProcId, ProcInfo,
-		FollowVars, ModuleInfo, CellCounter0, OutsideResumePoint,
-		TraceSlotInfo, CodeInfo0),
+	code_info__init(SaveSuccip, Globals, PredId, ProcId, PredInfo,
+		ProcInfo, FollowVars, ModuleInfo, CellCounter0,
+		OutsideResumePoint, TraceSlotInfo, CodeInfo0),
 
 		% Generate code for the procedure.
 	generate_category_code(CodeModel, Goal, OutsideResumePoint,
@@ -289,8 +289,10 @@
 	globals__get_trace_level(Globals, TraceLevel),
 	code_info__get_created_temp_frame(CreatedTempFrame, CodeInfo, _),
 
+	EffTraceIsNone = eff_trace_level_is_none(PredInfo, ProcInfo,
+		TraceLevel),
 	(
-		trace_level_is_none(TraceLevel) = no,
+		EffTraceIsNone = no,
 		CreatedTempFrame = yes,
 		CodeModel \= model_non
 	->
@@ -344,11 +346,25 @@
 		proc_info_headvars(ProcInfo, HeadVars),
 		proc_info_varset(ProcInfo, VarSet),
 		proc_info_vartypes(ProcInfo, VarTypes),
+		globals__get_trace_suppress(Globals, TraceSuppress),
+		(
+			eff_trace_needs_proc_body_reps(PredInfo, ProcInfo,
+				TraceLevel, TraceSuppress) = yes
+		->
+			MaybeGoal = yes(Goal)
+		;
+			MaybeGoal = no
+		),
+		IsBeingTraced = bool__not(eff_trace_level_is_none(PredInfo,
+			ProcInfo, TraceLevel)),
+		NeedsAllNames = eff_trace_needs_all_var_names(PredInfo,
+			ProcInfo, TraceLevel, TraceSuppress),
 		ProcLayout = proc_layout_info(RttiProcLabel, EntryLabel,
 			Detism, TotalSlots, MaybeSuccipSlot, EvalMethod,
-			MaybeTraceCallLabel, MaxTraceReg, HeadVars, Goal,
+			MaybeTraceCallLabel, MaxTraceReg, HeadVars, MaybeGoal,
 			InstMap0, TraceSlotInfo, ForceProcId, VarSet, VarTypes,
-			InternalMap, MaybeTableIoDecl),
+			InternalMap, MaybeTableIoDecl, IsBeingTraced,
+			NeedsAllNames),
 		global_data_add_new_proc_layout(GlobalData0,
 			proc(PredId, ProcId), ProcLayout, GlobalData1)
 	;
@@ -365,14 +381,15 @@
 	pred_info_name(PredInfo, Name),
 	pred_info_arity(PredInfo, Arity),
 
-	( goal_contains_reconstruction(Goal) ->
-		ContainsReconstruction = contains_reconstruction
+	code_info__get_label_counter(LabelCounter, CodeInfo, _),
+	(
+		EffTraceIsNone = yes,
+		MayAlterRtti = may_alter_rtti
 	;
-		ContainsReconstruction = does_not_contain_reconstruction
+		EffTraceIsNone = no,
+		MayAlterRtti = must_not_alter_rtti
 	),
 
-	code_info__get_label_counter(LabelCounter, CodeInfo, _),
-
 	globals__lookup_bool_option(Globals, generate_bytecode, GenBytecode),
 	(
 		% XXX: There is a mass of calls above that the bytecode
@@ -390,11 +407,11 @@
 			BytecodeInstructions),
 		Proc = c_procedure(Name, Arity, proc(PredId, ProcId),
 			BytecodeInstructions, ProcLabel, EmptyLabelCounter,
-			ContainsReconstruction)
+			MayAlterRtti)
 	;	
 		Proc = c_procedure(Name, Arity, proc(PredId, ProcId),
 			Instructions, ProcLabel, LabelCounter,
-			ContainsReconstruction)
+			MayAlterRtti)
 	).
 
 :- pred maybe_add_tabling_pointer_var(module_info::in,
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.268
diff -u -b -r1.268 code_info.m
--- compiler/code_info.m	2002/05/16 13:14:43	1.268
+++ compiler/code_info.m	2002/06/19 14:27:52
@@ -77,8 +77,9 @@
 		% outermost resumption point, and info about the non-fixed
 		% stack slots used for tracing purposes.
 :- pred code_info__init(bool::in, globals::in, pred_id::in, proc_id::in,
-	proc_info::in, follow_vars::in, module_info::in, counter::in,
-	resume_point_info::out, trace_slot_info::out, code_info::out) is det.
+	pred_info::in, proc_info::in, follow_vars::in, module_info::in,
+	counter::in, resume_point_info::out, trace_slot_info::out,
+	code_info::out) is det.
 
 		% Get the globals table.
 :- pred code_info__get_globals(globals::out,
@@ -100,6 +101,11 @@
 :- pred code_info__get_proc_info(proc_info::out,
 	code_info::in, code_info::out) is det.
 
+		% Get the HLDS of the predicate containing the procedure
+		% we are generating code for.
+:- pred code_info__get_pred_info(pred_info::out,
+	code_info::in, code_info::out) is det.
+
 		% Get the variables for the current procedure.
 :- pred code_info__get_varset(prog_varset::out,
 	code_info::in, code_info::out) is det.
@@ -271,7 +277,10 @@
 		proc_id :: proc_id,
 				% The id of the current procedure.
 		proc_info :: proc_info,
-				% The proc_info for the this procedure.
+				% The proc_info for this procedure.
+		pred_info :: pred_info,
+				% The pred_info for the predicate containing
+				% this procedure.
 		varset :: prog_varset,
 				% The variables in this procedure.
 		var_slot_count :: int,
@@ -366,9 +375,9 @@
 
 %---------------------------------------------------------------------------%
 
-code_info__init(SaveSuccip, Globals, PredId, ProcId, ProcInfo, FollowVars,
-		ModuleInfo, CellCounter, ResumePoint, TraceSlotInfo, CodeInfo)
-		:-
+code_info__init(SaveSuccip, Globals, PredId, ProcId, PredInfo, ProcInfo,
+		FollowVars, ModuleInfo, CellCounter, ResumePoint,
+		TraceSlotInfo, CodeInfo) :-
 	proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap),
 	proc_info_liveness_info(ProcInfo, Liveness),
 	proc_info_interface_code_model(ProcInfo, CodeModel),
@@ -378,7 +387,7 @@
 	globals__lookup_bool_option(Globals, lazy_code, LazyCode),
 	globals__get_options(Globals, Options),
 	globals__get_trace_level(Globals, TraceLevel),
-	( trace_level_is_none(TraceLevel) = no ->
+	( eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel) = no ->
 		trace__fail_vars(ModuleInfo, ProcInfo, FailVars),
 		MaybeFailVars = yes(FailVars),
 		set__union(Liveness, FailVars, EffLiveness)
@@ -415,7 +424,8 @@
 	set__init(Zombies),
 	map__init(LayoutMap),
 	code_info__max_var_slot(StackSlots, VarSlotMax),
-	trace__reserved_slots(ModuleInfo, ProcInfo, Globals, FixedSlots, _),
+	trace__reserved_slots(ModuleInfo, PredInfo, ProcInfo, Globals,
+		FixedSlots, _),
 	int__max(VarSlotMax, FixedSlots, SlotMax),
 	globals__lookup_bool_option(Globals, opt_no_return_calls,
 		OptNoReturnCalls),
@@ -426,6 +436,7 @@
 			PredId,
 			ProcId,
 			ProcInfo,
+			PredInfo,
 			VarSet,
 			SlotMax,
 			no,
@@ -453,19 +464,19 @@
 			no
 		)
 	),
-	code_info__init_maybe_trace_info(TraceLevel, Globals, ProcInfo,
-		ModuleInfo, TraceSlotInfo, CodeInfo0, CodeInfo1),
+	code_info__init_maybe_trace_info(TraceLevel, Globals, ModuleInfo,
+		PredInfo, ProcInfo, TraceSlotInfo, CodeInfo0, CodeInfo1),
 	code_info__init_fail_info(CodeModel, MaybeFailVars, ResumePoint,
 		CodeInfo1, CodeInfo).
 
 :- pred code_info__init_maybe_trace_info(trace_level::in, globals::in,
-	proc_info::in, module_info::in, trace_slot_info::out,
+	module_info::in, pred_info::in, proc_info::in, trace_slot_info::out,
 	code_info::in, code_info::out) is det.
 
-code_info__init_maybe_trace_info(TraceLevel, Globals, ProcInfo, ModuleInfo,
-		TraceSlotInfo) -->
-	( { trace_level_is_none(TraceLevel) = no } ->
-		trace__setup(ModuleInfo, ProcInfo, Globals,
+code_info__init_maybe_trace_info(TraceLevel, Globals, ModuleInfo, PredInfo,
+		ProcInfo, TraceSlotInfo) -->
+	( { eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel) = no } ->
+		trace__setup(ModuleInfo, PredInfo, ProcInfo, Globals,
 			TraceSlotInfo, TraceInfo),
 		code_info__set_maybe_trace_info(yes(TraceInfo))
 	;
@@ -479,6 +490,7 @@
 code_info__get_pred_id(CI^code_info_static^pred_id, CI, CI).
 code_info__get_proc_id(CI^code_info_static^proc_id, CI, CI).
 code_info__get_proc_info(CI^code_info_static^proc_info, CI, CI).
+code_info__get_pred_info(CI^code_info_static^pred_info, CI, CI).
 code_info__get_varset(CI^code_info_static^varset, CI, CI).
 code_info__get_var_slot_count(CI^code_info_static^var_slot_count, CI, CI).
 code_info__get_maybe_trace_info(CI^code_info_static^maybe_trace_info, CI, CI).
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.15
diff -u -b -r1.15 compile_target_code.m
--- compiler/compile_target_code.m	2002/06/26 08:31:23	1.15
+++ compiler/compile_target_code.m	2002/06/27 08:57:15
@@ -791,7 +791,7 @@
 	maybe_write_string(Verbose, "% Creating initialization file...\n"),
 
 	globals__io_get_trace_level(TraceLevel),
-	{ trace_level_is_none(TraceLevel) = no ->
+	{ given_trace_level_is_none(TraceLevel) = no ->
 		TraceOpt = "--trace "
 	;
 		TraceOpt = ""
@@ -893,7 +893,7 @@
 	globals__io_lookup_bool_option(statistics, Stats),
 
 	globals__io_get_trace_level(TraceLevel),
-	{ trace_level_is_none(TraceLevel) = no ->
+	{ given_trace_level_is_none(TraceLevel) = no ->
 		TraceOpt = "--trace "
 	;
 		TraceOpt = ""
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.42
diff -u -b -r1.42 continuation_info.m
--- compiler/continuation_info.m	2002/04/04 06:00:09	1.42
+++ compiler/continuation_info.m	2002/06/19 16:18:31
@@ -96,8 +96,9 @@
 					% The head variables, in order,
 					% including the ones introduced by the
 					% compiler.
-			proc_body	:: hlds_goal,
-					% The body of the procedure.
+			maybe_proc_body	:: maybe(hlds_goal),
+					% The body of the procedure, if
+					% required.
 			initial_instmap	:: instmap,
 					% The instmap at the start of the
 					% procedure body.
@@ -115,7 +116,13 @@
 			internal_map	:: proc_label_layout_info,
 					% Info for each internal label,
 					% needed for basic_stack_layouts.
-			table_io_decl	:: maybe(table_io_decl_info)
+			table_io_decl	:: maybe(table_io_decl_info),
+					% True if the effective trace level
+					% of the procedure is not none.
+			is_being_traced :: bool,
+					% True iff we need the names of all the
+					% variables.
+			need_all_names	:: bool
 		).
 
 	%
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.142
diff -u -b -r1.142 handle_options.m
--- compiler/handle_options.m	2002/07/01 09:03:54	1.142
+++ compiler/handle_options.m	2002/07/02 02:15:22
@@ -615,7 +615,7 @@
 	% 	- enabling stack layouts
 	% 	- enabling typeinfo liveness
 	globals__io_lookup_bool_option(trace_optimized, TraceOptimized),
-	( { trace_level_is_none(TraceLevel) = no } ->
+	( { given_trace_level_is_none(TraceLevel) = no } ->
 		( { TraceOptimized = no } ->
 			% The following options modify the structure
 			% of the program, which makes it difficult to
Index: compiler/inlining.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.107
diff -u -b -r1.107 inlining.m
--- compiler/inlining.m	2002/03/28 03:43:05	1.107
+++ compiler/inlining.m	2002/06/19 15:34:30
@@ -204,7 +204,7 @@
 	globals__io_lookup_int_option(inline_vars_threshold, VarThreshold),
 	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
 	globals__io_get_trace_level(TraceLevel),
-	{ Tracing = bool__not(trace_level_is_none(TraceLevel)) },
+	{ Tracing = bool__not(given_trace_level_is_none(TraceLevel)) },
 	{ Params = params(Simple, SingleUse, CompoundThreshold,
 		SimpleThreshold, VarThreshold, HighLevelCode, Tracing) },
 
@@ -855,7 +855,11 @@
 	module_info_globals(ModuleInfo, Globals),
 	globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), 
 	globals__get_trace_level(Globals, TraceLevel),
-	Tracing = bool__not(trace_level_is_none(TraceLevel)),
+	module_info_pred_info(ModuleInfo, PredId, PredInfo),
+	pred_info_procedures(PredInfo, Procs),
+	map__lookup(Procs, ProcId, ProcInfo),
+	Tracing = bool__not(
+		eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel)),
 	inlining__can_inline_proc(PredId, ProcId, BuiltinState,
 		HighLevelCode, Tracing, InlinePromisedPure,
 		CallingPredMarkers, ModuleInfo).
Index: compiler/jumpopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/jumpopt.m,v
retrieving revision 1.61
diff -u -b -r1.61 jumpopt.m
--- compiler/jumpopt.m	2002/03/20 12:36:28	1.61
+++ compiler/jumpopt.m	2002/06/19 15:22:25
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1994-2001 The University of Melbourne.
+% Copyright (C) 1994-2002 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -14,7 +14,7 @@
 
 :- interface.
 
-:- import_module ll_backend__llds, libs__trace_params.
+:- import_module ll_backend__llds.
 :- import_module list, set, bool, counter.
 
 	% Take an instruction list and optimize jumps. This includes jumps
@@ -23,10 +23,10 @@
 	% The second argument gives the set of labels that have layout
 	% structures. This module will not optimize jumps to labels in this
 	% set, since this may interfere with the RTTI recorded for these
-	% labels. The third argument gives the trace level, which we also
-	% use to avoid optimizations that may interfere with RTTI.
+	% labels. The third argument says whether we are allowed to perform
+	% optimizations that may interfere with RTTI.
 	%
-	% The four bool inputs should be
+	% The final four bool inputs should be
 	%
 	% - the value of the --optimize-fulljumps option,
 	%
@@ -40,7 +40,7 @@
 	% The bool output says whether the instruction sequence was modified
 	% by the optimization.
 
-:- pred jumpopt_main(list(instruction)::in, set(label)::in, trace_level::in,
+:- pred jumpopt_main(list(instruction)::in, set(label)::in, may_alter_rtti::in,
 	proc_label::in, counter::in, counter::out,
 	bool::in, bool::in, bool::in, bool::in,
 	list(instruction)::out, bool::out) is det.
@@ -79,7 +79,7 @@
 % numbering, which can do a better job of optimizing this block, have
 % been applied.
 
-jumpopt_main(Instrs0, LayoutLabels, TraceLevel, ProcLabel, C0, C,
+jumpopt_main(Instrs0, LayoutLabels, MayAlterRtti, ProcLabel, C0, C,
 		Blockopt, Recjump, PessimizeTailCalls, CheckedNondetTailCall,
 		Instrs, Mod) :-
 	map__init(Instrmap0),
@@ -112,7 +112,7 @@
 		CheckedNondetTailCallInfo0 = yes(ProcLabel - C0),
 		jumpopt__instr_list(Instrs0, comment(""), Instrmap, Blockmap,
 			Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap,
-			LayoutLabels, TraceLevel, CheckedNondetTailCallInfo0,
+			LayoutLabels, MayAlterRtti, CheckedNondetTailCallInfo0,
 			CheckedNondetTailCallInfo, Instrs1),
 		( CheckedNondetTailCallInfo = yes(_ - Cprime) ->
 			C = Cprime
@@ -124,7 +124,7 @@
 		CheckedNondetTailCallInfo0 = no,
 		jumpopt__instr_list(Instrs0, comment(""), Instrmap, Blockmap,
 			Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap,
-			LayoutLabels, TraceLevel, CheckedNondetTailCallInfo0,
+			LayoutLabels, MayAlterRtti, CheckedNondetTailCallInfo0,
 			_, Instrs1),
 		C = C0
 	),
@@ -245,9 +245,9 @@
 	% between the if-val and the goto.
 
 :- pred jumpopt__instr_list(list(instruction), instr, instrmap, tailmap,
-	lvalmap, tailmap, tailmap, tailmap, tailmap, set(label), trace_level,
-	maybe(pair(proc_label, counter)), maybe(pair(proc_label, counter)),
-	list(instruction)).
+	lvalmap, tailmap, tailmap, tailmap, tailmap, set(label),
+	may_alter_rtti, maybe(pair(proc_label, counter)),
+	maybe(pair(proc_label, counter)), list(instruction)).
 :- mode jumpopt__instr_list(in, in, in, in, in, in, in, in, in, in, in,
 	in, out, out) is det.
 
@@ -256,7 +256,7 @@
 		_, CheckedNondetTailCallInfo, CheckedNondetTailCallInfo, []).
 jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap,
 		Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap, LayoutLabels,
-		TraceLevel, CheckedNondetTailCallInfo0,
+		MayAlterRtti, CheckedNondetTailCallInfo0,
 		CheckedNondetTailCallInfo, Instrs) :-
 	Instr0 = Uinstr0 - Comment0,
 	(
@@ -271,7 +271,7 @@
 			( CallModel = det ; CallModel = semidet ),
 			map__search(Procmap, RetLabel, Between0),
 			PrevInstr = livevals(Livevals),
-			trace_level_is_none(TraceLevel) = yes,
+			MayAlterRtti = may_alter_rtti,
 			not set__member(RetLabel, LayoutLabels)
 		->
 			opt_util__filter_out_livevals(Between0, Between1),
@@ -285,7 +285,7 @@
 			CallModel = semidet,
 			map__search(Forkmap, RetLabel, Between),
 			PrevInstr = livevals(Livevals),
-			trace_level_is_none(TraceLevel) = yes,
+			MayAlterRtti = may_alter_rtti,
 			not set__member(RetLabel, LayoutLabels)
 		->
 			list__append(Between, [livevals(Livevals) - "",
@@ -300,7 +300,7 @@
 			map__search(Succmap, RetLabel, BetweenIncl),
 			BetweenIncl = [livevals(_) - _, goto(_) - _],
 			PrevInstr = livevals(Livevals),
-			trace_level_is_none(TraceLevel) = yes,
+			MayAlterRtti = may_alter_rtti,
 			not set__member(RetLabel, LayoutLabels)
 		->
 			NewInstrs = [
@@ -324,7 +324,7 @@
 			map__search(Succmap, RetLabel, BetweenIncl),
 			BetweenIncl = [livevals(_) - _, goto(_) - _],
 			PrevInstr = livevals(Livevals),
-			trace_level_is_none(TraceLevel) = yes,
+			MayAlterRtti = may_alter_rtti,
 			not set__member(RetLabel, LayoutLabels)
 		->
 			counter__allocate(LabelNum, Counter0, Counter1),
@@ -349,7 +349,7 @@
 		;
 			% Short circuit the return label if possible.
 			map__search(Instrmap, RetLabel, RetInstr),
-			trace_level_is_none(TraceLevel) = yes,
+			MayAlterRtti = may_alter_rtti,
 			not set__member(RetLabel, LayoutLabels)
 		->
 			jumpopt__final_dest(RetLabel, RetInstr, Instrmap,
@@ -451,7 +451,7 @@
 			jumpopt__instr_list(AdjustedBlock, comment(""),
 				Instrmap, CrippledBlockmap, Lvalmap, Procmap,
 				Sdprocmap, Forkmap, Succmap, LayoutLabels,
-				TraceLevel, CheckedNondetTailCallInfo0,
+				MayAlterRtti, CheckedNondetTailCallInfo0,
 				CheckedNondetTailCallInfo1, NewInstrs),
 			RemainInstrs = Instrs0
 		;
@@ -657,7 +657,7 @@
 	),
 	jumpopt__instr_list(RemainInstrs, NewPrevInstr, Instrmap, Blockmap,
 		Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap, LayoutLabels,
-		TraceLevel, CheckedNondetTailCallInfo1,
+		MayAlterRtti, CheckedNondetTailCallInfo1,
 		CheckedNondetTailCallInfo, Instrs9),
 	list__append(NewInstrs, Instrs9, Instrs).
 
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.120
diff -u -b -r1.120 liveness.m
--- compiler/liveness.m	2002/03/28 03:43:09	1.120
+++ compiler/liveness.m	2002/06/19 15:38:29
@@ -244,8 +244,8 @@
 	),
 
 	globals__get_trace_level(Globals, TraceLevel),
-	( trace_level_is_none(TraceLevel) = no ->
-		trace__fail_vars(ModuleInfo, ProcInfo0, ResumeVars0)
+	( eff_trace_level_is_none(PredInfo, ProcInfo1, TraceLevel) = no ->
+		trace__fail_vars(ModuleInfo, ProcInfo1, ResumeVars0)
 	;
 		set__init(ResumeVars0)
 	),
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.286
diff -u -b -r1.286 llds.m
--- compiler/llds.m	2002/05/09 16:30:53	1.286
+++ compiler/llds.m	2002/06/19 15:20:16
@@ -148,16 +148,12 @@
 			list(instruction),	% the code for this procedure
 			proc_label,		% proc_label of this procedure
 			counter,		% source for new label numbers
-			contains_reconstruction	% value numbering needs
-						% to handle goals that
-						% perform structure reuse
-						% specially.
+			may_alter_rtti
 		).
 
-:- type contains_reconstruction
-	--->	contains_reconstruction
-	;	does_not_contain_reconstruction
-	.
+:- type may_alter_rtti
+	--->	may_alter_rtti
+	;	must_not_alter_rtti.
 
 :- type llds_proc_id	==	int.
 
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.194
diff -u -b -r1.194 llds_out.m
--- compiler/llds_out.m	2002/05/30 08:00:01	1.194
+++ compiler/llds_out.m	2002/06/19 15:25:30
@@ -434,7 +434,7 @@
 
 output_c_file_mercury_headers -->
 	globals__io_get_trace_level(TraceLevel),
-	( { trace_level_is_none(TraceLevel) = no } ->
+	( { given_trace_level_is_none(TraceLevel) = no } ->
 		io__write_string("#include ""mercury_imp.h""\n"),
 		io__write_string("#include ""mercury_trace_base.h""\n")
 	;
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.256
diff -u -b -r1.256 mercury_compile.m
--- compiler/mercury_compile.m	2002/06/26 08:31:23	1.256
+++ compiler/mercury_compile.m	2002/06/27 08:57:16
@@ -2219,7 +2219,7 @@
 	{ allocate_store_maps(final_allocation, ProcInfoStackSlot,
 		PredId, ModuleInfoSimplify, ProcInfoStoreAlloc) },
 	globals__io_get_trace_level(TraceLevel),
-	( { trace_level_is_none(TraceLevel) = no } ->
+	( { given_trace_level_is_none(TraceLevel) = no } ->
 		write_proc_progress_message(
 			"% Calculating goal paths in ",
 			PredId, ProcId, ModuleInfoSimplify),
@@ -3087,7 +3087,7 @@
 
 mercury_compile__maybe_goal_paths(HLDS0, Verbose, Stats, HLDS) -->
 	globals__io_get_trace_level(TraceLevel),
-	( { trace_level_is_none(TraceLevel) = no } ->
+	( { given_trace_level_is_none(TraceLevel) = no } ->
 		maybe_write_string(Verbose, "% Calculating goal paths..."),
 		maybe_flush_output(Verbose),
 		process_all_nonimported_procs(
Index: compiler/optimize.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/optimize.m,v
retrieving revision 1.32
diff -u -b -r1.32 optimize.m
--- compiler/optimize.m	2002/03/28 03:43:27	1.32
+++ compiler/optimize.m	2002/06/19 15:24:52
@@ -47,7 +47,7 @@
 
 optimize__proc(CProc0, GlobalData, CProc) -->
 	{ CProc0 = c_procedure(Name, Arity, PredProcId, Instrs0,
-		ProcLabel, C0, ContainsReconstruction) },
+		ProcLabel, C0, MayAlterRtti) },
 	optimize__init_opt_debug_info(Name, Arity, PredProcId, Instrs0, C0,
 		OptDebugInfo0),
 	globals__io_lookup_int_option(optimize_repeat, Repeat),
@@ -61,13 +61,13 @@
 	;
 		set__init(LayoutLabelSet)
 	},
-	optimize__repeat(Repeat, LayoutLabelSet, Instrs0, ProcLabel, C0, C1,
-		OptDebugInfo0, OptDebugInfo1, Instrs1),
+	optimize__repeat(Repeat, LayoutLabelSet, Instrs0, ProcLabel,
+		MayAlterRtti, C0, C1, OptDebugInfo0, OptDebugInfo1, Instrs1),
 	optimize__middle(Instrs1, yes, LayoutLabelSet, ProcLabel,
-		C1, C, OptDebugInfo1, OptDebugInfo, Instrs3),
+		MayAlterRtti, C1, C, OptDebugInfo1, OptDebugInfo, Instrs3),
 	optimize__last(Instrs3, LayoutLabelSet, C, OptDebugInfo, Instrs),
 	{ CProc = c_procedure(Name, Arity, PredProcId, Instrs,
-		ProcLabel, C, ContainsReconstruction) }.
+		ProcLabel, C, MayAlterRtti) }.
 
 %-----------------------------------------------------------------------------%
 
@@ -162,12 +162,12 @@
 %-----------------------------------------------------------------------------%
 
 :- pred optimize__repeat(int::in, set(label)::in, list(instruction)::in,
-	proc_label::in, counter::in, counter::out, opt_debug_info::in,
-	opt_debug_info::out, list(instruction)::out,
+	proc_label::in, may_alter_rtti::in, counter::in, counter::out,
+	opt_debug_info::in, opt_debug_info::out, list(instruction)::out,
 	io__state::di, io__state::uo) is det.
 
-optimize__repeat(Iter0, LayoutLabelSet, Instrs0, ProcLabel, C0, C,
-		OptDebugInfo0, OptDebugInfo, Instrs) -->
+optimize__repeat(Iter0, LayoutLabelSet, Instrs0, ProcLabel, MayAlterRtti,
+		C0, C, OptDebugInfo0, OptDebugInfo, Instrs) -->
 	( { Iter0 > 0 } ->
 		{ Iter1 = Iter0 - 1 },
 		( { Iter1 = 0 } ->
@@ -176,11 +176,12 @@
 			{ Final = no }
 		),
 		optimize__repeated(Instrs0, Final, LayoutLabelSet, ProcLabel,
-			C0, C1, OptDebugInfo0, OptDebugInfo1, Instrs1, Mod),
+			MayAlterRtti, C0, C1, OptDebugInfo0, OptDebugInfo1,
+			Instrs1, Mod),
 		( { Mod = yes } ->
 			optimize__repeat(Iter1, LayoutLabelSet, Instrs1,
-				ProcLabel, C1, C, OptDebugInfo1, OptDebugInfo,
-				Instrs)
+				ProcLabel, MayAlterRtti, C1, C,
+				OptDebugInfo1, OptDebugInfo, Instrs)
 		;
 			{ Instrs = Instrs1 },
 			{ C = C1 },
@@ -196,12 +197,12 @@
 	% to create more opportunities for use of the tailcall macro.
 
 :- pred optimize__repeated(list(instruction)::in, bool::in, set(label)::in,
-	proc_label::in, counter::in, counter::out,
+	proc_label::in, may_alter_rtti::in, counter::in, counter::out,
 	opt_debug_info::in, opt_debug_info::out, list(instruction)::out,
 	bool::out, io__state::di, io__state::uo) is det.
 
-optimize__repeated(Instrs0, Final, LayoutLabelSet, ProcLabel, C0, C,
-		OptDebugInfo0, OptDebugInfo, Instrs, Mod) -->
+optimize__repeated(Instrs0, Final, LayoutLabelSet, ProcLabel, MayAlterRtti,
+		C0, C, OptDebugInfo0, OptDebugInfo, Instrs, Mod) -->
 	{ opt_util__find_first_label(Instrs0, Label) },
 	{ opt_util__format_label(Label, LabelStr) },
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
@@ -211,7 +212,6 @@
 		PessimizeTailCalls),
 	globals__io_lookup_bool_option(checked_nondet_tailcalls,
 		CheckedNondetTailCalls),
-	globals__io_get_trace_level(TraceLevel),
 	( { Jumpopt = yes } ->
 		( { VeryVerbose = yes } ->
 			io__write_string("% Optimizing jumps for "),
@@ -220,9 +220,10 @@
 		;
 			[]
 		),
-		{ jumpopt_main(Instrs0, LayoutLabelSet, TraceLevel, ProcLabel,
-			C0, C1, FullJumpopt, Final, PessimizeTailCalls,
-			CheckedNondetTailCalls, Instrs1, Mod1) },
+		{ jumpopt_main(Instrs0, LayoutLabelSet, MayAlterRtti,
+			ProcLabel, C0, C1, FullJumpopt, Final,
+			PessimizeTailCalls, CheckedNondetTailCalls,
+			Instrs1, Mod1) },
 		optimize__maybe_opt_debug(Instrs1, C1, "after jump opt",
 			OptDebugInfo0, OptDebugInfo1)
 	;
@@ -293,12 +294,12 @@
 	maybe_report_stats(Statistics).
 
 :- pred optimize__middle(list(instruction)::in, bool::in, set(label)::in,
-	proc_label::in, counter::in, counter::out,
+	proc_label::in, may_alter_rtti::in, counter::in, counter::out,
 	opt_debug_info::in, opt_debug_info::out, list(instruction)::out,
 	io__state::di, io__state::uo) is det.
 
-optimize__middle(Instrs0, Final, LayoutLabelSet, ProcLabel, C0, C,
-		OptDebugInfo0, OptDebugInfo, Instrs) -->
+optimize__middle(Instrs0, Final, LayoutLabelSet, ProcLabel, MayAlterRtti,
+		C0, C, OptDebugInfo0, OptDebugInfo, Instrs) -->
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
 	{ opt_util__find_first_label(Instrs0, Label) },
 	{ opt_util__format_label(Label, LabelStr) },
@@ -321,7 +322,6 @@
 			PessimizeTailCalls),
 		globals__io_lookup_bool_option(checked_nondet_tailcalls,
 			CheckedNondetTailCalls),
-		globals__io_get_trace_level(TraceLevel),
 		( { Jumps = yes, FullJumpopt = yes } ->
 			( { VeryVerbose = yes } ->
 				io__write_string("% Optimizing jumps for "),
@@ -330,7 +330,7 @@
 			;
 				[]
 			),
-			{ jumpopt_main(Instrs1, LayoutLabelSet, TraceLevel,
+			{ jumpopt_main(Instrs1, LayoutLabelSet, MayAlterRtti,
 				ProcLabel, C1, C2, FullJumpopt, Final,
 				PessimizeTailCalls, CheckedNondetTailCalls,
 				Instrs2, _Mod2) },
Index: compiler/stack_alloc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_alloc.m,v
retrieving revision 1.1
diff -u -b -r1.1 stack_alloc.m
--- compiler/stack_alloc.m	2002/03/28 03:43:37	1.1
+++ compiler/stack_alloc.m	2002/06/19 16:08:22
@@ -54,14 +54,17 @@
 allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, ProcInfo0, ProcInfo,
 		IO, IO) :-
 	initial_liveness(ProcInfo0, PredId, ModuleInfo, Liveness0),
+	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	module_info_globals(ModuleInfo, Globals),
 	globals__get_trace_level(Globals, TraceLevel),
-	( trace_level_needs_input_vars(TraceLevel) = yes ->
+	(
+		eff_trace_level_needs_input_vars(PredInfo, ProcInfo0,
+			TraceLevel) = yes
+	->
 		trace__fail_vars(ModuleInfo, ProcInfo0, FailVars)
 	;
 		set__init(FailVars)
 	),
-	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness),
 	globals__lookup_bool_option(Globals, opt_no_return_calls,
 		OptNoReturnCalls),
@@ -76,9 +79,9 @@
 	proc_info_set_goal(ProcInfo0, Goal, ProcInfo3),
 	SimpleStackAlloc = stack_alloc(LiveSets0),
 
-	trace__do_we_need_maxfr_slot(Globals, ProcInfo3, ProcInfo4),
-	trace__reserved_slots(ModuleInfo, ProcInfo4, Globals, NumReservedSlots,
-		MaybeReservedVarInfo),
+	trace__do_we_need_maxfr_slot(Globals, PredInfo, ProcInfo3, ProcInfo4),
+	trace__reserved_slots(ModuleInfo, PredInfo, ProcInfo4, Globals,
+		NumReservedSlots, MaybeReservedVarInfo),
 	(
 		MaybeReservedVarInfo = yes(ResVar - _),
 		set__singleton_set(ResVarSet, ResVar),
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.68
diff -u -b -r1.68 stack_layout.m
--- compiler/stack_layout.m	2002/05/16 13:14:48	1.68
+++ compiler/stack_layout.m	2002/06/19 16:20:01
@@ -78,7 +78,6 @@
 	globals__lookup_bool_option(Globals, procid_stack_layout,
 		ProcIdLayout),
 	globals__get_trace_level(Globals, TraceLevel),
-	globals__get_trace_suppress(Globals, TraceSuppress),
 	globals__have_static_code_addresses(Globals, StaticCodeAddr),
 	map__init(LayoutLabels0),
 
@@ -87,8 +86,7 @@
 	StringTable0 = string_table(StringMap0, [], 0),
 	LayoutInfo0 = stack_layout_info(ModuleInfo0,
 		AgcLayout, TraceLayout, ProcIdLayout,
-		TraceLevel, TraceSuppress, StaticCodeAddr,
-		[], [], [], LayoutLabels0, [],
+		StaticCodeAddr, [], [], [], LayoutLabels0, [],
 		StringTable0, LabelTables0, map__init),
 	stack_layout__lookup_string_in_table("", _, LayoutInfo0, LayoutInfo1),
 	stack_layout__lookup_string_in_table("<too many variables>", _,
@@ -249,8 +247,9 @@
 stack_layout__construct_layouts(ProcLayoutInfo) -->
 	{ ProcLayoutInfo = proc_layout_info(RttiProcLabel, EntryLabel, Detism,
 		StackSlots, SuccipLoc, EvalMethod, MaybeCallLabel, MaxTraceReg,
-		HeadVars, Goal, InstMap, TraceSlotInfo, ForceProcIdLayout,
-		VarSet, VarTypes, InternalMap, MaybeTableIoDecl) },
+		HeadVars, MaybeGoal, InstMap, TraceSlotInfo, ForceProcIdLayout,
+		VarSet, VarTypes, InternalMap, MaybeTableIoDecl, IsBeingTraced,
+		NeedsAllNames) },
 	{ map__to_assoc_list(InternalMap, Internals) },
 	stack_layout__set_cur_proc_named_vars(map__init),
 
@@ -266,7 +265,13 @@
 		stack_layout__get_trace_stack_layout(TraceLayout),
 		{
 			TraceLayout = yes,
+			(
+				IsBeingTraced = no,
+				Kind = proc_layout_proc_id(UserOrCompiler)
+			;
+				IsBeingTraced = yes,
 			Kind = proc_layout_exec_trace(UserOrCompiler)
+			)
 		;
 			TraceLayout = no,
 			Kind = proc_layout_proc_id(UserOrCompiler)
@@ -286,9 +291,9 @@
 	stack_layout__set_label_tables(LabelTables),
 	stack_layout__construct_proc_layout(RttiProcLabel, EntryLabel,
 		ProcLabel, Detism, StackSlots, SuccipLoc, EvalMethod,
-		MaybeCallLabel, MaxTraceReg, HeadVars, Goal, InstMap,
+		MaybeCallLabel, MaxTraceReg, HeadVars, MaybeGoal, InstMap,
 		TraceSlotInfo, VarSet, VarTypes, NamedVars, MaybeTableIoDecl,
-		Kind).
+		Kind, NeedsAllNames).
 
 %---------------------------------------------------------------------------%
 
@@ -388,15 +393,16 @@
 :- pred stack_layout__construct_proc_layout(rtti_proc_label::in, label::in,
 	proc_label::in, determinism::in, int::in, maybe(int)::in,
 	eval_method::in, maybe(label)::in, int::in, list(prog_var)::in,
-	hlds_goal::in, instmap::in, trace_slot_info::in, prog_varset::in,
+	maybe(hlds_goal)::in, instmap::in, trace_slot_info::in, prog_varset::in,
 	vartypes::in, map(int, string)::in, maybe(table_io_decl_info)::in,
-	proc_layout_kind::in, stack_layout_info::in, stack_layout_info::out)
-	is det.
+	proc_layout_kind::in, bool::in, stack_layout_info::in,
+	stack_layout_info::out) is det.
 
 stack_layout__construct_proc_layout(RttiProcLabel, EntryLabel, ProcLabel,
 		Detism, StackSlots, MaybeSuccipLoc, EvalMethod, MaybeCallLabel,
-		MaxTraceReg, HeadVars, Goal, InstMap, TraceSlotInfo, VarSet,
-		VarTypes, UsedVarNames, MaybeTableIoDeclInfo, Kind) -->
+		MaxTraceReg, HeadVars, MaybeGoal, InstMap, TraceSlotInfo,
+		VarSet, VarTypes, UsedVarNames, MaybeTableIoDeclInfo, Kind,
+		NeedsAllNames) -->
 	{
 		MaybeSuccipLoc = yes(Location)
 	->
@@ -454,9 +460,9 @@
 	;
 		{ Kind = proc_layout_exec_trace(_) },
 		stack_layout__construct_trace_layout(RttiProcLabel, EvalMethod,
-			MaybeCallLabel, MaxTraceReg, HeadVars, Goal, InstMap,
-			TraceSlotInfo, VarSet, VarTypes, UsedVarNames,
-			MaybeTableIoDeclInfo, ExecTrace),
+			MaybeCallLabel, MaxTraceReg, HeadVars, MaybeGoal,
+			InstMap, TraceSlotInfo, VarSet, VarTypes, UsedVarNames,
+			MaybeTableIoDeclInfo, NeedsAllNames, ExecTrace),
 		{ MaybeRest = proc_id_and_exec_trace(ExecTrace) }
 	),
 
@@ -476,25 +482,23 @@
 
 :- pred stack_layout__construct_trace_layout(rtti_proc_label::in,
 	eval_method::in, maybe(label)::in, int::in, list(prog_var)::in,
-	hlds_goal::in, instmap::in, trace_slot_info::in, prog_varset::in,
+	maybe(hlds_goal)::in, instmap::in, trace_slot_info::in, prog_varset::in,
 	vartypes::in, map(int, string)::in, maybe(table_io_decl_info)::in,
-	proc_layout_exec_trace::out,
+	bool::in, proc_layout_exec_trace::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_trace_layout(RttiProcLabel, EvalMethod, MaybeCallLabel,
-		MaxTraceReg, HeadVars, Goal, InstMap, TraceSlotInfo, VarSet,
-		VarTypes, UsedVarNameMap, MaybeTableIoDecl, ExecTrace) -->
+		MaxTraceReg, HeadVars, MaybeGoal, InstMap, TraceSlotInfo,
+		VarSet, VarTypes, UsedVarNameMap, MaybeTableIoDecl,
+		NeedsAllNames, ExecTrace) -->
 	stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap,
-		MaxVarNum, VarNameVector),
+		NeedsAllNames, MaxVarNum, VarNameVector),
 	{ list__map(term__var_to_int, HeadVars, HeadVarNumVector) },
-	stack_layout__get_trace_level(TraceLevel),
-	stack_layout__get_trace_suppress(TraceSuppress),
-	{ BodyReps = trace_needs_proc_body_reps(TraceLevel, TraceSuppress) },
 	(
-		{ BodyReps = no },
+		{ MaybeGoal = no },
 		{ MaybeProcRepRval = no }
 	;
-		{ BodyReps = yes },
+		{ MaybeGoal = yes(Goal) },
 		stack_layout__get_module_info(ModuleInfo),
 		{ prog_rep__represent_proc(HeadVars, Goal, InstMap, VarTypes,
 			ModuleInfo, ProcRep) },
@@ -530,15 +534,11 @@
 		MaybeCallTableSlot) }.
 
 :- pred stack_layout__construct_var_name_vector(prog_varset::in,
-	map(int, string)::in, int::out, list(int)::out,
+	map(int, string)::in, bool::in, int::out, list(int)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap, Count, Offsets)
-		-->
-	stack_layout__get_trace_level(TraceLevel),
-	stack_layout__get_trace_suppress(TraceSuppress),
-	{ NeedsAllNames = trace_needs_all_var_names(TraceLevel,
-		TraceSuppress) },
+stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap, NeedsAllNames,
+		Count, Offsets) -->
 	(
 		{ NeedsAllNames = yes },
 		{ varset__var_name_list(VarSet, VarNameList) },
@@ -1467,8 +1467,6 @@
 		agc_stack_layout	:: bool, % generate agc info?
 		trace_stack_layout	:: bool, % generate tracing info?
 		procid_stack_layout	:: bool, % generate proc id info?
-		trace_level		:: trace_level,
-		trace_suppress_items	:: trace_suppress_items,
 		static_code_addresses	:: bool, % have static code addresses?
 		table_io_decls		:: list(comp_gen_c_data),
 		proc_layouts		:: list(comp_gen_c_data),
@@ -1505,12 +1503,6 @@
 :- pred stack_layout__get_procid_stack_layout(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-:- pred stack_layout__get_trace_level(trace_level::out,
-	stack_layout_info::in, stack_layout_info::out) is det.
-
-:- pred stack_layout__get_trace_suppress(trace_suppress_items::out,
-	stack_layout_info::in, stack_layout_info::out) is det.
-
 :- pred stack_layout__get_static_code_addresses(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
@@ -1539,8 +1531,6 @@
 stack_layout__get_agc_stack_layout(LI ^ agc_stack_layout, LI, LI).
 stack_layout__get_trace_stack_layout(LI ^ trace_stack_layout, LI, LI).
 stack_layout__get_procid_stack_layout(LI ^ procid_stack_layout, LI, LI).
-stack_layout__get_trace_level(LI ^ trace_level, LI, LI).
-stack_layout__get_trace_suppress(LI ^ trace_suppress_items, LI, LI).
 stack_layout__get_static_code_addresses(LI ^ static_code_addresses, LI, LI).
 stack_layout__get_table_io_decl_data(LI ^ table_io_decls, LI, LI).
 stack_layout__get_proc_layout_data(LI ^ proc_layouts, LI, LI).
Index: compiler/stack_opt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_opt.m,v
retrieving revision 1.3
diff -u -b -r1.3 stack_opt.m
--- compiler/stack_opt.m	2002/06/30 17:06:40	1.3
+++ compiler/stack_opt.m	2002/06/30 23:18:15
@@ -93,7 +93,7 @@
 :- import_module ll_backend__store_alloc.
 :- import_module backend_libs__code_model.
 :- import_module backend_libs__matching.
-:- import_module libs__trace_params, libs__globals, libs__options.
+:- import_module libs__globals, libs__options.
 
 :- import_module counter, bool, int, list, assoc_list.
 :- import_module map, set, std_util, require, term, varset.
@@ -324,8 +324,8 @@
 		optimize_saved_vars_cell_full_path, FullPath),
 	globals__lookup_bool_option(Globals,
 		optimize_saved_vars_cell_on_stack, OnStack),
-	globals__get_trace_level(Globals, TraceLevel),
-	OptNoReturnCalls = trace_level_is_none(TraceLevel),
+	globals__lookup_bool_option(Globals,
+		opt_no_return_calls, OptNoReturnCalls),
 	OptParams = opt_params(ModuleInfo, VarTypes0, MatchingParams,
 		AllPathNodeRatio, FixpointLoop, FullPath, OnStack,
 		OptNoReturnCalls, NonCandidateVars),
Index: compiler/store_alloc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/store_alloc.m,v
retrieving revision 1.79
diff -u -b -r1.79 store_alloc.m
--- compiler/store_alloc.m	2002/03/28 03:43:38	1.79
+++ compiler/store_alloc.m	2002/06/19 15:29:14
@@ -78,7 +78,8 @@
 	),
 	initial_liveness(ProcInfo0, PredId, ModuleInfo, Liveness0),
 	globals__get_trace_level(Globals, TraceLevel),
-	( trace_level_is_none(TraceLevel) = no ->
+	module_info_pred_info(ModuleInfo, PredId, PredInfo),
+	( eff_trace_level_is_none(PredInfo, ProcInfo0, TraceLevel) = no ->
 		trace__fail_vars(ModuleInfo, ProcInfo0, ResumeVars0)
 	;
 		set__init(ResumeVars0)
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.52
diff -u -b -r1.52 trace.m
--- compiler/trace.m	2002/05/16 13:14:50	1.52
+++ compiler/trace.m	2002/06/19 15:29:49
@@ -129,7 +129,7 @@
 
 	% Figure out whether we need a slot for storing the value of maxfr
 	% on entry, and record the result in the proc info.
-:- pred trace__do_we_need_maxfr_slot(globals::in, proc_info::in,
+:- pred trace__do_we_need_maxfr_slot(globals::in, pred_info::in, proc_info::in,
 	proc_info::out) is det.
 
 	% Return the number of slots reserved for tracing information.
@@ -138,17 +138,17 @@
 	% It is possible that one of these reserved slots contains a variable.
 	% If so, the variable and its slot number are returned in the last
 	% argument.
-:- pred trace__reserved_slots(module_info::in, proc_info::in, globals::in,
-	int::out, maybe(pair(prog_var, int))::out) is det.
+:- pred trace__reserved_slots(module_info::in, pred_info::in, proc_info::in,
+	globals::in, int::out, maybe(pair(prog_var, int))::out) is det.
 
 	% Construct and return an abstract struct that represents the
 	% tracing-specific part of the code generator state. Return also
 	% info about the non-fixed slots used by the tracing system,
 	% for eventual use in the constructing the procedure's layout
 	% structure.
-:- pred trace__setup(module_info::in, proc_info::in, globals::in,
-	trace_slot_info::out, trace_info::out, code_info::in, code_info::out)
-	is det.
+:- pred trace__setup(module_info::in, pred_info::in, proc_info::in,
+	globals::in, trace_slot_info::out, trace_info::out,
+	code_info::in, code_info::out) is det.
 
 	% Generate code to fill in the reserved stack slots.
 :- pred trace__generate_slot_fill_code(trace_info::in, code_tree::out,
@@ -252,11 +252,11 @@
 		error("length mismatch in trace__fail_vars")
 	).
 
-trace__do_we_need_maxfr_slot(Globals, ProcInfo0, ProcInfo) :-
+trace__do_we_need_maxfr_slot(Globals, PredInfo0, ProcInfo0, ProcInfo) :-
 	globals__get_trace_level(Globals, TraceLevel),
 	proc_info_interface_code_model(ProcInfo0, CodeModel),
 	(
-		trace_level_is_none(TraceLevel) = no,
+		eff_trace_level_is_none(PredInfo0, ProcInfo0, TraceLevel) = no,
 		CodeModel \= model_non,
 		proc_info_goal(ProcInfo0, Goal),
 		code_util__goal_may_alloc_temp_frame(Goal)
@@ -342,12 +342,13 @@
 	% which answers such questions, for later inclusion in the
 	% procedure's layout structure.
 
-trace__reserved_slots(_ModuleInfo, ProcInfo, Globals, ReservedSlots,
+trace__reserved_slots(_ModuleInfo, PredInfo, ProcInfo, Globals, ReservedSlots,
 		MaybeTableVarInfo) :-
 	globals__get_trace_level(Globals, TraceLevel),
 	globals__get_trace_suppress(Globals, TraceSuppress),
 	globals__lookup_bool_option(Globals, trace_table_io, TraceTableIo),
-	FixedSlots = trace_level_needs_fixed_slots(TraceLevel),
+	FixedSlots = eff_trace_level_needs_fixed_slots(PredInfo, ProcInfo,
+		TraceLevel),
 	(
 		FixedSlots = no,
 		ReservedSlots = 0,
@@ -357,13 +358,17 @@
 		Fixed = 3, % event#, call#, call depth
 		(
 			proc_info_interface_code_model(ProcInfo, model_non),
-			trace_needs_port(TraceLevel, TraceSuppress, redo) = yes
+			eff_trace_needs_port(PredInfo, ProcInfo, TraceLevel,
+				TraceSuppress, redo) = yes
 		->
 			RedoLayout = 1
 		;
 			RedoLayout = 0
 		),
-		( trace_level_needs_from_full_slot(TraceLevel) = yes ->
+		(
+			eff_trace_level_needs_from_full_slot(PredInfo,
+				ProcInfo, TraceLevel) = yes
+		->
 			FromFull = 1
 		;
 			FromFull = 0
@@ -399,12 +404,14 @@
 		)
 	).
 
-trace__setup(_ModuleInfo, ProcInfo, Globals, TraceSlotInfo, TraceInfo) -->
+trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo,
+		TraceInfo) -->
 	code_info__get_proc_model(CodeModel),
 	{ globals__get_trace_level(Globals, TraceLevel) },
 	{ globals__get_trace_suppress(Globals, TraceSuppress) },
 	{ globals__lookup_bool_option(Globals, trace_table_io, TraceTableIo) },
-	{ trace_needs_port(TraceLevel, TraceSuppress, redo) = TraceRedo },
+	{ TraceRedo = eff_trace_needs_port(PredInfo, ProcInfo, TraceLevel,
+		TraceSuppress, redo) },
 	(
 		{ TraceRedo = yes },
 		{ CodeModel = model_non }
@@ -416,7 +423,8 @@
 		{ MaybeRedoLayoutLabel = no },
 		{ NextSlotAfterRedoLayout = 4 }
 	),
-	{ trace_level_needs_from_full_slot(TraceLevel) = FromFullSlot },
+	{ FromFullSlot = eff_trace_level_needs_from_full_slot(PredInfo,
+		ProcInfo, TraceLevel) },
 	{
 		FromFullSlot = no,
 		MaybeFromFullSlot = no,
@@ -664,7 +672,10 @@
 			error("trace__generate_internal_event_code: bad path")
 		},
 		(
-			{ trace_needs_port(TraceInfo ^ trace_level,
+			code_info__get_pred_info(PredInfo),
+			code_info__get_proc_info(ProcInfo),
+			{ eff_trace_needs_port(PredInfo, ProcInfo,
+				TraceInfo ^ trace_level,
 				TraceInfo ^ trace_suppress_items, Port) = yes }
 		->
 			{ goal_info_get_pre_deaths(GoalInfo, PreDeaths) },
@@ -690,7 +701,10 @@
 			NegPort = neg_success,
 			Port = neg_success
 		},
-		{ trace_needs_port(TraceInfo ^ trace_level,
+		code_info__get_pred_info(PredInfo),
+		code_info__get_proc_info(ProcInfo),
+		{ eff_trace_needs_port(PredInfo, ProcInfo,
+			TraceInfo ^ trace_level,
 			TraceInfo ^ trace_suppress_items, Port) = yes }
 	->
 		{ Goal = _ - GoalInfo },
@@ -707,7 +721,10 @@
 	(
 		{ MaybeTraceInfo = yes(TraceInfo) },
 		{ trace__convert_nondet_pragma_port_type(PragmaPort, Port) },
-		{ trace_needs_port(TraceInfo ^ trace_level,
+		code_info__get_pred_info(PredInfo),
+		code_info__get_proc_info(ProcInfo),
+		{ eff_trace_needs_port(PredInfo, ProcInfo,
+			TraceInfo ^ trace_level,
 			TraceInfo ^ trace_suppress_items, Port) = yes }
 	->
 		trace__generate_event_code(Port, nondet_pragma, TraceInfo,
@@ -720,7 +737,10 @@
 		MaybeExternalInfo) -->
 	{ trace__convert_external_port_type(ExternalPort, Port) },
 	(
-		{ trace_needs_port(TraceInfo ^ trace_level,
+		code_info__get_pred_info(PredInfo),
+		code_info__get_proc_info(ProcInfo),
+		{ eff_trace_needs_port(PredInfo, ProcInfo,
+			TraceInfo ^ trace_level,
 			TraceInfo ^ trace_suppress_items, Port) = yes }
 	->
 		trace__generate_event_code(Port, external, TraceInfo,
Index: compiler/trace_params.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace_params.m,v
retrieving revision 1.9
diff -u -b -r1.9 trace_params.m
--- compiler/trace_params.m	2002/06/05 16:41:14	1.9
+++ compiler/trace_params.m	2002/07/04 03:59:46
@@ -10,6 +10,23 @@
 %
 % This module defines the parameters of execution tracing at various trace
 % levels and with various settings of the --suppress-trace option.
+%
+% Many of the functions defined in this module work not with the global trace
+% level, but with effective trace levels. In most cases the trace level we want
+% to apply to a procedure (which is its effective trace level) is the same as
+% the global trace level. However, if the global trace level is shallow, then
+% we optimize the handling of procedures that cannot be called from deep traced
+% contexts. If a procedure is neither exported nor has its address taken, then
+% it can only be called from other procedures in its module. If the module is
+% shallow traced, this guarantees that we will never get any events from the
+% procedure, so there is no point in including any tracing code in it in the
+% first place. We therefore make its effective trace level "none" for must
+% purposes (the purposes whose functions test effective trace levels). Apart
+% from avoiding the overhead of calls to MR_trace, this also allows the code
+% generator to preserve tail recursion optimization. However, we continue to
+% generate the data structures that enable the debugger to walk the stack for
+% such procedures. We accomplish this by making the relevant test work on the
+% global trace level, not effective trace levels.
 
 %-----------------------------------------------------------------------------%
 
@@ -17,6 +34,7 @@
 
 :- interface.
 
+:- import_module hlds__hlds_pred.
 :- import_module ll_backend__llds. % XXX for trace_port
 :- import_module bool.
 
@@ -29,21 +47,34 @@
 :- pred convert_trace_suppress(string::in, trace_suppress_items::out)
 	is semidet.
 
-	% These functions check for various properties of the trace level.
-:- func trace_level_is_none(trace_level) = bool.
-:- func trace_level_needs_input_vars(trace_level) = bool.
-:- func trace_level_needs_fixed_slots(trace_level) = bool.
-:- func trace_level_needs_from_full_slot(trace_level) = bool.
+	% These functions check for various properties of the global
+	% trace level.
+:- func given_trace_level_is_none(trace_level) = bool.
 :- func trace_level_allows_delay_death(trace_level) = bool.
 :- func trace_needs_return_info(trace_level, trace_suppress_items) = bool.
-:- func trace_needs_all_var_names(trace_level, trace_suppress_items) = bool.
-:- func trace_needs_proc_body_reps(trace_level, trace_suppress_items) = bool.
-:- func trace_needs_port(trace_level, trace_suppress_items, trace_port) = bool.
 
 	% Should optimization passes maintain meaningful
 	% variable names where possible.
 :- func trace_level_needs_meaningful_var_names(trace_level) = bool.
 
+	% These functions check for various properties of the given procedure's
+	% effective trace level.
+:- func eff_trace_level_is_none(pred_info, proc_info, trace_level) = bool.
+:- func eff_trace_level_needs_input_vars(pred_info, proc_info, trace_level)
+	= bool.
+:- func eff_trace_level_needs_fixed_slots(pred_info, proc_info, trace_level)
+	= bool.
+:- func eff_trace_level_needs_from_full_slot(pred_info, proc_info, trace_level)
+	= bool.
+:- func eff_trace_needs_all_var_names(pred_info, proc_info, trace_level,
+	trace_suppress_items) = bool.
+:- func eff_trace_needs_proc_body_reps(pred_info, proc_info, trace_level,
+	trace_suppress_items) = bool.
+:- func eff_trace_needs_port(pred_info, proc_info, trace_level,
+	trace_suppress_items, trace_port) = bool.
+
+:- func eff_trace_level(pred_info, proc_info, trace_level) = trace_level.
+
 :- func trace_level_none = trace_level.
 
 	% This is used to represent the trace level in the module layout.
@@ -78,6 +109,53 @@
 convert_trace_level("rep", _, decl_rep).
 convert_trace_level("default", no, none).
 convert_trace_level("default", yes, deep).
+
+eff_trace_level(PredInfo, ProcInfo, TraceLevel) = EffTraceLevel :-
+	(
+		TraceLevel = shallow,
+		pred_info_import_status(PredInfo, Status),
+		status_is_exported(Status, no),
+		proc_info_is_address_taken(ProcInfo, address_is_not_taken)
+	->
+		EffTraceLevel = none
+	;
+		EffTraceLevel = TraceLevel
+	).
+
+given_trace_level_is_none(TraceLevel) =
+	trace_level_is_none(TraceLevel).
+
+eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel) =
+	trace_level_is_none(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel)).
+eff_trace_level_needs_input_vars(PredInfo, ProcInfo, TraceLevel) =
+	trace_level_needs_input_vars(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel)).
+eff_trace_level_needs_fixed_slots(PredInfo, ProcInfo, TraceLevel) =
+	trace_level_needs_fixed_slots(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel)).
+eff_trace_level_needs_from_full_slot(PredInfo, ProcInfo, TraceLevel) =
+	trace_level_needs_from_full_slot(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel)).
+eff_trace_needs_all_var_names(PredInfo, ProcInfo, TraceLevel, SuppressItems) =
+	trace_needs_all_var_names(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel),
+		SuppressItems).
+eff_trace_needs_proc_body_reps(PredInfo, ProcInfo, TraceLevel, SuppressItems) =
+	trace_needs_proc_body_reps(
+		eff_trace_level(PredInfo, ProcInfo, TraceLevel),
+		SuppressItems).
+eff_trace_needs_port(PredInfo, ProcInfo, TraceLevel, SuppressItems, Port) =
+	trace_needs_port(eff_trace_level(PredInfo, ProcInfo, TraceLevel),
+		SuppressItems, Port).
+
+:- func trace_level_is_none(trace_level) = bool.
+:- func trace_level_needs_input_vars(trace_level) = bool.
+:- func trace_level_needs_fixed_slots(trace_level) = bool.
+:- func trace_level_needs_from_full_slot(trace_level) = bool.
+:- func trace_needs_all_var_names(trace_level, trace_suppress_items) = bool.
+:- func trace_needs_proc_body_reps(trace_level, trace_suppress_items) = bool.
+:- func trace_needs_port(trace_level, trace_suppress_items, trace_port) = bool.
 
 trace_level_is_none(none) = yes.
 trace_level_is_none(shallow) = no.
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
Index: tests/debugger/shallow.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/shallow.exp,v
retrieving revision 1.4
diff -u -b -r1.4 shallow.exp
--- tests/debugger/shallow.exp	1999/12/13 07:43:40	1.4
+++ tests/debugger/shallow.exp	2002/06/19 19:06:33
@@ -1,10 +1,17 @@
-       1:      1  1 CALL pred shallow:main/2-0 (cc_multi) shallow.m:17
+       1:      1  1 CALL pred shallow:main/2-0 (cc_multi) shallow.m:18
 mdb> echo on
 Command echo enabled.
 mdb> context before
 Contexts will be printed before, on the same line.
 mdb> context
 Contexts are printed before, on the same line.
-mdb> c -a
+mdb> step
+       2:      2  2 CALL shallow2.m:14 pred shallow2:safe/1-0 (semidet)
+mdb> print *
+       HeadVar__1             	[1, 2, 3, 4, 5]
+mdb> stack
+   0       pred shallow2:safe/1-0 (semidet) (shallow2.m:14)
+   1       pred shallow:queen/2-0 (nondet)
+   2       pred shallow:main/2-0 (cc_multi) (shallow.m:16)
+mdb> c -S
 [1, 3, 5, 2, 4]
-       2:      1  1 EXIT shallow.m:17 pred shallow:main/2-0 (cc_multi)
Index: tests/debugger/shallow.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/shallow.exp2,v
retrieving revision 1.3
diff -u -b -r1.3 shallow.exp2
--- tests/debugger/shallow.exp2	1999/12/13 07:43:41	1.3
+++ tests/debugger/shallow.exp2	2002/06/19 19:21:19
@@ -1,10 +1,17 @@
-       1:      1  1 CALL pred shallow:main/2-0 (cc_multi) shallow.m:17
+       1:      1  1 CALL pred shallow:main/2-0 (cc_multi) shallow.m:18
 mdb> echo on
 Command echo enabled.
 mdb> context before
 Contexts will be printed before, on the same line.
 mdb> context
 Contexts are printed before, on the same line.
-mdb> c -a
+mdb> step
+       2:      2  2 CALL shallow2.m:14 pred shallow2:safe/1-0 (semidet)
+mdb> print *
+       HeadVar__1             	[1, 2, 3, 4, 5]
+mdb> stack
+   0       pred shallow2:safe/1-0 (semidet) (shallow2.m:14)
+   1       pred shallow:queen/2-0 (nondet)
+   2       pred shallow:main/2-0 (cc_multi) (shallow.m:16)
+mdb> c -S
 [1, 3, 5, 2, 4]
-       2:      1  1 EXIT shallow.m:17 pred shallow:main/2-0 (cc_multi)
Index: tests/debugger/shallow.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/shallow.inp,v
retrieving revision 1.3
diff -u -b -r1.3 shallow.inp
--- tests/debugger/shallow.inp	1999/11/15 00:43:49	1.3
+++ tests/debugger/shallow.inp	2002/06/19 19:06:00
@@ -1,4 +1,7 @@
 echo on
 context before
 context
-c -a
+step
+print *
+stack
+c -S
Index: tests/debugger/shallow.m
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/shallow.m,v
retrieving revision 1.1
diff -u -b -r1.1 shallow.m
--- tests/debugger/shallow.m	1999/08/24 09:40:47	1.1
+++ tests/debugger/shallow.m	2002/06/19 16:24:21
@@ -9,6 +9,7 @@
 
 :- implementation.
 
+:- import_module shallow2.
 :- import_module list, int.
 
 main -->
@@ -30,12 +31,6 @@
 :- pred qdelete(T, list(T), list(T)).
 :- mode qdelete(out, in, out) is nondet.
 
-:- pred safe(list(int)).
-:- mode safe(in) is semidet.
-
-:- pred nodiag(int, int, list(int)).
-:- mode nodiag(in, in, in) is semidet.
-
 data([1,2,3,4,5]).
 
 queen(Data, Out) :-
@@ -51,25 +46,6 @@
 qdelete(A, [A|L], L).
 qdelete(X, [A|Z], [A|R]) :-
 	qdelete(X, Z, R).
-
-safe([]).
-safe([N|L]) :-
-	nodiag(N, 1, L),
-	safe(L).
-
-nodiag(_, _, []).
-nodiag(B, D, [N|L]) :-
-	NmB is N - B,
-	BmN is B - N,
-	( D = NmB ->
-		fail
-	; D = BmN ->
-		fail
-	;
-		true
-	),
-	D1 is D + 1,
-	nodiag(B, D1, L).
 
 :- pred print_list(list(int), io__state, io__state).
 :- mode print_list(in, di, uo) is det.
Index: tests/debugger/shallow2.m
===================================================================
RCS file: shallow2.m
diff -N shallow2.m
--- /dev/null	Fri Dec  1 02:25:58 2000
+++ shallow2.m	Thu Jun 20 02:25:08 2002
@@ -0,0 +1,34 @@
+:- module shallow2.
+
+:- interface.
+
+:- import_module list.
+
+:- pred safe(list(int)).
+:- mode safe(in) is semidet.
+
+:- implementation.
+
+:- import_module int.
+
+safe([]).
+safe([N|L]) :-
+	nodiag(N, 1, L),
+	safe(L).
+
+:- pred nodiag(int, int, list(int)).
+:- mode nodiag(in, in, in) is semidet.
+
+nodiag(_, _, []).
+nodiag(B, D, [N|L]) :-
+	NmB is N - B,
+	BmN is B - N,
+	( D = NmB ->
+		fail
+	; D = BmN ->
+		fail
+	;
+		true
+	),
+	D1 is D + 1,
+	nodiag(B, D1, L).
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
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
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: 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