Commit Graph

5139 Commits

Author SHA1 Message Date
Peter Wang
f2d121b6e1 This is a follow up to a previous patch designed to solve a
Estimated hours taken: 2
Branches: main

This is a follow up to a previous patch designed to solve a
problem where "mmc --make libfoo.install --libgrade <bar>" would
install into a grade subdirectory named <bar> in non-canonical form.
The previous patch was completely broken for "hlc" grades (at least).

compiler/handle_options.m:
	Revert r1.252 as it did not properly canonicalise grade strings.

compiler/make.program_target.m:
	Use `grade_directory_component' to find out which directory a grade's
	files should be installed into instead of assuming the verbatim grade
	string passed in with `--libgrade'.
2006-02-03 05:46:21 +00:00
Julien Fischer
ea4306b4b2 Add module qualifiers in order to avoid ambiguous overloadings
Estimated hours taken: 0.5
Branches: main

compiler/mcsolver.m:
	Add module qualifiers in order to avoid ambiguous overloadings
	when compile with `--intermodule-optimization'.
2006-02-02 12:57:31 +00:00
Richard James Fothergill
765109cde2 Extend constraints based mode analysis.
Estimated hours taken: 120.
Branches: main.

Extend constraints based mode analysis.
Constraints on the producing and consuming goals for program
variables are now solved, and the solutions used for
conjunction reordering. The resulting HLDS is then thrown away,
after maybe being dumped (stage 33).

Extend dumping of mode analysis constraints.
Constraints are no longer dumped to file - they are displayed as
error messages when the --debug-mode-constraints is set. After
conjunction ordering, the original goal paths are printed in the
order they now appear.

compiler/options.m:
	Added the option described above, and some comments describing
	various mode constraint options.

compiler/check_hlds.m:
	Grouped ":- include_module"s for propagation solver
	constraints based mode analysis, and included
	new modules in this area - mcsolver and
	ordering_mode_constraints.

compiler/mode_constraints.m:
	Changes to the nature of constraint dumping - introduction
	of the use of --debug-mode-constraints.
	Introduction of conjunction ordering (call to module
	ordering_mode_constraints).

compiler/prop_mode_constraints.m:
	Changes to way constraints are dumped as described above.
	Changes to the way constraint variables are created -
	constraint variables can now be constructed as needed
	when the constraints are built.
	Structural changes to make constraint generation more
	natural (eg introduction of state variables, instead
	of use of functions).

compiler/abstract_mode_constraints.m:
	Changes to the way constraints are stored - the old
	speculative code became redundant with the introduction
	of rafe's solver (see mcsolver.m).
	New, specialised constraint generation predicates.
	Constraints are now created with a context attached,
	and space was left for adding other information.

compiler/build_mode_constraints.m:
	Changes to the way constraint variables are created -
	constraint variables can now be constructed as needed
	when the constraints are built.
	Structural changes to make constraint generation more
	natural (eg introduction of state variables, instead
	of use of functions).
	Constraints are now created with a context attached.

compiler/ordering_mode_constraints.m:
	New file. Uses solutions to the producer/consumer
	constraints to order conjunctions for mode analysis.
	Does not yet do mode inference.

compiler/mcsolver.m:
	New file. Written by rafe, modified by myself to
	accomodate the rest of the mode constraints branch
	(and a new constraint type). Solves mode constraints
	to produce bindings for constraint variables from
	producer/consumer analysis.

compiler/notes/compiler_design.html:
	Updated notes about constraints based mode analysis.
2006-02-02 00:38:30 +00:00
Peter Wang
5fbb10ab69 Canonicalise the grade strings passed to `--libgrade'.
Estimated hours taken: 1
Branches: main

compiler/handle_options.m:
	Canonicalise the grade strings passed to `--libgrade'.  This solves a
	problem where "mmc --make libfoo.install --libgrade <bar>" would
	install into a grade subdirectory named <bar> in non-canonical form.
2006-02-01 23:38:20 +00:00
Julien Fischer
8113fc0818 Mention that module imports from the analysis directory should be
Estimated hours taken: 0
Branches: main

compiler/notes/coding_standards.html:
	Mention that module imports from the analysis directory should be
	grouped with those from the compiler and mdbcomp directories.
2006-02-01 07:39:12 +00:00
Julien Fischer
18c3a96cfd Preliminary working on converting the termination analyser to use the
Estimated hours taken: 4
Branches: main

Preliminary working on converting the termination analyser to use the
intermodule analysis framework.  This mainly involves threading the
module_info and io.state through more of the code and changing some code that
was semidet to det returning a boolean (because it now takes the
io.state).  I've put placeholders , XXX intermod, in the spots that need to be
further modified.

compiler/term_errors.m:
compiler/term_pass1.m:
compiler/term_pass2.m:
compiler/term_util.m:
compiler/term_traversal.m:
compiler/termination.m:
	Prepare to convert termination analysis to use the intermodule
	analysis framework.

	Fix some layout problems.
2006-02-01 05:10:39 +00:00
Julien Fischer
9e0eac872d Convert the exception analysis so that it can use the intermodule-analysis
Estimated hours taken: 10
Branches: main

Convert the exception analysis so that it can use the intermodule-analysis
framework.

General cleanup of the exception analysis code, particularly the parts that
analyse higher-order calls based on the results of closure analysis.

TODO:
	- fix up the optimization passes so that they look up exception
	  information in the correct place when --intermodule-analysis
	  is enabled.  Information about imported procedures will be stored
	  in the analysis registry, not in the exception_info table as
	  is the case when --intermodule-optimization is used.
          (The same thing needs to be done for the trail usage
           optimization.)

compiler/exception_analysis.m:
	Support exception analysis using the intermodule analysis framework.

	Fix some layout problems

	Update the TODO list.

compiler/mmc_analysis.m:
	Add `exception_analysis' to the list of supported analyses.

