Files
mercury/tests/hard_coded/ho_order2.m
Simon Taylor 98c2fbf51b Bug fixes.
Estimated hours taken: 12

Bug fixes.

tests/term/arit_exp.m still fails with --intermodule-optimization
due to a slightly different (but correct) trans_opt file being produced.

compiler/simplify.m
	Don't produce singleton disjunctions, since the code generator
	barfs on them. Use a `some' instead.
	Test case: tests/general/partition.m compiled with --deforestation.

compiler/unused_args.m
	Deconstructions where the arguments included `any' insts were
	not being handled correctly, due to inst_matches_binding
	failing for any->any.
	Test case: extras/trailed_update/samples/vqueens.m at -O3.
	Don't warn about predicates from `.opt' files having unused
	arguments, because in most cases the warning will be generated
	when compiling the imported module.

compiler/higher_order.m
	Fix a bug that caused compiler/modules.m to be miscompiled at
	-O3 --intermodule-optimization, due to curried arguments for
	multiple known higher-order arguments being passed to a
	specialised version in the wrong order.
	Test case: tests/hard_coded/ho_order2.m

compiler/mercury_compile.m
	Call intermod__update_pred_import_status when compiling to
	C at the same stage of the compilation as the `.opt' file
	was written to ensure that the same information is being used.
	Test case: tests/hard_coded/rational_test.m compiled with
	--intermodule-optimization failed because of a link error.
	Make sure polymorphism has been run before doing unused argument
	checking with --errorcheck-only. Otherwise the argument indices
	read in from `.opt' files are incorrect.

compiler/intermod.m
	Use code_util__compiler_generated to test if a called predicate
	is compiler generated, rather than looking for a call_unify_context
	(function calls have a call_unify_context).
	Add a progress message for updating the import status of predicates
	exported to `.opt' files.
	Fix a bug where the unused_args pragmas read in from the current
	module's `.opt' file were given an import_status of `imported' rather
	than `opt_imported' resulting in an error message from make_hlds.m.

compiler/dead_proc_elim.m
	Ensure that predicates used by instance declarations and
	`:- pragma export's are not eliminated by the dead_pred_elim
	pass before typechecking.
	Test case: most of the typeclass tests compiled with
	--intermodule-optimization.

compiler/hlds_goal.m
	Remove obsolete comments about the modes of a higher-order
	unification being incorrect after polymorphism, since that
	was fixed months ago.

compiler/options.m
	Reenable deforestation.
	Enable --intermodule-optimization and --intermod-unused-args
	at -O5 so they get tested occasionally.

compiler/handle_options.m
	Disable deforestation if --typeinfo-liveness is set, since
	there are bugs in the folding code if extra typeinfos are
	added to a new predicate's arguments by hlds_pred__define_new_pred.
	Disable higher_order.m if --typeinfo-liveness is set, since
	higher_order.m currently does not pass all necessary typeinfos
	to specialised versions or update the typeinfo_varmap of
	specialised versions.
	Test case: tests/valid/agc_ho_pred.m

tests/hard_coded/ho_order2.m
tests/hard_coded/ho_order2.exp
	Test case for higher_order.m.

tools/test_mercury
	Added --intermod-unused-args to the options for murlibobo.

extras/trailed_update/{samples,tests}/Mmakefile
	Add "-I.." to MGNUCFLAGS so gcc can find unsafe.h which
	is #included in c_header_code read from unsafe.opt.
1998-06-03 00:44:04 +00:00

86 lines
2.7 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Regression test for a bug in higher_order.m
% Symptom: seg fault or incorrect behaviour at runtime
% Cause: Incorrect ordering of curried arguments to multiple known
% higher-order input arguments in the specialised version.
%-----------------------------------------------------------------------------%
:- module ho_order2.
:- interface.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is det.
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module int, list, map, require, std_util, string.
%-----------------------------------------------------------------------------%
% information used during the elimination phase.
main(State0, State) :-
map__from_assoc_list([0 - 1], Needed),
map__from_assoc_list([0 - 1, 1 - 2, 2 - 4], ProcTable0),
ProcIds = [1, 2],
Keep = no,
fldl2(ho_order2__eliminate_proc(Keep, Needed),
ho_order2__eliminate_proc_2(Needed, Keep),
ProcIds, ProcTable0, _ProcTable, State0, State).
% eliminate a procedure, if unused
:- pred ho_order2__eliminate_proc(maybe(int), map(int, int),
int, map(int, int), map(int, int), io__state, io__state).
:- mode ho_order2__eliminate_proc(in, in, in, in, out, di, uo) is det.
ho_order2__eliminate_proc(Keep, Needed, ProcId,
ProcTable0, ProcTable) -->
(
( { map__search(Needed, ProcId, _) }
; { Keep = yes(_) }
)
->
{ ProcTable = ProcTable0 }
;
io__format("Deleting %i\n", [i(ProcId)]),
{ map__delete(ProcTable0, ProcId, ProcTable) }
).
:- pred ho_order2__eliminate_proc_2(map(int, int), maybe(int),
int, map(int, int), map(int, int), io__state, io__state).
:- mode ho_order2__eliminate_proc_2(in, in, in, in, out, di, uo) is det.
ho_order2__eliminate_proc_2(Needed, Keep, ProcId,
ProcTable0, ProcTable) -->
(
( { map__search(Needed, ProcId, _) }
; { Keep = yes(_) }
)
->
{ ProcTable = ProcTable0 }
;
io__format("Deleting %i\n", [i(ProcId)]),
{ map__delete(ProcTable0, ProcId, ProcTable) }
).
:- pred fldl2(pred(X, Y, Y, Z, Z), pred(X, Y, Y, Z, Z), list(X), Y, Y, Z, Z).
:- mode fldl2(pred(in, in, out, di, uo) is det,
pred(in, in, out, di, uo) is det,
in, in, out, di, uo) is det.
fldl2(_, _, [], FirstAcc, FirstAcc, SecAcc, SecAcc).
fldl2(P1, P2, [H|T], FirstAcc0, FirstAcc, SecAcc0, SecAcc) :-
call(P1, H, FirstAcc0, FirstAcc1, SecAcc0, SecAcc1),
call(P2, H, FirstAcc0, FirstAcc2, SecAcc1, SecAcc2),
( FirstAcc1 = FirstAcc2 ->
fldl2(P1, P2, T, FirstAcc1, FirstAcc, SecAcc2, SecAcc)
;
error("fldl2: results don't agree")
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%