[m-rev.] diff: fix MLDS bootstrap error

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Feb 11 20:00:15 AEDT 2002


Estimated hours taken: 4
Branches: main

Fix a bug in my recent change to add `--eliminate-local-variables'
that broke bootstrapping of the MLDS back-end.

compiler/mercury_compile.m:
	When invoking ml_optimize the first time (before ml_elim_nested),
	disable --optimize-initializations, because ml_elim_nested
	doesn't handle MLDS code containing initializations correctly.

compiler/ml_elim_nested.m:
	Add an XXX comment about not handling initializations correctly.

Workspace: /home/earth/fjh/ws-earth4/mercury
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.230
diff -u -d -r1.230 mercury_compile.m
--- compiler/mercury_compile.m	7 Feb 2002 03:55:41 -0000	1.230
+++ compiler/mercury_compile.m	10 Feb 2002 11:07:32 -0000
@@ -3270,16 +3270,26 @@
 	% this point, because that would result in loops
 	% with no call to MR_GC_check().
 	% So we explicitly disable that here.
+	% Also, we need to disable optimize_initializations,
+	% because ml_elim_nested doesn't correctly handle
+	% code containing initializations.
+	% The only optimization that ml_optimize will do on this
+	% pass is eliminating variables.
 	globals__io_lookup_bool_option(optimize, Optimize),
 	( { Optimize = yes } ->
+		globals__io_lookup_bool_option(optimize_initializations,
+			OptimizeInitializations),
 		globals__io_set_option(optimize_tailcalls, bool(no)),
+		globals__io_set_option(optimize_initializations, bool(no)),
 
 		maybe_write_string(Verbose, "% Optimizing MLDS...\n"),
 		ml_optimize__optimize(MLDS20, MLDS25),
 		maybe_write_string(Verbose, "% done.\n"),
 
 		globals__io_set_option(optimize_tailcalls,
-			bool(OptimizeTailCalls))
+			bool(OptimizeTailCalls)),
+		globals__io_set_option(optimize_initializations,
+			bool(OptimizeInitializations))
 	;
 		{ MLDS25 = MLDS20 }
 	),
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.51
diff -u -d -r1.51 ml_elim_nested.m
--- compiler/ml_elim_nested.m	7 Feb 2002 11:32:07 -0000	1.51
+++ compiler/ml_elim_nested.m	10 Feb 2002 11:05:39 -0000
@@ -1650,6 +1650,10 @@
 			% since this local variable is going to become
 			% a field, and fields can't have initializers.
 			( { Init0 = init_obj(Rval) } ->
+				% XXX Bug! Converting the initializer to an
+				% assignment doesn't work, because it doesn't
+				% handle the case when initializers in
+				% FollowingDefns reference this variable
 				{ Init1 = no_initializer },
 				{ DefnBody1 = mlds__data(Type, Init1,
 					MaybeGCTraceCode0) },

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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