compiler/intermod.m:
We used to put predicate declarations and definitions into .opt files
in order of pred_id. Since pred_ids are allocated sequentially, this
meant that the order of the pragmas in .*opt files recording analysis
results was determined by the order of the predicate declarations
in the .m file, and if this changes, everything that depends on the
.opt file has to be recompiled. Change this to put the pragmas into
an order based on the predicates' names, arities, and pred_or_func flag.
Precede each block of analysis results (one block per pragma type)
with a blank line, to make .*opt files a bit easier to read by revealing
their structure.
When printing analysis results for all the procedures of a predicate,
don't get a list of proc_ids and then look them up one by one; just
iterated over all the proc_infos in the proc_table.
Rename some predicates to make their names fit into the naming scheme
used in the rest of the module.
compiler/hlds_module.m:
compiler/hlds_pred.m:
The results of the exception, trailing and mm_tabling analyses
used to be stored in the module_info as maps from pred_proc_ids
to the results about the procedure. Change this to store them
in the proc_info of the procedure, since any code that looks up
the results of an analysis typically also wants to look up other
information in the proc_info as well. (intermod.m certainly does.)
The results of the termination, structure sharing and structure reuse
analysis were already stored in the proc_info.
compiler/add_pragma.m:
When reading in exceptions, trailing and mm_tabling pragmas,
add their information to the named procedure's proc_info,
not to a map in the module_info.
compiler/exception_analysis.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
Put analysis results into procedures' proc_infos, not into a map
in the module_info, and if need be, look it up there as well.
compiler/goal_form.m:
Look up the results of exception_analysis in procedures' proc_infos,
not in a map in the module_info.
compiler/lco.m:
Work around a bug in lco.m itself exposed by the move of analysis
results to proc_infos. When lco.m duplicates the proc_info of a procedure
that it optimizes, it now duplicates its analysis results as well.
The duplication is correct in a sense, since any results of the exception,
trailing and mm_tabling analysis that hold for the original procedure
have to hold for the duplicate copy as well, but interestingly, this extra
precision causes simplify to believe that the call from the original
procedure to duplicated procedure is dead code that can be eliminated,
since it is det and appears to have no outputs. In fact, it does have
outputs, but it returns those outputs via impure calls to store_at_ref.
While the call to store_at_ref in the duplicated procedure is marked
as impure, the call to the duplicate procedure in the original procedure
is NOT (yet) so marked.
compiler/parse_tree_out_pred_decl.m:
When printing parts of predicate declarations, e.g. as parts of pragmas
that record analysis results, don't take as an argument a context that
will never be used.
compiler/add_clause.m:
compiler/dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/make_hlds_error.m:
compiler/mode_errors.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_pragma.m:
compiler/typecheck.m:
Conform to the changes in parse_tree_out_pred_decl.m above.
tests/term/*.trans_opt_exp:
Expect the same termination analysis results as before, just in
predicate name order, and with a blank line before each block.
Estimated hours taken: 0.1
Branches: main
tests/term/*.trans_opt_exp:
Update the expected outputs of these test cases.
These have changed because of the recent change
to termination2_info pragmas.
Estimated hours taken: 1
Branches: main
Fix recent test case failures in the term directory. The test case
failures were caused by the argument size constraints being in a
different order to the expected outputs in some grades. (The change
in the ordering is due to differences in the HLDS in each grade.)
Also, fix an additional problem where non-negativity constraints
where being written out as part of the termination2_info pragmas.
This is unnecessary as the analyser assumes that variables are
non-negative anyway.
compiler/term_constr_main.m:
When writing out argument size constraints in the termination2_info
pragmas, make sure that we don't write out non-negativity
constraints.
Sort the constraint set before writing it out to the
termination2_info pragmas.
tests/term/*.trans_opt_exp.m:
Minor changes to conform to the above.
Estimated hours taken: 1
Branches: main
Enable the support for writing out termination2_info pragmas
in the .opt and .trans_opt files.
Test both termination analyses when running the test suite.
compiler/term_constr_main.m:
compiler/trans_opt.m:
Uncomment the code that causes termination2_info pragmas
to be written out the .opt and .trans_opt files.
tests/term/Mmakefile:
Run the new termination analyser on these tests as well.
tests/term/*.trans_opt_exp:
Include the expected termination2_info pragmas.
Estimated hours taken: 14
Branches: main
Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.
Infix `.' now has associativity yfx and priority 10.
NEWS:
Report the change.
configure.in:
Amend the test for an up-to-date Mercury compiler to check whether
it recognises `.' as a module qualifier.
compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
Change `:' to `.' as module separator for output.
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
As above.
Fixed a bug where `.' was not being recognised as a module separator.
doc/reference_manual.texi:
Report the change.
library/term_io.m:
Ensure that infix `.' is written without surrounding spaces.
tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 6
compiler/mercury_to_mercury.m:
compiler/mode_errors.m:
Make the code a little bit more readable:
use specific types rather than `bool' in a few places.
compiler/mercury_to_mercury.m:
Fix bugs in the generation of interface files where it was
outputting certain graphic tokens incorrectly. In particular,
it was outputting things like `module:?' without any parentheses,
space, or quotes to separate the `:' as module qualifier from
the symbol name.
tests/hard_coded/Mmakefile:
tests/hard_coded/quoting_bug.m:
tests/hard_coded/quoting_bug_test.m:
tests/hard_coded/quoting_bug_test.exp:
Add some tests for the above-mentioned bug fix.
tests/term/*.trans_opt_exp:
tests/misc_tests/pretty_print_test.exp:
Update expected output for these tests to reflect the
above changes.
Estimated hours taken: 60
A rewrite of termination analysis to make it significantly easier to modify,
and to extend its capabilities.
compiler/error_util.m:
A new file containing code that makes it easier to generate
nicely formatted error messages.
compiler/termination.m:
Updates to reflect the changes to the representation of termination
information.
Instead of doing pass 1 on all SCCs and then pass 2 on all SCCs,
we now do both pass 1 and 2 on an SCC before moving on to the next.
Do not insist that either all procedures in an SCC are
compiler-generated or all are user-written, since this need not be
true in the presence of user-defined equality predicates.
Clarify the structure of the code that handles builtins and compiler
generated predicates.
Concentrate all the code for updating module_infos in this module.
Previously it was scattered in several places in several files.
Put all the code for writing out termination information at the
end of the module in a logical order.
compiler/term_traversal.m:
A new file containing code used by both pass 1 and pass 2 to
traverse procedure bodies.
compiler/term_pass1.m:
Use the new traversal module.
Clarify the fixpoint computation on the set of output supplier
arguments.
Remove duplicates from the list of equations given to the solver.
This avoids a det stack overflow in lp.m when doing termination
analysis on options.m.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_pass2.m:
Use the new traversal module. Unlike the previous code, this allows us
to ignore recursive calls with input arguments bigger than the head
if those calls occur after goals that cannot succeed (since those
calls will never be reached).
Implement a better way of doing single argument analysis, which
(unlike the previous version) works in the presence of mutual recursion
and other calls between the recursive call and the start of the clause.
Implement a more precise way of checking for recursions that don't
cause termination problems. We now allow calls from p to q in which
the recursive input supplier arguments can grow, provided that on
any path on which q can call p, directly or indirectly, the recursive
input supplier arguments shrink by a greater amount.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_util.m:
Updates to reflect the changes to the representation of termination
information.
Reorder to put related code together.
Change the interface of several predicates to better reflect the
way they are used.
Add some more utility predicates.
compiler/term_errors.m:
Small changes to the set of possible errors, and major changes in
the way the messages are printed out (we now use error_util).
compiler/options.m:
Change --term-single-arg from being a bool to an int option,
whose value indicates the maximum size of an SCC in which we try
single argument analysis. (Large SCCs can cause single-arg analysis
to require a lot of iterations.)
Add an (int) option that controls the max number of paths
that we are willing to analyze (analyzing too many paths can cause
det stack overflow).
Add an (int) option that controls the max number of causes of
nontermination that we print out.
compiler/hlds_pred.m:
Use two separate slots in the proc_info to hold argument size data
and termination info, instead of the single slot used until now.
The two kinds of information are produced and used separately.
Make the layout of the get and set procedures for proc_infos more
regular, to facilitate later updates.
The procedures proc_info_{,set_}variables did the same work as
proc_info_{,set_}varset. To eliminate potential confusion, I
removed the first set.
compiler/*.m:
Change proc_info_{,set_}variables to proc_info_{,set_}varset.
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Change the code to handle the arg size data and the termination
info separately.
compiler/prog_data.m:
Change the internal representation of termination_info pragmas to
hold the arg size data and the termination info separately.
compiler/prog_io_pragma.m:
Change the external representation of termination_info pragmas to
group the arg size data together with the output supplier data,
to which it is logically connected.
compiler/module_qual.m:
compiler/modules.m:
Change the code to accommodate the change to the internal
representation of termination_info pragmas.
compiler/notes/compiler_design.html:
Fix some documentation rot, and clarify some points.
Document termination analysis.
doc/user_guide.texi:
Document --term-single-arg and the new options.
Remove spaces from the ends of lines.
library/bag.m:
Add a new predicate, bag__least_upper_bound.
Fix code that would do the wrong thing if executed by Prolog.
Remove spaces from the ends of lines.
library/list.m:
Add a new predicate, list__take_upto.
library/set{,_ordlist}.m:
Add a new predicate, set{,_ordlist}__count.
tests/term/*:
A bunch of new test cases to test the behaviour of termination
analysis. They are the small benchmark suite from our paper.
tests/Mmakefile:
Enable the new test case directory.