compiler/hlds_module.m:
	Add a slot to store the exception analysis status for each procedure.

compiler/add_pragma.m:
compiler/goal_form.m:
	Conform to the above changes.
2006-02-01 04:02:46 +00:00
Zoltan Somogyi
9736a7c600 Fix a bug reported by Samrith, which is that some of the files in
Estimated hours taken: 1
Branches: main

Fix a bug reported by Samrith, which is that some of the files in
benchmarks/progs/icfp2000, e.g. eval.m, got a compiler abort when compiled
with -O0 --optimize-repeat=0 --optimize-saved-vars. This was because
--optimize-saved-vars relied on jump optimization being done, but
--optimize-repeat=0 disables jump optimization.

compiler/handle_options.m:
	Make --optimize-repeat at least one if some other optimization
	requires the optimizations controlled by --optimize-repeat.

compiler/optimize.m:
compiler/use_local_vars.m:
	Rename some predicates to make their unqualified names more meaningful.

	Delete unnecessary module qualifications. Switch to using . instead of
	__ as module qualifier.

compiler/mercury_compile.m:
	Conform to the change to optimize.m.

compiler/modules.m:
	Rename a predicate to avoid a confusing overloading.

compiler/compile_target_code.m:
	Conform to the change to modules.m.

tests/valid/eval.m:
	New test case to check the fix.

tests/valid/Mmakefile:
	Enable the new test case.
2006-01-31 05:20:45 +00:00
Julien Fischer
636e9c8e0a Fix some entries in the help message that exceed
Estimated hours taken: 0
Branches: main

compiler/options.m:
	Fix some entries in the help message that exceed
	80 chars in width.
2006-01-30 00:41:32 +00:00
Zoltan Somogyi
b819fbc0a6 Give the compiler the capability of detecting errors that manifest themselves
Estimated hours taken: 16
Branches: main

Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.

This capability is controlled through two new options:

	--warn-known-bad-format-calls
	--warn-unknown-format-calls

The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.

NEWS:
	Mention the new capability.

compiler/options.m:
	Add the two new options.

doc/user_guide.texi:
	Document the new options.

compiler/format_call.m:
	New module to implement the new capability.

compiler/notes/compiler_structure.html:
	Document the new module.

compiler/check_hlds.m:
	Include the new module.

compiler/simplify.m:
	Invoke the new module if the procedure being processed contains calls
	to string.format or io.format.

	Fix an old bug: we could generate warnings or even errors when
	simplifying predicate bodies imported from other modules via
	intermodule optimization.

	Don't export get/set predicates that do not need to be exported.

compiler/det_report.m:
	Add new kinds of error specifications for the errors detected by the
	new module.

	Separate out the context of each error specification, in order
	to allow the error messages to be sorted by context; this makes
	the output much easier to read.

compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
	Conform to the change to det_report.m.

mdbcomp/prim_data.m:
	Add a utility function for forming the possibly qualified names of
	library modules (such as "io" and "string").

library/Mercury.options:
compiler/Mercury.options:
	Add the lines that disable the new checks in the modules that need them
	disabled. The new lines are commented out until installed compilers all
	understand them, at which point in time we will add the requirement to
	understand the option to configure.in.

compiler/fact_table.m:
compiler/mlds_to_il.m:
	Fix three bugs reported by the new check that have apparently escaped
	detection all this time.

library/rtti_implementation.m:
	Change some code to avoid a spurious warning from the new checks.

library/string.m:
	Rename a predicate to avoid an unnecessary and confusing overloading of
	its name.

	Replace __ with . as module qualifier connective.

compiler/handle_options.m:
library/pprint.m:
	Misc cleanups.

tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
	New test cases to test the new warnings.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
	Enable the new test cases.

tests/general/string_format_test*.exp*:
	Update any expected abort messages to expect . instead of __ as module
	qualifier connective.

tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
	Expect the same error messages in program context order.
2006-01-27 05:52:27 +00:00
Samrith Uong
536503137d Removed --no-common-goal from the documented options.
Estimated hours taken: 0.2
Branches: main

Removed --no-common-goal from the documented options.

compiler/options.m and doc/user_guide.texi:
	This option can change the inferred determinism of some
	predicates, causing the compiler to fail to compile code that
	would otherwise compile without problems.  Turning off the
	optimization can also change the determinism of
	compiler-generated predicates, making the program impossible
	to compile.
