[m-rev.] diff: workaround to fix nightly builds

Mark Brown mark at cs.mu.OZ.AU
Tue Aug 16 15:15:33 AEST 2005


On 16-Aug-2005, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> 
> On Mon, 15 Aug 2005, Julien Fischer wrote:
> 
> >
> > Estimated hours taken: 0.1
> > Branches: main
> >
> > library/Mercury.options:
> > 	Workaround a bug in the compiler that is causing the
> > 	library to fail to build in grade asm_fast.gc.tr.debug
> > 	at -O5.  This is just to get the nightly builds up and
> > 	running again.
> >
> 
> Mark, at a guess most of what failed on aral last night is due
> to the same or a similar bug.  (aral runs the tests at -O5)

The following diff should fix this bug.

Cheers,
Mark.

Estimated hours taken: 4
Branches: main

Fix a problem exposed by the exists_cast transformation.

compiler/saved_vars.m:
	Don't duplicate variables holding type_infos if type_info liveness
	is set.  Doing so could leave the rtti_varmaps in an inconsistent
	state, since there may no longer be a unique location which holds 
	the type_info for a given type.  This can cause an exception to be
	thrown by liveness.m, for example, when compiling version_store.m
	in a debug grade with --optimize-saved-vars-const set.

library/Mercury.options:
	Undo the workaround for this bug.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/exists_cast_bug.m:
	A test case.  This is compiled with deep tracing and
	--optimize-saved-vars-const even if version_store is not.

tests/valid/aditi_calls_mercury.m:
	Modify this test case so that the Aditi predicate no longer uses
	polymorphism.  Without this, we get the error "the code uses
	polymorphism or type-classes which are not supported by Aditi".

Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.49
diff -u -r1.49 saved_vars.m
--- compiler/saved_vars.m	31 May 2005 06:55:31 -0000	1.49
+++ compiler/saved_vars.m	16 Aug 2005 03:47:53 -0000
@@ -40,6 +40,7 @@
 :- implementation.
 
 :- import_module check_hlds__mode_util.
+:- import_module check_hlds__polymorphism.
 :- import_module hlds__goal_util.
 :- import_module hlds__hlds_goal.
 :- import_module hlds__hlds_out.
@@ -62,16 +63,20 @@
 saved_vars_proc(PredId, ProcId, ProcInfo0, ProcInfo, !ModuleInfo, !IO) :-
 	write_proc_progress_message("% Minimizing saved vars in ",
 		PredId, ProcId, !.ModuleInfo, !IO),
-	saved_vars_proc_no_io(ProcInfo0, ProcInfo, !ModuleInfo).
+	module_info_globals(!.ModuleInfo, Globals),
+	module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
+	body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness),
+	saved_vars_proc_no_io(TypeInfoLiveness, ProcInfo0, ProcInfo,
+		!ModuleInfo).
 
