Estimated hours taken: 12
Branches: main
Add a new goal form, as discussed on our mailing lists:
promise_equivalent_solution_sets [Vars] (
arbitrary [Vars1] Goal1,
arbitrary [Vars2] Goal2,
...
)
NEWS:
Mention the new goal form.
doc/reference_manual.texi:
Document the new goal form.
library/ops.m:
Add "promise_equivalent_solution_sets" and "arbitrary" as new
operators.
compiler/prog_item.m:
Add a parse_tree representation of new constructs.
Change the representation of goal forms in the parse tree to avoid
using punctuation marks as function symbols, to avoid function symbols
that need quoting, and to avoid ambiguity with hlds_goal_expr.
Delete the obsolete if_then (no else) goal form.
compiler/hlds_goal.m:
Provide a HLDS representation of the new constructs.
compiler/det_analysis.m:
Implement the rules for processing the new constructs.
compiler/det_report.m:
Implement the messages for the errors that can occur with the
new constructs.
Add quotes around `promise_equivalent_solutions' in an existing error
message, for consistency.
compiler/prog_io_goal.m:
Parse the new goal constructs.
compiler/add_clause.m:
compiler/hlds_out.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/pd_util.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
compiler/saved_vars.m:
compiler/simplify.m:
Conform to the changes to prog_item.m and hlds_goal.m.
tests/hard_coded/one_member.{m,exp}:
New test case to test the proper functioning of the new construct.
tests/invalid/one_member.{m,err_exp}:
New test case to test the kinds of errors that can occur when using
the new construct.
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/promise_equivalent_solutions_test.err_exp:
Expect quotes around an old construct name, after the change to
det_report.m.
Estimated hours taken: 6
Branches: main
Change the way we represent static cells. Instead of generating a separate
global variable for each static cell, generate global variables that are
arrays, each containing all the static cells of the same type. By reducing
the number of symbols requiring relocation, this reduces link times, especially
in debug grades (since those have lots of static cells).
compiler/global_data.m:
Rewrite the part of this module that handles static cells in line
with the above.
compiler/llds.m:
Modify the data structures for representing static cells in line with
the above.
compiler/llds_out.m:
Delete all the code for grouping together all the static cells of the
same type, since it is not needed anymore. Replace with simpler code
to print out the new arrays of static cells.
Rename some predicates to eliminate ambiguity.
compiler/opt_debug.m:
Conform to the change in llds.m.
compiler/rtti_out.m:
Conform to the change in llds_out.m.
runtime/mercury_misc.h:
runtime/mercury_stack_layout.h:
Create variants of the existing shorthand macros to refer to static
cells not using a specified global variable but using a specified
offset in a specified array.
Once this change has been bootstrapped on all our machines, the old
variants can be deleted.
Estimated hours taken: 6
Branches: main
Fix a bug with solver types and mutables that was causing the compiler to
abort in deep profiling grades (The HLDS was incorrect in all grades, it just
didn't show in most of them). The bug occurred when a mutable was initialised
with a non-ground value, as in the following example derived from Ralph's sat
solver:
:- mutable(global, sat_literal, _, any, [untrailed]).
(sat_literal is some solver type).
The problem was that when adding the clauses for the mutable initialisation
predicates to the HLDS we did not consider that the initial value might be a
variable, as in this case, and attached an empty varset to the clause instead
of one containing the variable.
For the intialisation predicate for the above mutable, we have the following
at stage 197:
msat.initialise_mutable_global :-
msat.'__Initialise__'(V_1),
impure msat.set_global(V_1).
The prog_varset is (incorrectly) empty at this point - it should contain
V_1.
Deep profiling, stage 205, now comes along and starts allocating fresh
variables. The results pretty much speak for themselves ;-)
msat.initialise_mutable_global :-
ProcStaticLayout = deep_profiling_proc_layout(...),
impure det_call_port_code_sr(ProcStaticLayout, TopCSD,
MiddleCSD, ActivationPtr),
SiteNum = 0,
impure prepare_for_normal_call(SiteNum),
msat.'__Initialise__'(TopCSD), % *** should be V_1
SiteNum = 1,
impure prepare_for_normal_call(SiteNum),
impure msat.set_global(TopCSD), % *** should be V_1
impure det_exit_port_code_sr(TopCSD, MiddleCSD, ActivationPtr).
The fix is to attach the varset we use at parse time to the mutable items and
when adding the clauses for the mutable initialisation predicate to the HLDS,
to use that varset instead of an empty one.
compiler/prog_item.m:
compiler/prog_io.m:
Attach the varset to the mutable item, in case the initial value term
has a non-ground value.
compiler/make_hlds_passes.m:
Use the above varset when constructing the clauses for the mutable
initialisation predicates in order to avoid the bug outlined above.
compiler/equiv_type.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the above changes to the mutable item.
tests/valid/Mmakefile:
tests/valid/solver_type_mutable_bug.m:
Test case for the above derived from msat.m by Ralph.
Estimated hours taken: 0.1
Branches: main
compiler/make_hlds_passes.m:
Set the exit status to 1 if we detect an attempt to use
a trailed mutable in a non-trailing grade.
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all the compiler modules to use . instead of __ as
the module qualifier.
In some cases, change the names of predicates and types to make them
meaningful without the module qualifier. In particular, most of the
types that used to be referred to with an "mlds__" prefix have been
changed to have a "mlds_" prefix instead of changing the prefix to
"mlds.".
There are no algorithmic changes.
Estimated hours taken: 2
Branches: main
Cleanups for the il backend. Aside from changing some if-then-elses into
switches there are no changes to any algorithms.
compiler/ilasm.m:
compiler/ilds.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m
compiler/mlds_to_managed.m:
Convert these modules to use 4-space indentation where that has not
already been done.
Rename the type ilds.type as ilds.il_type in order to avoid having
to parenthesize it.
Replace __ with . as the module qualifier.
Use state variable notation in a few spots.
Replace some if-then-elses with switches.
Conform more closely to our current coding standard.
Remove duplicate module import declarations.
Estimated hours taken: 0.1
Branches: main
Enable `--warn-known-bad-format-calls' by default since the change
that added it has now bootstrapped on all of our machines.
configure.in:
Test that the installed compiler supports the
`--warn-known-bad-format-calls' option.
compiler/options.m:
Enable the option by default.
library/Mercury.options:
Uncomment the code that disables this check on modules where
it needs to be disabled. (The corresponding lines in the
compiler directory where deleted along with the Aditi backend.)
Estimated hours taken: 0.5
Branches: main
profiler/*.m:
deep_profiler/*.m:
compiler/*.m:
Replace __ with . as the module qualifier everywhere in all the modules
of the profiler and deep profiler and in some modules of the compiler.
Estimated hours taken: 10
Branches: main
Fix a few problems in the low-level parallel grade.
compiler/par_conj_gen.m:
runtime/mercury_context.c:
runtime/mercury_context.h:
Fix some off-by-one bugs introduced when `MR_sp' was changed to mean
the last used word on the det stack, rather than the first free word.
Update references to renamed fields in the MR_Context structure.
Change some `assert' calls to `MR_assert'.
Estimated hours taken: 2
Branches: main
Add a new pragma, promise_equivalent_clauses, whose effect is to promise
that mode-specific clauses don't make a predicate definition impure.
doc/reference_manual.texi:
Document the new pragma.
compiler/prog_item.m:
Add a representation of the new pragma.
compiler/prog_io_pragma.m:
Parse the new pragma.
compiler/hlds_pred.m:
Add the corresponding marker to predicates.
Reformat some type definitions to comply with our current standards.
compiler/purity.m:
Respect the new pragma when computing the purity of predicates.
compiler/add_pragma.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/table_gen.m:
Process the new pragma.
compiler/make_hlds_passes.m:
Fix some documentation rot.
tests/hard_coded/promise_equivalent_clauses.{m,exp}:
New test case to test the proper functioning of the new pragma
tests/invalid/promise_equivalent_clauses.{m,exp}:
New test case to test that the new pragma doesn't promise all that
promise_pure would promise.
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
Enable the new test cases.
Estimated hours taken: 1.5
Branches: main
More fixes and cleanups for ctgc. The only algorithmic change is that
we now disable structure sharing for predicates from *all* builtin modules,
not just those from builtin and private_builtin.
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/prog_ctgc.m:
compiler/ctgc.datastruct.m:
Further cleanups for the ctgc system.
Estimated hours taken: 2
Branches: main
compiler/*ctgc*.m:
compiler/structure_sharing*.m:
Further cleanups, mostly renaming predicates with ambiguous names,
and turning some lambda expressions into named predicates.
Estimated hours taken: 1
Branches: main
Improve the integration of the structure sharing analysis into the
(transitive-)intermodule optimization framework.
compiler/structure_sharing.analysis.m:
When building the the optimization interfaces we were performing
structure sharing analysis but the results were not being written out
to the .opt files. Add code to do this.
Don't write out structure sharing pragmas for procedures created by
type specialization - the compiler can't read them back in because the
type specialized versions don't yet exist when it reads the
.{opt,trans_opt} files. (This is a long standing limitation.)
compiler/handle_options.m:
Avoid unexpected behaviour: `--structure-sharing' should not imply
`--trans-intermod-opt'.
Estimated hours taken: 1
Branches: main
Improve the integration of the structure sharing analysis into the
(transitive-)intermodule optimization framework.
compiler/structure_sharing.analysis.m:
When building the the optimization interfaces we were performing
structure sharing analysis but the results were not being written out
to the .opt files. Add code to do this.
Don't write out structure sharing pragmas for procedures created by
type specialization - the compiler can't read them back in because the
type specialized versions don't yet exist when it reads the
.{opt,trans_opt} files. (This is a long standing limitation.)
compiler/handle_options.m:
Avoid unexpected behaviour: `--structure-sharing' should not imply
`--trans-intermod-opt'.
compiler/error_util.m:
Replace a missing full stop.
compiler/stratify.m:
compiler/termination.m:
s/bottom up/bottom-up/
tests/warnings/non_stratification.exp:
Conform to the above.
Estimated hours taken: 1.5
Branches main.
Clean up (some of) the formatting of the recently committed CTGC modules so
that they conform more closely to our coding standards. I made these changes
while reviewing these modules (I'll post the actual review comments
separately). There are no changes to any algorithms.
compiler/ctgc.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.fixpoint_table.m:
compiler/ctgc.selector.m:
compiler/ctgc.util.m:
compiler/prog_ctgc.m:
compiler/prog_data.m:
compiler/structure_sharing.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
Use four-space indentation in all of these modules.
Fix inconsistent indentation.
Use state variables in more places.
Use switches in preference to if-then-elses.
Use procedures from the sv* modules where appropriate.
s/io__state/io/
Remove unnecessary module qualification.
Lots of other minor formatting changes.
Estimated hours taken: 2
Branches: main
Improve the formatting of some error messages by using error_util
and hlds_error_util to handle the formatting of the error messages.
compiler/error_util.m:
Add a new format component `quote', which is identical to `fixed'
except that it outputs it's argument surrounded by `' quotes.
compiler/add_clause.m:
compiler/add_type.m:
compiler/make_hlds_passes.m:
compiler/options_file.m:
compiler/qual_info.m:
compiler/stratify.m:
Use the error_util to format warning/error messages rather than
doing it manually.
compiler/passes_aux.m:
complier/hlds_out.m:
Update comments.
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/sub_c.err_exp:
tests/invalid/types.err_exp:
Update the expected outputs of these test cases to account
for formatting changes introduced by the above.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/non_stratification.{exp,m}:
Add a test case for the `--warn-non-stratification' option.
Estimated hour taken: 0.1
Branches: main
compiler/options.m:
doc/user_guide.texi:
Mention that `--transitive-intermodule-optimization' does not
work with `mmc --make'.
Estimated hours taken: 1.5
Branches: main
Remove residual parts of the Aditi backend that weren't deleted the other day.
configure.in:
Mmake.common.in:
Remove support for enabling the Aditi backend.
runtime/mercury_aditi.h:
Remove this file.
runtime/Mmakefile:
runtime/mercury.h:
runtime/mercury_imp.h:
runtime/mercury_ho_call.[ch]:
runtime/mercury_wrapper.[ch]:
Delete support for Aditi in the runtime.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
scripts/c2init.in:
scripts/parse_ml_options.sh-subr.in:
Remove mmake support for building .rlo files, etc.
util/mkinit.c:
Remove Aditi specific code.
compiler/bytecode_data.m:
compiler/closure_analysis.m:
compiler/code_model.m:
compiler/compile_target_code.m:
compiler/det_analysis.m:
compiler/handle_options.m:
compiler/hlds_goal.m:
compiler/hlds_module.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_gcc.m:
compiler/modecheck_call.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/options.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/term_errors.m:
compiler/unify_proc.m:
mdbcomp/prim_data.m:
Remove residual support for Aditi.
library/ops.m:
Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the
ops table.
doc/reference_manual.texi:
doc/user_guide.texi:
Delete the sections on the Aditi interface.
extras/aditi/*:
Delete this.
Estimated hours taken: 5
Branches: main
Prepare for an extension of promise_equivalent_solutions that will allow us
to better handle values of user-defined types. The problem is that currently,
the deconstruction of a value of such a type can be followed only by code that
cannot fail, otherwise the cc_multi deconstruction is not in the required
single-solution context. If the following code is naturally semidet, this
can be worked around by turning it into det code returning a maybe and testing
the maybe outside the promise_equivalent_solutions, but this is inefficient,
and in any case it does not generalize to nondet code without even more
horrendous inefficiency and inconvenience. (You have to create a nondet closure
and call it outside the promise_equivalent_solutions.)
The solution I came up with is something is to have a construct that contains
- a list of deconstructions on types with user-defined equality,
- a goal, and
- the list of outputs of that goal.
The idea is that this would be transformed into a conjunction of the first and
second items, and wrapped inside a special kind of conj that provides a scope
for the implicit promise, which is that the set of solutions of the goal in
the second item doesn't depend on what concrete terms the deconstructions
in the first item return out of the set of concrete terms they *could* return.
The deconstructions in the first item would be marked to tell determinism
analysis to effectively ignore the fact that they involve user-defined
equality.
The actual addition of that construct is left for a future change, after we
agree on the syntax.
compiler/hlds_goal.m:
Generalize the existing promise_equivalent_solutions scope to a
promise_solutions scope with a flag that says whether in the source
code it was originally the existing "promise_equivalent_solutions"
construct or the new construct (which doesn't exist yet, but is
indicated by the symbol "same_solutions" for now).
Replace the conj and par_conj hlds_goal_exprs with a single goal
expression: conj with an additional argument which is either plain_conj
or parallel_conj. This was part of an earlier design in which a third
kind of disjunction took the role now assigned to the new kind of
promise_solutions scope, but turned out to be a good idea anyway,
since in many places the compiler does treat the two kinds of
conjunctions the same. This part of the change is responsible for the
fact that this change results in a net *reduction* of about 40 lines.
Move the most frequently used kinds of goal expressions to the front
of the type declaration to allow the compiler to make better decisions
about tag allocation.
Add the goal marker we will add to the deconstructions in the first
item.
Replace the true_goal and fail_goal predicates with functions to make
them easier to use, and rename their variants that take a context
argument to avoid unnecessary ambiguity.
compiler/*.m:
Conform to the change in hlds_goal.m.
Misc changes to make code more robust, e.g. replacing semidet
predicates on goal expressions with functions returning bool.
Misc cleanups, e.g. removal of unnecessary module qualifications
that made lines too long, renaming predicates whose names include
"disj" if they are also used to process parallel conjunctions (since in
both parallel conjunctions and in disjunctions the goals are
independent), and turning semidet predicates that switch on goal
expressions into bool functions (to make similar changes more rebust
in the future).
Estimated hours taken: 5
Branches: main
Fix a bug reported by Greg Duck. The bug was that the compiler always generated
a global variable of type MR_Word for each mutable, but could then assign
variables of other types to and from this global. If this other type is
float, the assignments discard the fractional part. If this other type
is something else, the result can be even worse.
There are two ways to fix this discrepancy. One is to change the type of the
global, and the other is to change the type of the variables it is assigned
to and from. The former looks cleaner, but it would mean that every call
to the get predicate would require a boxing operation, and that can be
relatively slow, since (e.g. for floats) it may require allocating a heap cell.
This diff implements both solutions.
We use the second solution on the LLDS backend because of its better
performance. We have to use the first solution on the MLDS backend,
because on that backend the type of the mutable variable is reflected
in the signature of the getter and setter predicates (whereas on the
LLDS backend all arguments are always MR_Words).
compiler/options.m:
Add an internal-only option that controls whether we use the first
solution or the second.
compiler/handle_options.m:
Make the MLDS backend imply the first solution.
compiler/prog_data.m:
For each argument of a foreign_proc item, record whether we want to
keep it boxed in the foreign code.
Add a foreign_proc attribute that asks for every arg to be kept boxed.
We can attach this to the mutable implementation foreign_procs we write
out to .opt files. This attribute is deliberately undocumented since
users should never use it.
compiler/make_hlds_passes.m:
For each argument of the get and set foreign_procs we create for
mutables, record that we do want to keep it boxed.
Move the action of creating the foreign code for the mutable's
declaration and definition to the third pass, since during the second
pass we don't necessarily know yet what its foreign type is (we may not
have processed a foreign_type declaration affecting it). Move the code
for creating the foreign code here from prog_mutable, since it depends
on the HLDS (and prog_mutable.m is in the parse_tree package).
Hoist some error handling code to put it where it belongs,
and to avoid some errors being reported twice.
compiler/hlds_goal.m:
For each argument of a foreign_proc goal, record whether we want to
keep it boxed in the foreign code.
compiler/llds_out.m:
compiler/pragma_c_gen.m:
compiler/ml_code_gen.m:
compiler/ml_call_gen.m:
If a foreign_proc argument is noted as being kept boxed in the
foreign_proc code, then keep it that way.
compiler/prog_io_pragma.m:
Parse the new foreign_proc annotation.
compiler/simplify.m:
If a foreign_proc has the always_boxed annotation, attach this info
to each of its args. We do this here because simplify is guaranteed
to be executed before all the code that may inspect these arguments.
Since nothing ever deletes an always_boxed annotation of a foreign_proc
arg, the code that attaches the annotation is idempotent, so the fact
that the compiler executes simplify twice is not a problem.
compiler/*.m:
Minor changes to conform to the changes in data structures above.
compiler/prog_type.m:
Move a function definition from prog_mutable to prog_type, and
fix the lack of abstraction in its code.
compiler/prog_mutable.m:
Delete the code moved to make_hlds_passes.m and prog_type.m.
compiler/notes/compiler_design.html:
Make the documentation of prog_mutable.m easier to read in source.
tests/hard_coded/float_gv.{m,exp}:
An extended version of Greg's code as a new test case.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/hard_coded/sub-modules/non_word_mutable.{m,exp}:
tests/hard_coded/sub-modules/non_word_mutable.child.m:
A version of the float_gv test case in which the compiler-generated
get and set foreign_procs should end up in .opt files.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/Mercury_options:
Enable the new test case, and make it execute with intermodule
optimization.
tests/invalid/bad_mutable.err_exp:
Expect the new output (in which an error is reported just once,
not twice).
Estimated hours taken: 2
Branches: main
Remove support for the Aditi backend. It is a pain to have to update it every
time a data structure changes when we don't see any benefit from it, and its
presence makes compilation of the compiler directory take about 10% longer
(since the Aditi backend modules are roughly 10% of the code in the compiler
directory). Deleting the Aditi-specific data structures from the HLDS should
also speed up compilation a little bit.
I have spoken to Rao and he is fine with this step.
Aditi users, if there are any, can continue to use the Aditi support in
release 0.12.*. I also tagged the last version on the trunk to support aditi
with the name "last_aditi". The need for modifications in this Aditi support
is likely to be very rare to nonexistent, if the recent past is any guide:
the Aditi backend hasn't seen a nontrivial modification in a year or more.
This diff removes a net 31492 lines.
compiler/add_aditi.m:
compiler/aditi_backend.pp:
compiler/aditi_builtin_ops.m:
compiler/context.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/rl.m:
compiler/rl_analyse.m:
compiler/rl_block.m:
compiler/rl_block_opt.m:
compiler/rl_code.m:
compiler/rl_dump.m:
compiler/rl_exprn.m:
compiler/rl_file.pp:
compiler/rl_gen.m:
compiler/rl_info.m:
compiler/rl_key.m:
compiler/rl_liveness.m:
compiler/rl_loop.m:
compiler/rl_opt.m:
compiler/rl_out.pp:
compiler/rl_relops.m:
compiler/rl_sort.m:
compiler/rl_stream.m:
Remove these compiler modules, since they existed only to support the
Aditi backend.
compiler/hlds_goal.m:
Delete the Aditi-specific components of goals (e.g. the aditi-builtin
kind of generic calls and Aditi-evaluated lambdas).
compiler/hlds_pred.m:
Delete the Aditi-specific components of pred_infos.
compiler/prog_data.m:
Delete the Aditi-specific items.
compiler/passes_aux.m:
Don't worry about processing all procedures or just all non-Aditi
procedures.
compiler/add_clause.m:
Add a predicate from a deleted module that is now used only here.
compiler/*.m:
Conform to the data structure changes above.
compiler/notes/*.html:
Remove references to the Aditi backend.
tests/invalid/aditi.m:
tests/invalid/aditi_errors.err_exp:
tests/invalid/aditi_errors.m:
tests/invalid/aditi_private_builtin.m:
tests/invalid/aditi_state_errors.err_exp:
tests/invalid/aditi_state_errors.m:
tests/invalid/aditi_update_derived_relation.err_exp:
tests/invalid/aditi_update_derived_relation.m:
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_mode_errors.err_exp:
tests/invalid/aditi_update_mode_errors.m:
tests/valid/aditi.m:
tests/valid/aditi_calls_mercury.m:
tests/valid/aditi_error_bug.m:
tests/valid/aditi_error_bug2.m:
tests/valid/aditi_error_bug3.m:
tests/valid/aditi_private_builtin.m:
tests/valid/aditi_query.m:
tests/valid/aditi_update.m:
tests/valid/base_relation.m:
tests/valid/base_relation2.m:
tests/valid/ite_to_disj.m:
Remove these Aditi-specific tests.
tests/*/Mmakefile:
Remove the references to these Aditi-specific tests.
Estimated hours taken: 120
Branches: main
Implementation of the structure sharing analysis (part of the CTGC system).
compiler/ctgc.datastruct.m:
(new file) Manipulation of a datastruct (defined in prog_data.m)
compiler/ctgc.selector.m:
(new file) Manipulation of a selector (defined in prog_data.m)
compiler/ctgc.fixpoint_table.m:
(new file) Definition of a generic fixpoint table to be used by the
structure sharing analysis framework as well as the structure reuse
part.
compiler/ctgc.util.m:
(new file) General operations valid for both structure sharing
analysis as structure reuse analysis.
compiler/ctgc.m:
Included additional modules.
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/structure_sharing.m:
Structure sharing analysis and domain.
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
compiler/trans_opt.m:
Added structure_sharing pragma and ways to handle it.
compiler/handle_options.m:
- Structure sharing analysis implies transitive optimization.
- Added character "S" to be used to dump structure sharing related
information in the hlds_dump-files.
compiler/hlds_out.m:
Dump structure sharing information.
compiler/hlds_pred.m:
Store structure sharing information in proc_info.
compiler/mercury_compile.m:
Perform structure sharing when creating .opt, .trans-opt files, and
when compiling to c.
compiler/options.m:
New options: structure-sharing and structure-sharing-widening.
compiler/parse_tree.m:
compiler/prog_ctgc.m:
(new file) This module contains printing/parsing and renaming
routines for handling the public representation used for
structure sharing information.
compiler/prog_data.m:
Public representation for structure sharing information.
Estimated hours taken: 10
Branches: main
compiler/make.program_target.m:
Don't try to reanalyse suboptimal, non-local modules when using
`--intermodule-analysis'.
compiler/exception_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
When looking up an analysis result, if the result is from a non-local
module and is `suboptimal', just assume it is `optimal' since we can't
make requests to or reanalyse the non-local module anyway. On the
other hand, if we look up a result from a local module which doesn't
yet exist, record the default (suboptimal) result that we are using
into the module's analysis registry, so that when the module is
reanalysed, if the answer pattern changes we will know that it changed
and the modules which made use of the default result can be marked.
Estimated hours taken: 1
Branches: main
Address review comments from Zoltan.
compiler/goal_form.m:
Rename the predicate goal_cannot_loop_or_throw/6 to
goal_can_loop_or_throw/6 and similarly for related predicates.
Add types to represent whether goals loop or throw exceptions and use
these in place of booleans.
compiler/constraint.m:
compiler/goal_util.m:
compiler/simplify.m:
Conform to the above changes and rename some variables in or to
simplify the code.
Estimated hours taken: 3
Branches: main
Fix a bug in my recent change to use the intermodule-analysis framework that
broke mmc --make on hosts that compiled at -O3 or greater.
compiler/constraint.m:
Fix a typo. We should *not* be performing constraint propagation
on goals that may loop or throw an exception.
Estimated hours taken: 5
Branches: main
analysis/analysis.file.m:
analysis/analysis.m:
Add support for "extra info" sections in `.analysis' files. These are
intended to contain any data that may be necessary but wouldn't fit as
answer patterns.
compiler/modules.m:
Add `.imdg' and `.request' to the list of extensions treated specially
by `make_file_name', so `--intermodule-analysis' works with
`--use-grade-subdirs'.
Estimated hours taken: 2
Branches: main
Fix a problem introduced by my recent changes to simplify.m that broke the
nightly builds on those hosts that use `--intermodule-optimization'. When
compiling with `--intermodule-optimization --no-fully-strict' simplify now
realises that it can replace calls to `builtin.false/0' with `fail'. In the
process of doing so it was emitting warning about `false' never succeeding.
compiler/simplify.m:
Don't emit a warning when replacing calls to builtin.false/0 with
fail.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/builtin_false.m:
Test case for the above.
Estimated hours taken: 0.3
Branches: main
compiler/det_analysis.m:
Break up a predicate whose code used to be 441(!) lines long
into manageable pieces. There are no algorithmic changes.
Estimated hours taken: 1.5
Branches: main
Make trail usage optimization use information from the intermodule-analysis
framework.
Fix a bug with in trail usage analysis where polymorphism was not being
correctly resolved if results from the intermodule-analysis framework were
being used. Rather than trying to get rid of the conditional status once the
values of any type variables were known the analysis was just propagating the
conditional status up the call graph.
compiler/trailing_analysis.m:
When annotating goals with trail usage information make use of trail
analysis results provided by the intermodule-analysis framework (if
available).
Fix a bug in trail usage analysis with respect to the handling
of polymorphism.
Estimated hours taken: 10
Branches: main
Convert those optimization passes that make use of exception analysis
information to make use of the intermodule-analysis framework.
Make preparations to do the same thing for the termination analyses.
s/list(prog_var)/prog_vars/
s/list(hlds_goal)/hlds_goals/
Style cleanups and formatting fixes for these modules as necessary.
compiler/exception_analysis.m:
Export a predicate that allows optimizations to access exception
analysis results without worrying about where they are stored. When
using intermodule-analysis information about imported procedures is
stored in the analysis registry, not in the exception_info table; with
intermodule-optimization information about imported procedures is
stored in the exception_info table.
compiler/goal_form.m:
Add a version of goal_cannot_throw that uses information from the
intermodule-analysis framework.
Mention that the existing versions of this predicate are deprecated
and will eventually be deleted.
compiler/goal_util.m:
Provide alternative versions of the predicates can_reorder_goals and
reordering_maintains_termination that can use information from the
intermodule-analysis framework. We will eventually use these versions
exclusively.
compiler/simplify.m:
compiler/constraint.m:
Use information from the intermodule-analysis framework when
performing these optimizations.
compiler/accumulator.m:
Mention that this module needs to be updated to use the
intermodule-analysis framework. (I'll do this as separate change
since it's probably going to require a fairly major rewrite of this
module to do this.)
compiler/deforest.m:
compiler/pd_util.m:
compiler/size_prof.m:
Conform to the above changes.
Estimated hours taken: 1
Branches: main
Fix a problem with unused argument analysis and intermodule-analysis.
compiler/unused_args.m:
Do not write unused argument info. for unification and comparison
predicates to the analysis registry.
With intermodule-optimization there were some limitations on what
could appear in the .opt files - this may not be the case with
.analysis files. Add an XXX comment about this.
Remove some (now redundant) support for `:` as a module qualifier.
Fix some overlong lines.
Estimated hours taken: 0.5
Branches: main
Emit an error message if `--intermod-opt' and `--intermodule-analysis' are
both enabled since they are not compatible with each other.
Emit an error message with `--make' and `--trans-intermod-opt' are enabled
together. We don't support transitive-intermodule optimization with `mmc
--make' but enabling both options together causes problems for termination
analysis (it expects that at least one more recompile is going to be performed
but it never is).
compiler/handle_options.m:
Emit an error message if `--intermod-opt' and `--intermodule-analysis'
are both specified.
Emit an error message if `--make' and `--trans-intermod-opt' are both
specified.
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/options.m
Remove some preliminary support for transitive-intermodule
optimization. We aren't going to implement it for mmc --make.
Update the TODO list.
Fix some formatting.
Estimated hours taken: 25
Branches: main
This patch improves the handling of libraries with the intermodule
analysis framework. `.analysis' files can now be installed into library
directories and used when analysing local modules.
analysis/analysis.m:
analysis/analysis.file.m:
compiler/mmc_analysis.m:
Separate the `module_id_to_file_name' method of the `compiler'
typeclass into `module_id_to_read_file_name' and
`module_id_to_write_file_name'. Add `module_is_local' method.
Change the calls to `module_id_to_file_name' appropriately for the
context. This allows us to find the `.analysis' files of library
modules.
Only write results, IMDG and request files for local modules.
Force `.analysis' files of the currently-analysed module to be written
out, even if it would be empty. This avoids us trying to reanalyse the
module later.
compiler/options.m:
Add internal compiler option `--local-module-id'.
compiler/make.dependencies.m:
Add `make_local_module_id_options' to build a list of
`--local-module-id' options.
compiler/make.module_target.m:
Add predicate `make_module_target_extra_options' so we can pass the
`--local-module-id' options.
compiler/make.program_target.m:
Analyse modules in bottom up order, according to the module dependency
graph. The current analyses don't support non-default call patterns,
so this should reduce the number of analysis passes to get (close to)
to a fixpoint.
Pass `--local-module-id' options when building analysis files, so the
analysis framework knows which modules are local.
Install `.analysis' files when installing libraries.
compiler/modules.m:
Make `.analysis', `.analysis_date', `.imdg' and `.request' files
architecture- or grade-specified so they go into grade directories
when `--use-grade-subdirs' is used.
Search for `.analysis' files in the same directories as `.opt' and
`.trans_opt' files.
Export predicate `add_module_relations' to help build module dependency
graphs.
compiler/mercury_compile.m:
Fix a bug where the unused argument optimisation pass was always being
run if `--intermodule-analysis' was enabled.
Estimated hours taken: 2
Branches: main
`mmc --make --use-grade-subdirs <linked-target>' makes symlinks/copies of the
linked target into the current directory, but doesn't do so if the linked
target is already up to date. This patch makes it always make the
symlink/copy, so that it is easy to switch between two or more grades even if
no source files were modified.
compiler/compile_target_code.m:
Separate out the code to make symlinks/copies of linked targets from
the `link' predicate into a predicate `post_link_make_symlink_or_copy'.
Move `shared_libraries_supported' from make.program_target.m into
compile_target_code.m.
compiler/make.program_target.m:
Call `post_link_make_symlink_or_copy' if `--use-grade-subdirs' is
enabled, and the linked target is otherwise up-to-date.
Write out a message in `--verbose-make' mode.
Conform to the move of `shared_libraries_supported'.
compiler/make.util.m:
Add a predicate `maybe_symlink_or_copy_linked_target_message'.
Estimated hours taken: 1
Branches: main
compiler/mercury_to_mercury.m:
Fix a bug where class constraints on functions were being written out
before the determinism annotation in interface files.
tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/func_class.m:
Add a test case.
Estimated hours taken: 5
Branches: main
Isolate the nondeterminism in constraint based mode ordering so
that when the analysis of a single predicate fails it is dealt
with straight away (by storing a simple record of the failure,
to be used for error messages).
Further work towards constraint based mode inference.
compiler/abstract_mode_constraints.m:
compiler/build_mode_constraints.m:
Store PredIds for called predicates that require mode
inference with the constraints for the predicate calls.
compiler/mode_constraints.m:
Minor changes to conform with the above.
compiler/ordering_mode_constraints.m:
Conform to the above changes.
Add a data structure to record reasons for mode analysis
failures. Include printing of that structure where failure
occurs.
s/PredID/PredId/
Estimated hours taken: 4
Branches: main
Fix a bug with mmc --make and shared libraries on Darwin. The problem was
that the install_name for the library was being incorrectly set.
compiler/modules.m:
Set the value of the install-name path correctly. If the user doesn't
specify a value then generate one based on the current value of
INSTALL_PREFIX.
compiler/options.m:
Delete the bogus default value for the shlib-linker-install-name-path
option.
compiler/compile_target_code.m:
When linking a shared library on Darwin set the install-name path
correctly, in particular we need to set it to the directory we
are going to install the library in, *not* where the library is
being built.
compiler/make.program_target.m:
Mention that any changes to modules.get_install_name_option need to
be reflected here.
Estimated hours taken: 0.5
Branches: main
Add an option to inhibit warnings about unifications that cannot succeed.
Such code is sometimes useful, for example if you have debugging code that
is normally meant to be compiled away.
compiler/options.m:
Add and document the option.
compiler/modecheck_unify.m:
Check the option before outputting the warning.
Estimated hours taken: 3
Branches: main
Fix some problems with `mmc --make' on Windows (or possibly any platform
without symbolic links).
compiler/make.program_target.m:
Don't try to install `.mh' files into `inc/Mercury/mhs' as this is
(seems) unnecessary.
Make the symlinks or directories `ints/mhs' and `ints/mihs' when
installing libraries.
Correct a typo which created the directories
`lib/<grade>/inc/Mercury/mih' instead of
`lib/<grade>/inc/Mercury/mihs'.
compiler/modules.m:
Make `copy_file' first attempt to use the `--install-command' command,
in order to preserve more information about the file. In particular,
with `--use-grade-subdirs' we want executables copied from the grade
subdirectories to keep the executable bit.
Estimated hours taken: 20
Branches: main
This patch mainly adds the ability to perform intermodule analysis of modules
as a separate step from code generation. It makes a start on automatic
reanalysis of modules if their .analysis files become invalid or suboptimal.
analysis/analysis.file.m:
analysis/analysis.m:
Add a predicate `read_module_overall_status' to read just the overall
status of an analysis file.
Fix a bug where analysis results were being discarded (upon reading) if
the module's overall status was `invalid'. We can't do that as then we
wouldn't know which results changed after reanalysis.
Touch a `FOO.analysis_date' file after module `FOO' is analysed.
This is needed to indicate the time at which `FOO' was last analysed,
as `FOO.analysis' can be modified at other times.
Add a mutable boolean variable `debug_analysis' that can be set
to enable debugging messages for the analysis framework.
compiler/handle_options.m:
compiler/options.m:
Add new compiler options `--make-analysis-registry',
`--debug-intermodule-analysis' and `--analysis-repeat'.
compiler/make.dependencies.m:
Add `.analysis' files as dependencies of compiled code files if
`--intermodule-analysis' is used.
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Add a `FOO.analyse' pseudo-target to `mmc --make'. This produces all
the `.analysis' files needed to compile the top-level module `FOO',
reanalysing modules until none of the `.analysis' files are invalid.
The `--analysis-repeat' option can also be used to force
`suboptimal' modules to be reanalysed a number of times.
Perform an analysis pass when building executables or libraries to make
sure that compilation does not proceed with invalid analysis files.
Treat `.analysis' files specially when checking whether they are out of
date. Analysis files require looking at their contents to determine
whether they are invalid (in which case they are out of date), or valid
(in which case we look at the timestamp of the corresponding
`.analysis_date' file).
compiler/mercury_compile.m:
Make `.analysis' be written out only when `--make-analysis-registry'
is used, like `--make-transitive-optimization-interface'.
`mmc --make' runs the compiler the `--make-analysis-registry'
option as appropriate.
compiler/exception_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Only record intermodule dependencies and analysis results when
`--make-analysis-registry' is enabled, not when
`--intermodule-analysis' is enabled.
doc/user_guide.texi:
Document `--debug-intermodule-analysis' and `--analysis-repeat'.
Estimated hours taken: 1
Branches: main
Minor cleanups of Richard's recent update, basically review comments
I could address more easily myself.
compiler/abstract_mode_constraints.m:
compiler/build_mode_constraints.m:
compiler/mcsolver.m:
compiler/ordering_mode_constraints.m:
compiler/prop_mode_constraints.m:
Remove unnecessary module qualifications whose only effect was to
add clutter. When a piece of functionality was present in both
predicate and function forms, keep only the more convenient form.
Use multilevel switches on list lengths where relevant. Rename some
variables to conform with our conventions. Make comments into
complete sentences. Fix some white space issues.