2006-01-25 04:51:51 +00:00
Peter Wang
af878d04f9 Some work on the intermodule analysis framework.
Estimated hours taken: 45
Branches: main

Some work on the intermodule analysis framework.  The main changes are that
modules and analysis results have statuses associated with them, which are
saved in the `.analysis' files, and there is now code to handle intermodule
dependency graphs (that record which modules are dependent on a particular
analysis result).

Automatic recompilation of modules that use out of date or invalid analysis
results from other modules is not handled yet.

analysis/README:
analysis/analysis.m:
analysis/analysis.file.m:
	Remove the `FuncInfo' type variable everywhere.  This was originally
	designed to be used by analyses to store "extra" information that
	would be passed from an analysis implementation through the analysis
	framework, back to methods defined by the analysis implementation
	itself.

	The main problem was that `FuncInfo' made `Call' or `Answer' values
	hard to compare, as a `FuncInfo' value always had to be present for a
	comparison to be made (because the methods in the partial_order
	typeclass required FuncInfos).  One example of when this is hard to
	satisfy is when we are ready to write everything out to disk at the
	end of all analyses.  At this step there is much comparing of Call
	and Answer values, but this step is not invoked by any particular
	analysis pass.  To compare values we would need to get the FuncInfos
	from somewhere, which means we would have to store FuncInfos in the
	analysis_info maps as well.  And any time you have two FuncInfos, you
	need to choose one of the FuncInfos arbitrarily.

	Since FuncInfos would have to be read/written with every Call and
	Answer value, including IMDGs, I have changed it so that that any
	information which might be be stored in a `FuncInfo' should be stored
	in the corresponding `Call' value itself.

	Change the format of analysis result files to include an overall
	status for the module and a status for each analysis result.  The
	statuses record whether the module or analysis result could be
	improved by further compilation, or if the module or analysis result
	is no longer valid.

	Add code to read and write intermodule dependency graphs (IMDGs).  The
	IMDG file for module M records all the modules which depend on an
	analysis result for a procedure defined in M.

	Bump analysis file format version numbers as they are incompatible
	with earlier versions.

compiler/mercury_compile.m:
	Make `mercury_compile_after_front_end' use state variables for
	copies of the HLDS and update it to match changes in the intermodule
	analysis framework.

compiler/mmc_analysis.m:
	Add the trail usage analysis to the list of analyses to be used with
	the intermodule analysis framework.

	Update the entry for unused argument elimination.

	Add predicate `module_id_func_id'.

compiler/add_pragma.m:
compiler/hlds_module.m:
compiler/trailing_analysis.m:
	Make the trail usage analysis pass able to make use of the intermodule
	analysis framework.

	Associate each `trailing_status' in the `trailing_info' map with an
	`analysis_status', i.e. whether it is optimal or not.

compiler/unused_args.m:
	Update to match the removal of `FuncInfo' arguments and the
	addition of analysis statuses.

	Record the unused argument analysis result for a procedure even if
	all of the procedures arguments are used, so that callers of the
	procedure will know not to request more precise answers.

	Record the dependence of the current module on analysis results from
	other modules.

compiler/goal_util.m:
	Add predicate `pred_proc_ids_from_goal/2'.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/modules.m:
scripts/Mmake.vars.in:
	Make `mmc --make' and `mmake' realclean `.analysis', `.imdg' and
	`.request' files of non-library modules.  Files for imported library
	modules won't be deleted, but they probably shouldn't be generated in
	the first place.

NEWS:
library/list.m:
	Add a `list.map2_foldl2' predicate.

compiler/Mmakefile:
	Add the `analysis' directory to the list of directories to be
	processed by mtags.
2006-01-25 03:27:38 +00:00
Peter Wang
e3b4c8d1d8 Fix an infinite loop with `--debug-make'.
Estimated hours taken: 0.1
Branches: main

