for review: make_hlds.m: work-around for termination_info problem

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jan 25 15:52:29 AEDT 1998


Zoltan, can you please review this one?

Estimated hours taken: 1

compiler/make_hlds.m:
	Work around a problem with `pragma termination_info' declarations
	in `.trans_opt' files.

	The problem is that the `.trans_opt' files include `pragma
	termination_info' declarations for certain non-exported
	predicates (ones that might be called from
	cross-module-inlinable predicates) for which there happens to
	be no `pred' declaration in the `.opt' file.  This occurs, even
	though the `.opt' file contains declarations for all
	non-exported predicates that could be called from
	cross-module-inlinable predicates, because `.trans_opt' and
	`.opt' files use slightly different definitions of
	`cross-module-inlinable' -- the decision as to whether
	something is cross-module-inlinable uses the same criteria, but
	it is taken at different times, after the HLDS has been subject
	to different transformations, and so leads to different results.
	For `.opt' files, it is taken when the `.opt' file is written
	out, after type checking.  For `.trans_opt' files, it is taken
	after the simplification pass at the end of the front end
	semantic analysis and error checking phase.

	The work-around is to just ignore `pragma termination_info'
	declarations if there is no matching `pred' or `func' declaration.

	This is probably not the ideal solution, but the alternatives seem
	to be a lot more work.

cvs diff  compiler/make_hlds.m
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.254
diff -u -r1.254 make_hlds.m
--- make_hlds.m	1998/01/24 05:44:19	1.254
+++ make_hlds.m	1998/01/25 04:16:51
@@ -408,13 +408,10 @@
 		{ list__length(ModeList, Arity) },
 		(
 		    { predicate_table_search_pf_sym_arity(Preds,
-			PredOrFunc, SymName, Arity, PredIds) }
+			PredOrFunc, SymName, Arity, PredIds) },
+		    { PredIds \= [] }
 		->
-		    ( { PredIds = [] } ->
-			undefined_pred_or_func_error(SymName, Arity, Context,
-				"`:- pragma termination_info' declaration"),
-			{ module_info_incr_errors(Module0, Module) }
-		    ; { PredIds = [PredId] } ->
+		    ( { PredIds = [PredId] } ->
 			{ module_info_preds(Module0, PredTable0) },
 			{ map__lookup(PredTable0, PredId, PredInfo0) },
 			{ pred_info_procedures(PredInfo0, ProcTable0)},
@@ -459,9 +456,15 @@
 			{ module_info_incr_errors(Module0, Module) }
 		    )
 		;
-		    undefined_pred_or_func_error(SymName, Arity, Context,
-			"`:- pragma termination_info' declaration"),
-		    { module_info_incr_errors(Module0, Module) }
+		    % XXX This happens in `.trans_opt' files sometimes --
+		    % so just ignore it
+		    { Module = Module0 }
+		    /***
+		    ****   undefined_pred_or_func_error(
+		    ****	    SymName, Arity, Context,
+		    **** 	    "`:- pragma termination_info' declaration"),
+		    ****   { module_info_incr_errors(Module0, Module) }
+		    ***/
 		)
 	;
 		{ Pragma = terminates(Name, Arity) },

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list