tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
Estimated hours taken: 70
Branches: main
Add an analysis that tries to identify those procedures
in a module that will not throw an exception.
(I guess it may be more accurate to call it a non-exception analysis).
For those procedures that might throw exceptions the
analysis further tries to distinguish between those
that throw an exception as a result of a call to throw
and those that throw an exception as a result of a
call to a unification/comparison predicate that may involve
calls to user-defined equality/comparison predicates that throw
exceptions.
This sort of thing used to be done by the termination analysis,
where being able to prove termination was equated with not
throwing an exception. This no longer works now that
the termination analyser considers exception.throw/1 to
be terminating - and in fact it never quite worked anyway
because the termination analyser was not handling things
like foreign code and user-defined equality and comparison
predicates correctly.
There are currently a few limitations, the main ones being:
* we currently use transitive-intermodule optimization rather
than the intermodule-analysis framework. This may causes
problems when their are cycles in the module dependency graph.
* we currently assume that all calls to higher-order predicates
may result in an exception being thrown.
* we currently assume that all foreign procs that make calls
back to Mercury may throw exceptions.
* we currently assume that all solver types and existentially
quantified types might result in an exception being thrown.
It should be possible to remove these limitations in later
versions.
This diff also modifies the cannot_loop_or_throw family of
predicates in goal_form.m. There are now two versions of each
predicate; one that can make use of information from the
termination and exception analyses and one that cannot.
compiler/exception_analysis.m:
The new analysis.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Handle `:- pragma exceptions(...' in .opt and .trans_opt files.
compiler/hlds_module.m:
Attach information to each module about whether each procedure
in the module may throw an exception.
compiler/goal_form.m:
Rewrite the predicates in this module so that they can
optionally use information from the exception analysis.
compiler/constraint.m:
compiler/goal_util.m:
compiler/rl.m:
compiler/simplify.m:
Use information from exception and termination analyses
when performing various optimizations.
compiler/type_util.m:
Add a new predicate type_util.type_is_existq/2 that tests
whether a type is existentially quantified or not.
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/modules.m:
compiler/options.m:
compiler/module_qual.m:
compiler/make_hlds.m:
compiler/recompilation.version.m:
compiler/trans_opt.m:
compiler/transform_hlds.m:
Minor changes needed by the above.
NEWS:
compiler/notes/compiler_design.html:
doc/user_guide.texi:
Mention the new analysis.
tests/README:
Include a description of the term directory.
tests/term/Mercury.options:
tests/term/Mmakefile:
tests/term/exception_analysis_test.m:
tests/term/exception_analysis_test.trans_opt_exp:
Add a test for the new analysis.