compiler/make.dependencies.m:
	Fix an infinite loop with `--debug-make'.

Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.21
diff -u -r1.21 make.dependencies.m
--- compiler/make.dependencies.m	17 Nov 2005 15:57:22 -0000	1.21
+++ compiler/make.dependencies.m	24 Jan 2006 02:41:46 -0000
@@ -996,7 +996,7 @@

 debug_newer_dependencies(TargetFileName, MaybeTimestamp,
         DepFiles, WriteDepFile, DepTimestamps, !IO) :-
-    debug_msg(debug_newer_dependencies(TargetFileName, MaybeTimestamp,
+    debug_msg(debug_newer_dependencies_2(TargetFileName, MaybeTimestamp,
         DepFiles, WriteDepFile, DepTimestamps), !IO).

 :- pred debug_newer_dependencies_2(string::in, maybe_error(timestamp)::in,
2006-01-24 06:07:19 +00:00
Julien Fischer
30da5fed1c Back out my change to report duplicate mode declarations for typeclass
Estimated hours taken: 0.5
Branches: main

compiler/post_typecheck.m:
	Back out my change to report duplicate mode declarations for typeclass
	methods.  It causes stage 2 to break when compiling mlds_to_il.m with
	intermodule-optimization enabled.
2006-01-17 04:51:42 +00:00
Julien Fischer
b78d146b75 Improve error reporting for type class declarations in the situation where a
Estimated hours taken: 10
Branches: main

Improve error reporting for type class declarations in the situation where a
mode declaration for a method has been provided but there is no function or
predicate declaration for that method.  Currently, this causes an internal
abort in the compiler.

Avoid another compiler abort in polymorphism.m when a type class method has two
duplicate mode declarations.

compiler/add_class.m:
	Change the order in which we add type class declarations to the HLDS
	so that we can detect and report situations where a type class method
	has a mode declaration but no corresponding predicate or function
	declaration.  All of the predicate/function method declarations for a
	particular typeclass need to be added before any mode declarations.
	We can then check that there is a corresponding predicate/function
	method declaration as each mode is added.

compiler/post_typecheck.m:
	Have the post-typechecking pass indicate that an error has occurred if
	we encounter indistinguishable mode declarations.  This prevents
	polymorphism being run if there are such mode declarations.  This
	avoids an internal abort in polymorphism.m when the mode declarations
	in question are type class methods.

	Unrelated change: s/io.state/io__state/ in an error message.

compiler/hlds_error_util.m:
	When formatting predicate names, specifically identify type class
	methods as such.  e.g. instead of `predicate foo/1' we now
	write them out as `type class predicate method foo/1'.

compiler/modecheck_call.m:
	Fix a typo: s/identical/indentical/

compiler/prog_item.m:
	Add the equivalence: class_methods == list(class_method).

compiler/equiv_type.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_typeclass.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.

tests/README:
	Fix an line that exceeds 80 characters in length.

tests/invalid/Mmakefile:
	Enable the test cases typeclass_mode_{2,3,4} since we now pass those
	tests.

	Delete a comment about `--split-c-files'.  That option is no longer
	supported.

tests/invalid/typeclass_mode_{2,3,4}.err_exp:
	Add expected outputs for these test cases.

tests/invalid/invalid_main.err_exp:
	The module qualifier in the expected output is now '.'.

tests/invalid/qualified_cons_id2.err_exp:
	Delete the determinism error from the expected output.  It won't show
	up now as the above changes mean the compiler will abort before
	determinism checking in this case.

tests/invalid/typeclass_dup_method_mode.{m,err_exp}:
	Add a test case for the problem that causes an abort in the
	polymorphism pass when a type class method has duplicate mode
	declarations.

tests/invalid/typeclass_mode.err_exp:
	Update the expected output to conform with the above changes.  Also,
	we no longer emit the spurious error message about missing clauses.

tests/recompilation/typeclass_method_pragma_r.err_exp.2:
	Update to conform to the new naming of type class methods
	in the error message.
2006-01-16 03:08:17 +00:00
Julien Fischer
acd90ad281 Avoid a warning from smart recompilation when generating a source file
Estimated hours taken: 0.5
Branches: main

compiler/handle_options.m:
	Avoid a warning from smart recompilation when generating a source file
	mapping.  The warning occurs because --no-target-code-only is enabled
	by default when --generate-source-file-mapping is specified and the
	former is incompatible with --smart-recompilation.
2006-01-13 05:07:34 +00:00
Peter Wang
0290b5a4bf This fixes some problems with building everything with `mmake --use-mmc-make'
Estimated hours taken: 3
Branches: main

This fixes some problems with building everything with `mmake --use-mmc-make'
on x86, or possibly any platform where shared libraries are supported.

Mmake.workspace:
	Add "--mercury-linkage static" or "--mercury-linkage shared" to
	`MCFLAGS' depending on whether the `LINK_STATIC' makefile variable is
	yes or no.

analysis/ANALYSIS_FLAGS.in:
	Add -L<dir> options so that the analysis library can find the boehm_gc,
	runtime and standard library files when built in shared linking mode.