-:- pred saved_vars_proc_no_io(proc_info::in, proc_info::out,
+:- pred saved_vars_proc_no_io(bool::in, proc_info::in, proc_info::out,
 	module_info::in, module_info::out) is det.
 
-saved_vars_proc_no_io(!ProcInfo, !ModuleInfo) :-
+saved_vars_proc_no_io(TypeInfoLiveness, !ProcInfo, !ModuleInfo) :-
 	proc_info_goal(!.ProcInfo, Goal0),
 	proc_info_varset(!.ProcInfo, Varset0),
 	proc_info_vartypes(!.ProcInfo, VarTypes0),
-	init_slot_info(Varset0, VarTypes0, SlotInfo0),
+	init_slot_info(Varset0, VarTypes0, TypeInfoLiveness, SlotInfo0),
 
 	saved_vars_in_goal(Goal0, Goal1, SlotInfo0, SlotInfo),
 
@@ -173,12 +178,13 @@
 	(
 		Goal0 = unify(_, _, _, Unif, _) - GoalInfo,
 		Unif = construct(Var, _, [], _, _, _, _),
-		skip_constant_constructs(Goals0, Constants, Others),
-		Others = [First | _Rest],
-		can_push(Var, First),
 		goal_info_get_features(GoalInfo, Features),
 		( all [Feature] ( set__member(Feature, Features)
-			=> ok_to_duplicate(Feature) = yes ))
+			=> ok_to_duplicate(Feature) = yes )),
+		\+ slot_info_do_not_duplicate_var(!.SlotInfo, Var),
+		skip_constant_constructs(Goals0, Constants, Others),
+		Others = [First | _Rest],
+		can_push(Var, First)
 	->
 		set__is_member(Var, NonLocals, IsNonLocal),
 		saved_vars_delay_goal(Others, Goal0, Var, IsNonLocal,
@@ -503,28 +509,48 @@
 :- type slot_info
 	---> slot_info(
 		prog_varset,
-		vartypes
+		vartypes,
+		bool		% TypeInfoLiveness
 	).
 
-:- pred init_slot_info(prog_varset::in, map(prog_var, type)::in,
+:- pred init_slot_info(prog_varset::in, map(prog_var, type)::in, bool::in,
 	slot_info::out) is det.
 
-init_slot_info(Varset, VarTypes, slot_info(Varset, VarTypes)).
+init_slot_info(Varset, VarTypes, TypeInfoLiveness, SlotInfo) :-
+	SlotInfo = slot_info(Varset, VarTypes, TypeInfoLiveness).
 
 :- pred final_slot_info(prog_varset::out, vartypes::out, slot_info::in) is det.
 
-final_slot_info(Varset, VarTypes, slot_info(Varset, VarTypes)).
+final_slot_info(Varset, VarTypes, slot_info(Varset, VarTypes, _)).
 
 :- pred rename_var(prog_var::in, prog_var::out, map(prog_var, prog_var)::out,
 	slot_info::in, slot_info::out) is det.
 
 rename_var(Var, NewVar, Substitution, !SlotInfo) :-
-	!.SlotInfo = slot_info(Varset0, VarTypes0),
+	!.SlotInfo = slot_info(Varset0, VarTypes0, TypeInfoLiveness),
 	varset__new_var(Varset0, NewVar, Varset),
 	map__from_assoc_list([Var - NewVar], Substitution),
 	map__lookup(VarTypes0, Var, Type),
 	map__det_insert(VarTypes0, NewVar, Type, VarTypes),
-	!:SlotInfo = slot_info(Varset, VarTypes).
+	!:SlotInfo = slot_info(Varset, VarTypes, TypeInfoLiveness).
+
+	% Check whether it is ok to duplicate a given variable according
+	% to the information in the slot_info.  If TypeInfoLiveness is set,
+	% it is possible that liveness.m will want to refer to the
+	% rtti_varmaps to calculate which type_infos are live (see the
+	% comments at the top of liveness.m).  If we duplicated any
+	% type_info variables here then this could cause problems because
+	% the rtti_varmaps would not be able to be kept consistent.
+	% Therefore we don't allow type_infos to be duplicated when
+	% TypeInfoLiveness is set.
+	%
+:- pred slot_info_do_not_duplicate_var(slot_info::in, prog_var::in) is semidet.
+
+slot_info_do_not_duplicate_var(SlotInfo, Var) :-
+	SlotInfo = slot_info(_, VarTypes, TypeInfoLiveness),
+	TypeInfoLiveness = yes,
+	map__lookup(VarTypes, Var, Type),
+	polymorphism__type_is_type_info_or_ctor_type(Type).
 
 %-----------------------------------------------------------------------------%
 
Index: library/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mercury.options,v
retrieving revision 1.9
diff -u -r1.9 Mercury.options
--- library/Mercury.options	15 Aug 2005 07:28:25 -0000	1.9
+++ library/Mercury.options	15 Aug 2005 17:04:38 -0000
@@ -20,7 +20,6 @@
 MCFLAGS-std_util += --no-halt-at-warn
 MCFLAGS-dir += --no-halt-at-warn
 MCFLAGS-exception += --no-halt-at-warn
-MCFLAGS-version_store += -O0
 
 # io.m uses library features that are supported by POSIX but which are not
 # part of ANSI C, such as `struct stat', fileno(), and putenv().
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.21
diff -u -r1.21 Mercury.options
--- tests/valid/Mercury.options	23 May 2005 08:37:03 -0000	1.21
+++ tests/valid/Mercury.options	15 Aug 2005 16:45:47 -0000
@@ -38,6 +38,7 @@
 MCFLAGS-deforest_loop		= -O3 --intermodule-optimization
 MCFLAGS-deforest_rerun_det	= -O3 --check-termination
 MCFLAGS-double_vn		= -O4
+MCFLAGS-exists_cast_bug		= --trace deep -O0 --optimize-saved-vars-const
 MCFLAGS-explicit_quant		= --halt-at-warn
 MCFLAGS-foreign_underscore_var	= --halt-at-warn
 MCFLAGS-higher_order4		= -O3
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.156
diff -u -r1.156 Mmakefile
--- tests/valid/Mmakefile	12 Aug 2005 02:33:10 -0000	1.156
+++ tests/valid/Mmakefile	15 Aug 2005 17:02:48 -0000
@@ -214,9 +214,10 @@
 DEEP_PROF_CAPABLE_PROGS = \
 	impure_detism
 
-	# This test requires debugging, which hasn't been
+	# These tests require debugging, which hasn't been
 	# implemented for the MLDS backend.
 LLDS_PROGS= \
+	exists_cast_bug \
 	untuple_bug
 
 # The following programs require that num_tag_bits >= 1
Index: tests/valid/aditi_calls_mercury.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/aditi_calls_mercury.m,v
retrieving revision 1.1
diff -u -r1.1 aditi_calls_mercury.m
--- tests/valid/aditi_calls_mercury.m	20 Oct 2004 09:45:11 -0000	1.1
+++ tests/valid/aditi_calls_mercury.m	16 Aug 2005 03:53:46 -0000
@@ -14,7 +14,7 @@
 :- import_module int.
 :- import_module float.
 
-query(DB,X ++ X) :-
+query(DB, app(X, X)) :-
 	p(DB, X).
 
 :- pred p(aditi__state, list(int)).
@@ -22,3 +22,6 @@
 
 :- pragma base_relation(p/2).
 
+:- func app(list(int), list(int)) = list(int).
+
+app(X, Y) = X ++ Y.
Index: tests/valid/exists_cast_bug.m
===================================================================
RCS file: tests/valid/exists_cast_bug.m
diff -N tests/valid/exists_cast_bug.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/exists_cast_bug.m	15 Aug 2005 16:42:55 -0000
@@ -0,0 +1,20 @@
+% Compile with: --debug -O0 --optimize-saved-vars-const
+
+:- module exists_cast_bug.
+
+:- interface.
+
+:- type version_store(S).
+
+:- some [S] func new = version_store(S).
+
+:- implementation.
+
+:- import_module version_array.
+
+:- type version_store(S)  ---> version_store(version_array(unit)).
+:- type unit ---> unit.
+
+new = Result :-
+	Result = version_store(VA) `with_type` version_store(unit),
+    	VA = version_array.new(256, unit).
--------------------------------------------------------------------------
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