tests/invalid/require_tailrec_1.m:
tests/invalid/require_tailrec_2.m:
tests/invalid/require_tailrec_3.m:
Suppress some inlining that occurs at higher optimisation levels,
that changes the warnings produced for require_tail_recursion
pragmas.
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.err_exp2:
tests/invalid/require_tailrec_1.err_exp3:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.err_exp2:
tests/invalid/require_tailrec_2.err_exp3:
Update expected outputs for changed line numbers.
tests/invalid/require_tailrec_1.err_exp3:
tests/invalid/require_tailrec_2.err_exp3:
tests/invalid/require_tailrec_3.err_exp3:
Add these expected output files for deep profiling grades. They
differ from the expected output files for both the LLDS and MLDS
backends because deep profiling does not support *any* tail calls.
tests/invalid/require_tailrec_1.m:
tests/invalid/require_tailrec_2.m:
tests/invalid/require_tailrec_3.m:
Update the source code of these test cases to document
what circumstances each expected output file is for.
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.err_exp2:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.err_exp2:
tests/invalid/require_tailrec_3.err_exp:
tests/invalid/require_tailrec_3.err_exp2:
Update the existing expected output files to account for the
changes in line numbers caused by the new documentation.
This change enables warnings for mutual recursion for the low level C
backend.
--warn-non-tail-recursion currently only works for direct recursion. This
change renames it to --warn-non-tail-recursion-self and adds
--warn-non-tail-recursion which is intended to produce warnings for self
and mutual recursion.
compiler/options.m:
Add new option.
compiler/handle_options.m:
Make --warn-non-tail-recursion imply --warn-non-tail-recursion-self.
compiler/ml_tailcall.m:
Conform to changes in options.m.
compiler/mark_tail_calls.m:
Simplify the code that interprets tail recursion warning options, this
avoids the need for the warn_non_tail_rec_calls_opt which was only used
here in an unnecessary step. This logic has also been moved to a
separate predicate.
Add a warning for mutually recursive calls that are not tail recursive.
Update these warning/error messages to say if the call is self or
mutually recursive. Also in the case of mutually recursive calls, name
the callee.
compiler/mercury_compile_llds_back_end.m:
Compute the dependency information before running the pre-LLDS passes.
This makes sure that we do this once for the whole module, and
independently of --trad-passes.
compiler/dependency_graph.m:
Add a method for getting the SCC of a given node from a dependency_info
structure. The SCC is retrieved from a lazily built map.
doc/user_guide.texi:
Document the changes.
tests/invalid/Mmakefile:
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.m:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.m:
tests/invalid/require_tailrec_3.err_exp:
tests/invalid/require_tailrec_3.m:
tests/valid/Mmakefile:
tests/valid/require_tailrec_1.m:
tests/valid/require_tailrec_2.m:
tests/valid/require_tailrec_3.m:
Test the tail recursion warnings a lot more extensively, some of these
are new test programs, others just have many more test cases within
them.
tests/invalid/Mercury.options:
tests/valid/Mercury.options:
Add new test files.
Disable most optimisations as these could optimise away the mutual tail
recursions.
tests/EXPECT_FAIL_TESTS.hlc.gc:
New test case failures.
Its syntax is
disable_warnings [warning_category1, ...] Goal
Its semantics is identical to Goal's semantics, with the only difference
being that the compiler will not generate warnings belonging to the listed
categories for code inside Goal.
At the moment, we support the disabling of two warning categories:
singleton variable warnings, and warnings about recursive calls that are not
*tail* recursive. However, the documentation of the latter is commented out
until we use the same code for generating such warnings regardless of what
backend generates code.
doc/reference_manual.texi:
Document the new language extension.
NEWS:
Mention the new language extension.
library/ops.m:
Make "disable_warnings" (and its "disable_warning" variant) binary prefix
operators, as required for the syntax of the new scope.
compiler/prog_item.m:
Add disable_warnings_expr as a new kind of goal in the parse tree.
compiler/hlds_goal.m:
Add disable_warnings as a new kind of scope goal in the HLDS.
compiler/prog_data.m:
Add a type that represents the set of warnings that may be disabled.
This type cannot be in prog_item.m, because it is needed by the HLDS,
and we don't want the HLDS to depend on prog_item.m.
compiler/parse_goal.m:
Parse the new kind of goal, transforming it from source code to parse tree.
compiler/goal_expr_to_goal.m:
Transform the new kind of goal from parse tree to HLDS.
compiler/prog_out.m:
compiler/parse_tree_out_clause.m:
compiler/hlds_out_goal.m:
Output the new kinds of parse tree and HLDS goals.
compiler/make_hlds_warn.m:
Disable singleton variable warnings when the new scope asks for that.
compiler/mark_tail_calls.m:
Disable warnings about non-tail-recursive recursive calls
when the new scope asks for that.
Improve a warning message.
compiler/ml_tailcall.m:
Document why this sort-of-duplicate implementation of the
warnings about non-tail-recursive recursive calls cannot respect
the new scope. (I believe this sort-of-duplicate code should be deleted.)
Improve the same warning message as in mark_tail_calls.m.
compiler/constraint.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/erl_code_gen.m:
compiler/get_dependencies.m:
compiler/goal_util.m:
compiler/hlds_desc.m:
compiler/interval.m:
compiler/lambda.m:
compiler/modecheck_goal.m:
compiler/module_qual.collect_mq_info.m:
compiler/polymorphism.m:
compiler/prog_item_stats.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/saved_vars.m:
compiler/simplify_goal_scope.m:
compiler/simplify_proc.m:
compiler/stm_expand.m:
compiler/switch_detection.m:
compiler/try_expand.m:
compiler/typecheck.m:
compiler/unique_modes.m:
Handle the new kind of scope.
In a couple of places, fix comments.
tests/invalid/require_tailrec_1.{m,err_exp}:
Wrap a disable_warnings scope around one of the non-tail-recursive
recursive calls we used to get a warning about, and expect that
we don't get this warning anymore. (We still do get this warning in grades
that use ml_tailcall.m instead of mark_tail_calls.m to generate such
warnings, as mentioned above.)
Specify Mercury syntax highlighting for the source file.
Expect the improved wording of a warning.
tests/invalid/require_tailrec_2.{m,err_exp}:
Specify Mercury syntax highlighting for the source file.
Expect the improved wording of a warning.
tests/warnings/singleton_test.m:
Add a test of a singleton variable whose warning is disabled.
compiler/mark_tail_calls.m:
As above for the low level C backend.
compiler/ml_tailcall.m:
As above for the MLDS backends.
This has required some refactoring to track whether the code is
recursive or not.
compiler/mercury_compile_mlds_back_end.m
Conform to changes in ml_tailcall.m
tests/invalid/require_tailrec_1.{m,err_exp}:
tests/invalid/require_tailrec_2.{m,err_exp}:
Add tests for this.
This patch reduces spurious tail call warnings by warning only for the last
of a sequence of recursive calls along an execution path, for example it
no-longer emits a warning for the first of the two recursive calls in
quicksort. I have already made a change to this effect for the MLDS
backends.
This patch also implements the new the require_tail_recursion pragma. This
change has already been made for the MLDS backends.
The require_tail_recursion pragma does not yet handle mutual recursion or
raise an error if the code is not recursive at all. These will be my next
tasks.
compiler/mark_tail_calls.m:
Combine marking tail calls with warning about tail calls.
Handle scopes more accurately.
compiler/mercury_compile_llds_back_end.m:
Conform to changes in mark_tail_calls.m
No longer warn for tail calls, this is now done in the same pass that
marks tail calls. The decision to run this pass is now made on a
per-procedure basis and in mark_tail_calls.m
tests/invalid/require_tailrec_1.m:
tests/invalid/require_tailrec_2.m:
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/valid/require_tailrec_1.m:
tests/valid/require_tailrec_2.m:
tests/valid/Mmakefile:
tests/valid/Mercury.options:
Add new tests.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/require_tail_recursion.{m,err_exp} ->
require_tailrec_invalid.{m,exp}:
Rename existing test.