browser/Mercury.options:
	Work around a problem with per-file variables and `mmake
	--use-mmc-make'.

compiler/COMP_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
	Remove "--linkage shared" from these files.  The Mmakefiles in these
	directories have "LINK_STATIC=yes" set.  This was causing a link error
	where the object files where being built with PIC but expected to
	link against lib*.a files.
2006-01-12 07:07:31 +00:00
Julien Fischer
5385013fbc Fix some minor typos and layout issues.
compiler/recompilation.m:
compiler/recompilation.version.m:
	Fix some minor typos and layout issues.
2006-01-12 06:19:56 +00:00
Julien Fischer
73e2f4b3be Fix a typo: s/detailed/detail/.
compiler/options.m:
	Fix a typo: s/detailed/detail/.
2006-01-11 07:11:01 +00:00
Julien Fischer
a488270232 Fix a typo: s/MCFLAGS/MGFLAGS/
Estimated hours taken: 0
Branches: main

compiler/Mercury.options:
	Fix a typo: s/MCFLAGS/MGFLAGS/
2006-01-11 05:59:22 +00:00
Julien Fischer
5af76e31ca Update some comments concerning the recently deleted
Estimated hours taken: 0
Branches: main

compiler/make.m:
compiler/ml_code_gen.m:
compiler/rtti_out.m:
	Update some comments concerning the recently deleted
	--split-c-files option.
2006-01-11 02:33:41 +00:00
Julien Fischer
6371128312 Fix a few spots where the conversion to 4-space indentation went
Estimated hours taken: 0.1
Branches: main

compiler/deep_profiling.m:
	Fix a few spots where the conversion to 4-space indentation went
	astray or where there are now unnecessary line breaks.
2006-01-10 06:35:56 +00:00
Peter Wang
881b2d8594 Add a --lib-linkage' accumulating option for mmc --make'.
Estimated hours taken: 3
Branches: main

Add a `--lib-linkage' accumulating option for `mmc --make'.  This option
allows you to specify whether libraries should be installed for shared
linking (`shared') or static linking (`static').  The option corresponds
to an options file or environment variable called `LIB_LINKAGES'.

compiler/options.m:
compiler/options_file.m:
doc/user_guide.texi:
	Add and document `--lib-linkage' option and `LIB_LINKAGES'
	variable.

	Unrelated change: document `--no-libgrade' option.

compiler/handle_options.m:
	If no --lib-linkage option has been specified, default to the
	set of all possible linkages.

compiler/make.program_target.m:
	Skip building/installing static or shared libraries according to
	the `--lib-linkage' options.
2006-01-06 04:06:55 +00:00
Peter Wang
7ce42d3355 Fix a bug when unused argument elimination was enabled with
Estimated hours taken: 3
Branches: main

compiler/unused_args.m:
	Fix a bug when unused argument elimination was enabled with
	intermodule analysis that caused an exception in the MLDS code
	generator.  The proc_infos for created imported procedures did
	not have the modes of unused arguments removed.

tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/intermod_unused_args.exp:
tests/hard_coded/intermod_unused_args.m:
tests/hard_coded/intermod_unused_args2.m:
	Add a test case.
2006-01-04 07:14:35 +00:00
Julien Fischer
89287a4206 Add a new developer-only option, `--disable-trail-ops', that disables the
Estimated hours taken: 0.5
Branches: main

Add a new developer-only option, `--disable-trail-ops', that disables the
output of trailing operations.  This is intended for analysing the performance
impact of trailing and is not otherwise useful.

compiler/options.m:
	Add the new option.

compiler/code_util.m:
compiler/mercury_compile.m:
	Support the new option in the code generators.
2006-01-03 04:07:50 +00:00
Julien Fischer
e9babef3f7 Update the year in the copyright messages to 2006.
Estimated hours taken: 0.1
Branches: main

compiler/handle_options.m:
doc/reference_manual.texi:
doc/user_guide.texi:
profiler/mercury_profile.m:
trace/mercury_trace_internal.c:
	Update the year in the copyright messages to 2006.
2006-01-03 04:03:07 +00:00
Julien Fischer
aca4918747 Make the trail usage analysis less conservative with respect to compiler
Estimated hours taken: 1
Branches: main

Make the trail usage analysis less conservative with respect to compiler
generated special predicates.  This increases the speed of a compiler built in
hlc.gc.tr with --intermodule-optimzation and trail usage analysis by about
3.5% and decreases the executable size by 5.2%.

compiler/trailing_analysis.m:
	Do not assume that type-specific compiler generated unification and
	comparison predicates always modify the trail; some of them, e.g.
	those for enumerations, do not.

	Delete this item from the TODO list.

compiler/mode_info.m:
	Unrelated change: fix indentation in a spot.

compiler/ml_code_gen.m:
	Unrelated change: s/Word/MR_Word/.
2005-12-24 08:44:13 +00:00
Samrith Uong
f28dd3c419 Turn on --use-local-vars at -O1. Benchmarking has shown that,
Estimated hours taken: 0.01
Branches: main

compiler/options.m:
	Turn on --use-local-vars at -O1.  Benchmarking has shown that,
	at -O2, --use-local-vars results in a 3.5% increase in speed
	and a 7% decrease in size.  This is at a cost of an extra 1.5%
	in compilation time.
2005-12-22 00:53:19 +00:00
Mark Brown
822aec3454 Fix a bug with typeclasses.
Estimated hours taken: 5
Branches: main

Fix a bug with typeclasses.

compiler/polymorphism.m:
	When setting up headvars for existential constraints in anything
	other than a class method, don't record type_info_locns for the
	constrained type vars.  They generally won't be usable in the given
	location, since the typeclass_infos that contain them might not be
	constructed until just before the procedure exits.

	In class methods, record the type_info_locns anyway.  We know that
	recording them won't be a problem (since we construct the method
	bodies ourselves) and it's easier to do it here.

tests/valid/Mmakefile:
tests/valid/exists_bug.m:
	New test case.
2005-12-21 23:20:00 +00:00
Julien Fischer
4f0f4d4818 Update the documentation of the `--analyse-trail-usage'
Estimated hours taken: 0.1
Branches: main

compiler/options.m:
doc/user_guide.texi:
	Update the documentation of the `--analyse-trail-usage'
	option and add it to the user guide.

	Fix typo: s/predicates/pedicates/
2005-12-21 02:26:43 +00:00
Julien Fischer
a6d2a8b312 Make --generate-trail-ops-inline the default for trailing with the high-level
Estimated hours taken: 0.2
Branches: main

