[m-rev.] [reuse] diff: more trans_opt changes

Peter Ross peter.ross at miscrit.be
Tue Mar 20 23:56:02 AEDT 2001


Estimated hours taken: 1
Branches: reuse

compiler/mercury_compile.m:
    Don't transitvely read in .trans_opt files when making the trans_opt
    file

compiler/trans_opt.m:
    Avoid importing the current modules trans_opt when reading in
    trans_opt files.

Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.175.2.13
retrieving revision 1.175.2.14
diff -u -r1.175.2.13 -r1.175.2.14
--- mercury_compile.m	2001/03/05 12:05:46	1.175.2.13
+++ mercury_compile.m	2001/03/20 12:52:52	1.175.2.14
@@ -600,8 +600,8 @@
 	),
 
 	% Errors in .opt and .trans_opt files result in software errors.
-	mercury_compile__maybe_grab_optfiles(ModuleImports0, Verbose,
-		MaybeTransOptDeps, ModuleImports1, IntermodError),
+	mercury_compile__maybe_grab_optfiles(ModuleImports0, Module,
+		Verbose, MaybeTransOptDeps, ModuleImports1, IntermodError),
 
 	{ module_imports_get_items(ModuleImports1, Items1) },
 	mercury_compile__module_qualify_items(Items1, Items2, Module, Verbose,
@@ -650,13 +650,13 @@
 	maybe_write_string(Verbose, "% done.\n"),
 	maybe_report_stats(Stats).
 
-:- pred mercury_compile__maybe_grab_optfiles(module_imports, bool,
+:- pred mercury_compile__maybe_grab_optfiles(module_imports, module_name, bool,
 	 maybe(list(module_name)), module_imports, bool, io__state, io__state).
-:- mode mercury_compile__maybe_grab_optfiles(in, in, in, out, out, 
+:- mode mercury_compile__maybe_grab_optfiles(in, in, in, in, out, out, 
 	di, uo) is det.
 
-mercury_compile__maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, 
-		Imports, Error) -->
+mercury_compile__maybe_grab_optfiles(Imports0, OrigModuleName,
+		Verbose, MaybeTransOptDeps, Imports, Error) -->
 	globals__io_lookup_bool_option(intermodule_optimization, IntermodOpt),
 	globals__io_lookup_bool_option(use_opt_files, UseOptInt),
 	globals__io_lookup_bool_option(make_optimization_interface,
@@ -677,8 +677,8 @@
 		( { MaybeTransOptDeps = yes(TransOptDeps) } ->
 			% When creating the trans_opt file, only import the
 			% trans_opt files which are lower in the ordering.
-			trans_opt__grab_optfiles(Imports1, TransOptDeps, 
-				Imports, Error2)
+			trans_opt__grab_optfiles(no, Imports1, OrigModuleName,
+					TransOptDeps, Imports, Error2)
 		;
 			{ Imports = Imports1 },
 			{ Error2 = no },
@@ -725,8 +725,8 @@
 				_ForeignCode, _Items, _Error) },
 			{ list__condense([Ancestors, InterfaceImports,
 				ImplementationImports], TransOptFiles) },
-			trans_opt__grab_optfiles(Imports1, TransOptFiles,
-				Imports, Error2)
+			trans_opt__grab_optfiles(yes, Imports1, OrigModuleName,
+					TransOptFiles, Imports, Error2)
 		;
 			{ Imports = Imports1 },
 			{ Error2 = no }
Index: trans_opt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trans_opt.m,v
retrieving revision 1.15.4.6
retrieving revision 1.15.4.7
diff -u -r1.15.4.6 -r1.15.4.7
--- trans_opt.m	2001/03/20 11:15:15	1.15.4.6
+++ trans_opt.m	2001/03/20 12:52:56	1.15.4.7
@@ -57,13 +57,16 @@
 :- pred trans_opt__write_optfile(module_info, io__state, io__state).
 :- mode trans_opt__write_optfile(in, di, uo) is det.
 
-	% trans_opt__grab_optfiles(ModuleImports0, ModuleList, ModuleImports, 
-	% 	Error, IO0, IO).
+	% trans_opt__grab_optfiles(Transitive, ModuleImports0, ModuleName,
+	% 		ModuleList, ModuleImports, Error, IO0, IO).
 	% Add the items from each of the modules in ModuleList.trans_opt to
-	% the items in ModuleImports.
-:- pred trans_opt__grab_optfiles(module_imports, list(module_name), 
-	module_imports, bool, io__state, io__state).
-:- mode trans_opt__grab_optfiles(in, in, out, out, di, uo) is det.
+	% the items in ModuleImports, do this transitively if
+	% Transitive = yes.  The current module_name, ModuleName, is
+	% used to avoid importing the current modules trans_opt.
+	%
+:- pred trans_opt__grab_optfiles(bool, module_imports, module_name,
+		list(module_name), module_imports, bool, io__state, io__state).
+:- mode trans_opt__grab_optfiles(in, in, in, in, out, out, di, uo) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -194,11 +197,13 @@
 %-----------------------------------------------------------------------------%
 	% Read in and process the transitive optimization interfaces.
 
-trans_opt__grab_optfiles(Module0, TransOptDeps, Module, FoundError) -->
+trans_opt__grab_optfiles(Transitive, Module0, ModuleName,
+		TransOptDeps, Module, FoundError) -->
 	globals__io_lookup_bool_option(verbose, Verbose),
 	maybe_write_string(Verbose, "% Reading .trans_opt files..\n"),
 	maybe_flush_output(Verbose),
-	read_trans_opt_files(TransOptDeps, [], [], OptItems, no, FoundError),
+	read_trans_opt_files(Transitive, TransOptDeps, [ModuleName],
+			[], OptItems, no, FoundError),
 
 	{ append_pseudo_decl(Module0, opt_imported, Module1) },
 	{ module_imports_get_items(Module1, Items0) },
@@ -208,12 +213,13 @@
 
 	maybe_write_string(Verbose, "% Done.\n").
 
-:- pred read_trans_opt_files(list(module_name), list(module_name), item_list,
+:- pred read_trans_opt_files(bool,
+	list(module_name), list(module_name), item_list,
 	item_list, bool, bool, io__state, io__state).
-:- mode read_trans_opt_files(in, in, in, out, in, out, di, uo) is det.
+:- mode read_trans_opt_files(in, in, in, in, out, in, out, di, uo) is det.
 
-read_trans_opt_files([], _, Items, Items, Error, Error) --> [].
-read_trans_opt_files(OptFilesToRead, AlreadyReadOptFiles,
+read_trans_opt_files(_, [], _, Items, Items, Error, Error) --> [].
+read_trans_opt_files(Transitive, OptFilesToRead, AlreadyReadOptFiles,
 		Items0, Items, Error0, Error) -->
 	{ OptFilesToRead = [Import | Imports] },
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
@@ -229,17 +235,21 @@
 	prog_io__read_opt_file(FileName, Import, yes,
 			ModuleError, Messages, OptItems),
 
-		% Get the rest of the trans_opt files to be read.
-	{ get_dependencies(OptItems, NewImportDeps0, NewUseDeps0) },
-	globals__io_get_globals(Globals),
-	{ get_implicit_dependencies(OptItems, Globals,
-		NewImplicitImportDeps0, NewImplicitUseDeps0) },
-	{ NewDeps0 = list__condense([NewImportDeps0, NewUseDeps0,
-		NewImplicitImportDeps0, NewImplicitUseDeps0]) },
-	{ set__list_to_set(NewDeps0, NewDepsSet0) },
-	{ set__delete_list(NewDepsSet0,
-		OptFilesToRead ++ AlreadyReadOptFiles, NewDepsSet) },
-	{ set__to_sorted_list(NewDepsSet, NewDeps) },
+	( { Transitive = yes } ->
+			% Get the rest of the trans_opt files to be read.
+		{ get_dependencies(OptItems, NewImportDeps0, NewUseDeps0) },
+		globals__io_get_globals(Globals),
+		{ get_implicit_dependencies(OptItems, Globals,
+			NewImplicitImportDeps0, NewImplicitUseDeps0) },
+		{ NewDeps0 = list__condense([NewImportDeps0, NewUseDeps0,
+			NewImplicitImportDeps0, NewImplicitUseDeps0]) },
+		{ set__list_to_set(NewDeps0, NewDepsSet0) },
+		{ set__delete_list(NewDepsSet0,
+			OptFilesToRead ++ AlreadyReadOptFiles, NewDepsSet) },
+		{ set__to_sorted_list(NewDepsSet, NewDeps) }
+	;
+		{ NewDeps = [] }
+	),
 
 	maybe_write_string(VeryVerbose, " done.\n"),
 
@@ -247,7 +257,7 @@
 		Messages, Error0, Error1),
 
 	{ list__append(Items0, OptItems, Items2) },
-	read_trans_opt_files(NewDeps ++ Imports,
+	read_trans_opt_files(Transitive, NewDeps ++ Imports,
 			[Import | AlreadyReadOptFiles],
 			Items2, Items, Error1, Error).
 
--------------------------------------------------------------------------
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