[m-dev.] [reuse] diff: add heuristics for alias analysis

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Tue Oct 17 23:52:56 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 2

Adding new heuristics to the alias analysis, and other smaller 
fixes. 

pa_run.m:
	Add new heuristics for dealing with special calls: 
		- if making a call to something erroneous or failure, 
		it cannot add any new aliases to the system.  
		- calls to procedures from builtin.m are considered
		not to produce any aliases (temporary and unsafe)
	Also write the opt_exported predicates to the .trans_opt files.
		
structure_reuse.m:
	Also write the opt_exported predicates to the .trans_opt files.

handle_options.m:
	Don't use the .trans_opt files when making the .opt files. 
	
make_hlds.m:
	Instead of producing an error when no corresponding predinfo/
	procinfo is found for the pragma's pa_alias_info and sr_reuse_info,
	simply generate warnings and go on compiling. 

Index: handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.90.2.5
diff -u -r1.90.2.5 handle_options.m
--- handle_options.m	2000/10/17 12:33:27	1.90.2.5
+++ handle_options.m	2000/10/17 12:39:06
@@ -321,6 +321,7 @@
 	% we need to build all `.opt' or `.trans_opt' files.
 	option_implies(intermodule_optimization, use_opt_files, bool(no)),
 	option_implies(transitive_optimization, use_trans_opt_files, bool(no)),
+	option_implies(make_optimization_interface, use_trans_opt_files, bool(no)),
 
 	% when doing possible alias analysis, for the moment we
         % don't want everything to be rebuild each time -- so let's
Index: make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.347.2.6
diff -u -r1.347.2.6 make_hlds.m
--- make_hlds.m	2000/10/12 15:26:21	1.347.2.6
+++ make_hlds.m	2000/10/17 12:39:16
@@ -1471,11 +1471,11 @@
 		% { module_info_incr_errors(Module0, Module) }
 	   )
 	;
-	   io__write_string("Error: no corresponding entry found for "),
+	   io__write_string("Warning: no corresponding entry found for "),
 	   hlds_out__write_simple_call_id(PredOrFunc, SymName/Arity),
 	   io__write_string(" with `pragma pa_alias_info'.\n"),
-	   { Module = Module0 },
-	   io__set_exit_status(1)
+	   { Module = Module0 }
+	   % io__set_exit_status(1)
 	   % { module_info_incr_errors(Module0, Module) }
 	).
 
@@ -1542,11 +1542,11 @@
 		% { module_info_incr_errors(Module0, Module) }
 	   )
 	;
-	   io__write_string("Error: no corresponding entry found for "),
+	   io__write_string("Warning: no corresponding entry found for "),
 	   hlds_out__write_simple_call_id(PredOrFunc, SymName/Arity),
 	   io__write_string(" with `pragma sr_reuse_info'.\n"),
-	   { Module = Module0 },
-	   io__set_exit_status(1)
+	   { Module = Module0 }
+	   % io__set_exit_status(1)
 	   % { module_info_incr_errors(Module0, Module) }
 	).
 
Index: pa_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_run.m,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 pa_run.m
--- pa_run.m	2000/10/16 17:47:36	1.1.2.7
+++ pa_run.m	2000/10/17 12:39:17
@@ -420,18 +420,32 @@
 	module_info_pred_proc_info( HLDS, PRED_PROC_ID, PredInfo,
 				    ProcInfo),
 	(
+		% If the determinism of the called procedure is
+		% erroneous or failure, then you don't even need to
+		% check anything else anymore: it simply cannot 
+		% introduce any aliases. 
+		proc_info_inferred_determinism(ProcInfo, Determinism), 
+		(
+			Determinism = erroneous
+		; 
+			Determinism = failure
+		)
+	->
+		init(Alias)	
+	;
 		proc_info_possible_aliases(ProcInfo, MaybeAliases),
 		MaybeAliases = yes( SomeAL)
 	->
 		Alias = SomeAL
 	;
-		% check whether the args are primitive types
+		% Special tricks: 
+		% 1. check whether the args are primitive types
 		arg_types_are_all_primitive(HLDS, PredInfo)
 	->
 		init(Alias)
 	;
-		% 4 - call to builtin.m or private_builtin.m
-		%     predicate -- unify/index/compare
+		% 2. call to builtin.m or private_builtin.m
+		%    predicate -- unify/index/compare
 		pred_info_name(PredInfo, Name),
 		pred_info_arity(PredInfo, Arity),
 		(
@@ -449,9 +463,17 @@
 		% no aliases created
 		init(Alias)
 	;
-		% XXX Any call to private_builtin.m module!
+		% 3. XXX Any call to private_builtin.m module and
+		%        builtin module are considered alias-free. 
+		% This is unsafe and it would be much better to 
+		% even annotate their aliases manually then just considering
+		% them as non-alias by default. 
 		pred_info_module(PredInfo, ModuleName),
-		mercury_private_builtin_module(ModuleName)
+		( 
+			mercury_private_builtin_module(ModuleName)
+		; 
+			mercury_public_builtin_module(ModuleName)
+		)
 	->
 		% no aliases created
 		init(Alias)
@@ -571,7 +593,8 @@
 pa_run__make_pa_interface_pred( HLDS, SpecPredIds, PredId ) -->
 	{ module_info_pred_info( HLDS, PredId, PredInfo ) },
 	(
-		{ pred_info_is_exported( PredInfo ) }
+		{ pred_info_is_exported( PredInfo ) ;
+		  pred_info_is_opt_exported( PredInfo ) }
 	->
 		( 
 			{ list__member( PredId, SpecPredIds ) }
Index: structure_reuse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/structure_reuse.m,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 structure_reuse.m
--- structure_reuse.m	2000/10/13 13:49:38	1.1.2.4
+++ structure_reuse.m	2000/10/17 12:39:17
@@ -76,7 +76,9 @@
 write_pragma_reuse_info( HLDS, SpecPredIds, PredId ) --> 
 	{ module_info_pred_info( HLDS, PredId, PredInfo ) },
 	(
-		{ pred_info_is_exported( PredInfo ) }
+		{ pred_info_is_exported( PredInfo ) ; 
+		  pred_info_is_opt_exported( PredInfo) }
+	
 	->
 		( 
 			{ list__member( PredId, SpecPredIds ) }

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list