Make --generate-trail-ops-inline the default for trailing with the high-level
C backend.

compiler/options.m:
doc/user_guide.texi:
	Make --generate-trail-ops-inline the default.

	Document --no-generate-trail-ops-inline.

compiler/mercury_compile.m:
	Disable --generate-trail-ops-inline for non-C backends.
2005-12-19 02:13:55 +00:00
Julien Fischer
0670506146 Provide a default value and type for the
Estimated hours taken: 0.1
Branches: main

compiler/options.m:
	Provide a default value and type for the
	data_structure_sharing_analysis option.
2005-12-17 14:30:52 +00:00
Nancy Mazur
0a0089e128 Preparing the field for adding CTGC into the compiler by starting to add the
Estimated hours taken: 1
Branches: main

Preparing the field for adding CTGC into the compiler by starting to add the
structure sharing analysis.

compiler/mercury_compile.m:
compiler/options.m:
compiler/transform_hlds.m:
	Add structure sharing analysis as a new pass of the mercury compiler.

compiler/ctgc.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.m:
	New files.
2005-12-16 12:17:55 +00:00
Peter Wang
964ffbb950 These changes allow the compiler to be built with `mmake --use-mmc-make'.
Estimated hours taken: 2
Branches: main

These changes allow the compiler to be built with `mmake --use-mmc-make'.

*/Mmakefile:
	Add dummy rules for optional `Mmake.*.params' files so that
	`mmc --make' is not asked to make them.

library/INTER_FLAGS_MMC_MAKE:
library/Mmakefile:
	Add a version of the `library/INTER_FLAGS' file to be used when
	`mmc --make' is being used.

library/LIB_FLAGS.in:
	Add `--c-include-directory ../robdd' so that `mmc --make' can find
	the included C files for `robdd.m'.

tools/bootcheck:
	Make `bootcheck --use-mmc-make' imply `bootcheck --use-subdirs'.

	Copy `INTER_FLAGS_MMC_MAKE' to stage 2 and stage 3 directories.

	Manually make `*_FLAGS' files in the stage 2 directory if
	`--use-mmc-make' is in effect.
2005-12-16 05:49:40 +00:00
Julien Fischer
0ff544cb9a Speed up trailing in high-level C grades. The code for adding trailing
Estimated hours taken: 6
Branches: main

Speed up trailing in high-level C grades.  The code for adding trailing
operations to the HLDS (in add_trail_ops.m) worked by inserting calls to the
trailing predicates defined in private_builtin.m.  These predicates in turn
call the macros defined in runtime/mercury_trailing.h.  The compiler was not
inlining the trailing predicates which was imposing a significant penalty on
the performance of trailing in the high-level C grades.

This diff modifies add_trail_ops.m so that it optionally generates inline
foreign_procs that call the trailing macros rather than generating calls to
library predicates.  For the compiler in grade hlc.gc.tr this results in a
23.4% speed increase at the cost of a 4% increase in executable size.  (Since
the two methods are compatible with each other there is scope for further
exploring this space/time tradeoff.)

XXX This needs to be documented properly.  Subject to further testing
    I intend to make the inlined foreign_proc method the default one, so
    I'll document it all properly then.

XXX The non-C backends will need to use the library call method at the
    moment but since trailing isn't really implemented for them that
    won't be too much of a problem ;-)
2005-12-16 04:08:45 +00:00
Julien Fischer
fc5159db46 Improve trail usage optimization of disjunctions for the LLDS backend.
Estimated hours taken: 6
Branches: main

Improve trail usage optimization of disjunctions for the LLDS backend.

Fix a bug in my previous change which implemented this for the MLDS backend.

compiler/disj_gen.m:
	Improve the trail usage optimization of disjunctions for the LLDS
	backend.

	Reformat some comments to take advantage of the extra space provided by
	the conversion to four-space indentation.

compiler/code_info.m:
	Add some utility predicates for use by the above.

compiler/add_trail_ops.m:
	Fix a bug where we weren't emitting instructions to prune the trail
	ticket in model_semi and model_det disjunctions.

compiler/handle_options.m:
	`--analyse-trail-usage' implies `--optimize-trail-usage' because the
	analysis results assume that the redundant trailing instructions are
	removed.  The reverse implication is not true but trying to optimize
	trail usage without running the analysis won't have any effect.
2005-12-14 06:10:11 +00:00
Ralph Becket
684ecfbd55 Undo my recent changes to purity error checking in the context of inst any
Estimated hours taken: 16
Branches: main

Undo my recent changes to purity error checking in the context of inst any
non-locals in negated contexts.

Implement a better way of handling the problem, as discussed on the mailing
list.  The new solution is to require that any goals featuring inst any
non-locals in a negated context must appear in a
promise_{pure,semipure,impure} context.  This is something of a compromise:
on the one hand it does require that the condition be explicitly recognised
by the programmer; on the other, it does not require that the "offending" goals
be individually identified (this is partly for pragmatic reasons: the earlier
approach required a plethora of awkward impurity declarations on goals that
would otherwise be considered completely pure).

