Get the purity check pass to not issue warnings about unnecessary purity

Estimated hours taken: 16
Branches: main

Get the purity check pass to not issue warnings about unnecessary purity
annotations on compiler-generated predicates. The problem I am addressing
is that when an optimization such as type specialization creates a clone of
a predicate, that predicate gets all the original predicate's annotations.
During the creation of a .opt file, purity checking sees the clauses of the
original predicate and knows that the annotation is not redundant, but doesn't
know that about the copy, since it has no definition at all (it doesn't need
one).

The fix is to put into each pred_info an indication of where the predicate
came from, and to never warn about unnecessary purity annotations of predicates
that the programmer didn't write.

This diff also uses the origin indication to record human-usable names of
compiler-generated or compiler-transformed predicates in RTTI for use by the
debugger.

compiler/hlds_pred.m:
	Replace two fields in pred_infos, that say (a) whether the predicate
	is a special (unify/compare/index/init) predicate and (b) whether
	it is a type class method implementation, with an origin field saying
	where the predicate came from. This field has several alternatives,
	special preds and type class method implementation being only two.

	Make the predicates that create pred_infos take an argument specifing
	where the predicate comes from.

	Replace a copy of one of the old fields in rtti_proc_labels with
	the new one.

	Make the name of the existing function more descriptive.

compiler/purity.m:
	Use the origin field to suppress unnecessary annotation warnings for
	compiler-generated predicates.

compiler/layout_out.m:
	Use the origin field to generate more human-friendly names for
	predicates, instead of the existing linker-friendly names. The
	debugger doesn't insist on predicate names being unique, even
	within a module.

compiler/*.m:
	Conform to the changed interface of hlds_pred.m. The most significant
	changes were for recording the origin of new predicates. In one case
	(dnf.m) it also involved passing the required information down to the
	place where the new predicates were created through the dnf_info tuple
	instead of separate arguments, and switching to state variable
	notation.

tests/debugger/*.exp*:
tests/debugger/declarative/*.exp*:
tests/hard_coded/*.exp*:
	Update the expected outputs to expect human-friendly predicate names.
This commit is contained in:
Zoltan Somogyi
2005-01-21 06:21:00 +00:00
parent 9f34e99391
commit 9521818650
59 changed files with 742 additions and 576 deletions

View File

@@ -379,7 +379,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0,
ProcLabel, !GlobalData),
Name = pred_info_name(PredInfo),
Arity = pred_info_arity(PredInfo),
Arity = pred_info_orig_arity(PredInfo),
code_info__get_label_counter(CodeInfo, LabelCounter),
(
@@ -425,7 +425,7 @@ maybe_set_trace_level(PredInfo, !ModuleInfo) :-
(
PredModule = pred_info_module(PredInfo),
PredName = pred_info_name(PredInfo),
PredArity = pred_info_arity(PredInfo),
PredArity = pred_info_orig_arity(PredInfo),
no_type_info_builtin(PredModule, PredName, PredArity)
->
% These predicates should never be traced,
@@ -436,13 +436,11 @@ maybe_set_trace_level(PredInfo, !ModuleInfo) :-
globals__set_trace_level_none(Globals0, Globals1),
module_info_set_globals(Globals1, !ModuleInfo)
;
pred_info_get_maybe_special_pred(PredInfo, yes(_)),
pred_info_get_origin(PredInfo, special_pred(_)),
globals__get_trace_level(Globals0, TraceLevel),
UC_TraceLevel =
trace_level_for_unify_compare(TraceLevel)
UC_TraceLevel = trace_level_for_unify_compare(TraceLevel)
->
globals__set_trace_level(UC_TraceLevel,
Globals0, Globals1),
globals__set_trace_level(UC_TraceLevel, Globals0, Globals1),
module_info_set_globals(Globals1, !ModuleInfo)
;
true
@@ -830,7 +828,7 @@ code_gen__generate_entry(CI, CodeModel, Goal, OutsideResumePoint, FrameInfo,
module_info_pred_info(ModuleInfo, PredId, PredInfo),
ModuleName = pred_info_module(PredInfo),
PredName = pred_info_name(PredInfo),
Arity = pred_info_arity(PredInfo),
Arity = pred_info_orig_arity(PredInfo),
PushMsg = code_gen__push_msg(ModuleInfo, PredId, ProcId),
( CodeModel = model_non ->
@@ -1402,7 +1400,7 @@ code_gen__bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions) :-
PredName = pred_info_name(PredInfo),
proc_id_to_int(ProcId, ProcNum),
string__int_to_string(ProcNum, ProcStr),
Arity = pred_info_arity(PredInfo),
Arity = pred_info_orig_arity(PredInfo),
int_to_string(Arity, ArityStr),
PredOrFunc = pred_info_is_pred_or_func(PredInfo),
@@ -1452,9 +1450,9 @@ code_gen__push_msg(ModuleInfo, PredId, ProcId) = PushMsg :-
PredOrFunc = pred_info_is_pred_or_func(PredInfo),
ModuleName = pred_info_module(PredInfo),
PredName = pred_info_name(PredInfo),
Arity = pred_info_arity(PredInfo),
pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
( MaybeSpecial = yes(SpecialId - TypeCtor) ->
Arity = pred_info_orig_arity(PredInfo),
pred_info_get_origin(PredInfo, Origin),
( Origin = special_pred(SpecialId - TypeCtor) ->
code_gen__find_arg_type_ctor_name(TypeCtor, TypeName),
special_pred_name_arity(SpecialId, SpecialPredName, _),
string__append_list([SpecialPredName, "_for_", TypeName],