compiler/mode_errors.m:
	Remove purity_error_should_be_impure and purity_error_wrongly_impure
	data constructors; add purity_error_should_be_in_promise_purity_scope.

compiler/mode_info.m:
	Replace the in_negated_context field with the in_promise_purity_scope
	field.

compiler/modecheck_call.m:
compiler/modecheck_unify.m:
	Back out my previous change.

compiler/modes.m:
	Record a purity error if a non-local inst any variable appears
	in a negation or the condition of an if-then-else goal.

compiler/purity.m:
compiler/unique_modes.m:
	Back out my previous change.

doc/reference_manual.texi:
	Document the new purity rules for inst any non-locals in negated
	contexts.

tests/debugger/solver_test.m:
tests/hard_coded/any_free_unify.m:
tests/invalid/any_passed_as_ground.m:
tests/invalid/any_to_ground_in_ite_cond.m:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/anys_in_negated_contexts.m:
tests/invalid/purity/impure_func_t7.err_exp:
tests/invalid/purity/impure_func_t7.m:
	Fix up error cases to use the new syntax.
2005-12-14 05:14:17 +00:00
Peter Wang
0864822eca Make `mmc --make' print an informative message telling the user where
Estimated hours taken: 2
Branches: main

compiler/make.util.m:
	Make `mmc --make' print an informative message telling the user where
	to look for the full error message log if it is truncating the log on
	standard output because of the `--output-compile-error-lines' option.
2005-12-13 00:25:04 +00:00
Ian MacLarty
784a271bcf Always write out ENDINIT, so that mkinit doesn't end up scanning
Estimated hours taken: 0.2
Branches: main

compiler/mlds_to_c.m:
	Always write out ENDINIT, so that mkinit doesn't end up scanning
	the whole file.
2005-12-12 16:31:43 +00:00
Peter Wang
23db45434a Fix a bug in which only the first entry of an analysis file was being
Estimated hours taken: 5
Branches: main

analysis/analysis.file.m:
	Fix a bug in which only the first entry of an analysis file was being
	parsed.

compiler/unused_args.m:
	Fix `unused_args_answer_from_string' which was not reading in the
	output of `unused_args_answer_to_string' correctly.

	Disable an assertion in `fixup_unused_args' which seems to be invalid
	with intermodule analysis.
2005-12-12 02:54:36 +00:00
Julien Fischer
24ab04569c Update the arity of the high-level data version of type_info and
Estimated hours taken: 1.5
Branches: main

runtime/mercury_hlc_types.h:
	Update the arity of the high-level data version of type_info and
	friends.

library/private_butilin.m:
	Update the arity of type_info etc in some comments and also in the
	assertion messages used by the IL and Java backends.

compiler/ml_code_gen.m:
	Unrelated changed: s/Word/MR_Word/ in a comment.
2005-12-08 06:14:36 +00:00
Ian MacLarty
d47e633804 Trace builtin and private_builtin (with the exception of external predicates
Estimated hours taken: 4
Branches: main

Trace builtin and private_builtin (with the exception of external predicates
and those that are polymorhphic, but have no extra type_info arguments).

This allows subterms to be traced through calls to predicates in builtin
and private_builtin and fixes an assertion failure in the declarative debugger
that was triggered when an untraced builtin called a traced predicate
(the debugger would then think the events from the traced predicate were
child events of the parent of the untraced predicate, which would cause the
assertion failure).

compiler/code_gen.m:
compiler/hlds_pred.m:
compiler/mercury_compile.m:
compiler/ml_code_util.m:
compiler/polymorphism.m:
compiler/stack_layout.m:
compiler/term_constr_initial.m:
mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
	Move no_type_info_builtin from compiler/hlds_pred.m to
	mdbcomp/program_representation.m, so that the debugger can call it
	to see what builtin polymorphic predicates do not have extra type_info
	arguments.

	Define pred_is_external to be true for predicates defined with
	:- external.  The debugger needs to know not to expect any events for
	such predicates.

	Trace the builtin and private_builtin modules.

tests/debugger/loopcheck.exp3:
tests/debugger/uci.exp2:
tests/debugger/uci_index.exp:
	Changes to expected output due to the fact that builtins are now
	traced.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/typed_unify.exp:
tests/debugger/declarative/typed_unify.inp:
tests/debugger/declarative/typed_unify.m:
	Test tracking of a subterm through a builtin.
2005-12-07 16:07:17 +00:00
Julien Fischer
37a8303efa Further improve trail usage optimization by omitting reset_undo_ticket
Estimated hours taken: 3
Branches: main

Further improve trail usage optimization by omitting reset_undo_ticket
instructions from disjuncts where the previous disjunct did not modify the
trail.  This can be done even in disjunctions where some of the disjuncts do
modify the trail.  At the moment this optimization is only implemented
for the MLDS backend - I'll add it to the lowlevel backend as a separate
change.

compiler/add_trail_ops.m:
	Implement the above optimization for the MLDS backend.

compiler/goal_form.m:
	Add a predicate goal_may_modify_trail.

compiler/mercury_compile.m:
	Add a comment mentioning that after we have added trail ops
	(stage 410) to the HLDS we can no longer reorder disjunctions.
	This should be okay since none of the following passes reorder
	disjunctions anyway.

vim/syntax/mercury.vim:
	Highlight `will_not_modify_trail' and `may_modify_trail'
	appropriately.

NEWS:
	Make the description of what trail usage optimization does more
	precise.  It affects goals other than if-then-elses, notably
	disjunctions and negations as well.
2005-12-07 04:57:10 +00:00
Peter Wang
30f486d397 Make `mmc --make' print a line for each file it is about to
Estimated hours taken: 0.1
Branches: main

compiler/make.util.m:
	Make `mmc --make' print a line for each file it is about to
	remove, if `--verbose-make' is set (the default).  This doesn't
	include temporary files made by `mmc --make' itself.
2005-12-07 02:56:25 +00:00
Julien Fischer
6129c79d03 Attach trail usage information to the goal_info rather than recomputing it on
Estimated hours taken: 10
Branches: main

Attach trail usage information to the goal_info rather than recomputing it on
demand.  This avoids repeated traversals of the goal structure during trail
usage optimization.

compiler/trailing_analysis.m:
	Add an optional second pass to trail usage analysis that annotates
	goals with trail usage information.  The second pass is optional
	because we only run it when we are generating code; when building the
	optimization interfaces we don't run it.

	Factor out code that is common to both passes into separate
	procedures.

	Fix some problems with the documentation in this module.

	Update the TODO list in this module.

	Add exception.rethrow/1 to the known procedures table.

compiler/hlds_goal.m:
	Add a new goal feature `will_not_modify_trail' that can be used to
	mark goals that will not modify the trail.

compiler/goal_form.m:
	Instead of traversing the a goal to work out if it may modify the
	trail, just look for the will_not_modify_trail feature in the
	goal_info.

compiler/saved_vars.m:
compiler/add_trail_ops.m:
compiler/code_gen.m:
compiler/code_util.m:
compiler/disj_gen.m:
	Minor change to conform to the above.
2005-12-06 06:26:07 +00:00
Peter Wang
2e71714bf4 Fix a typo which caused mmake to look for `.int0' files
Estimated hours taken: 0.5
Branches: main

compiler/modules.m:
	Fix a typo which caused mmake to look for `.int0' files
	in a `Mercury/ints' subdirectory instead of `Mercury/int0s'.
2005-12-06 01:56:29 +00:00
Peter Wang
6c14c1cbbe Fix some problems with `mmc --make'.
Estimated hours taken: 8
Branches: main

Fix some problems with `mmc --make'.

compiler/compile_target_code.m:
	In `link' predicate, after the file has been created in a grade
	subdirectory it would try to symlink or copy the file into the user
	directory.  This would fail if a file of the same name already existed
	there, so remove it before attempting the symlink/copy.

compiler/make.program_target.m:
	Prevent `mmc --make libFOO' from trying to produce a shared library
	if they are unsupported on the current architecture.

	Disable the logic to conditionally generate `.mh' files so as to avoid
	trouble with Mmake, which expects them to always exist.

	Fix a typo that tried to install `.mih' files into `int' directories
	instead of `ints'.

compiler/modules.m:
	Make `make_symlink_or_copy_file' write a newline after errors.
2005-12-05 02:17:21 +00:00
Peter Wang
43be969555 Change the header guards for .mh files from FOO_H to FOO_MH.
Estimated hours taken: 0.1

compiler/export.m:
	Change the header guards for .mh files from FOO_H to FOO_MH.
	This avoids a conflict where foo.m needs to #include <foo.h>
	but foo.h already uses a header guard called FOO_H.
2005-12-02 00:37:24 +00:00
Julien Fischer
45fdb6c451 Use expect/3 in place of require/2 throughout most of the
Estimated hours taken: 4
Branches: main

compiler/*.m:
	Use expect/3 in place of require/2 throughout most of the
	compiler.

	Use unexpected/2 (or sorry/2) in place of error/1 in more
	places.

	Fix more dodgy assertion error messages.

	s/map(prog_var, mer_type)/vartypes/ where the latter is meant.
2005-11-28 04:11:59 +00:00
Zoltan Somogyi
6d7b63df43 Remove support for the --split-c-files option, since it hasn't worked in a
Estimated hours taken: 1
Branches: main

Remove support for the --split-c-files option, since it hasn't worked in a
while, we haven't wanted to use it in a while, and the tradeoff of greatly
increased compilation time for a ~10% space gain is an increasingly bad one.

compiler/options.m:
doc/user_guide.texi:
	Remove the option.

NEWS:
	Mention the removal of the option.

compiler/modules.m:
	Remove the references to .split executables and archives from the
	generated .d files.

compiler/*.m:
	Delete the code for handling --split-c-files=yes, and make whatever
	simplifications this makes possible.

scripts/Mmake.*:
	Remove the references to .split executables and archives.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
	Remove the references to the --split-c-files option.

tests/hard_coded/split_c_files.{m,split.exp}:
tests/hard_coded/mapped_module.split.exp:
	Delete the test cases testing the deleted functionality.

tests/hard_coded/Mmakefile:
	Don't test split C files.
2005-11-28 02:30:36 +00:00