compiler/try_expand.m:
As above.
tests/valid/try_inside_lambda.m:
A minimal version of Volker's test case, with English names.
tests/valid/Mmakefile:
Enable the new test case.
library/map.m:
library/tree234.m:
Add cc_multi versions of some of the higher-order predicates in these
modules.
Re-order of mode declarations where they are inconsistent with our usual
ordering.
NEWS.md:
Announce the above additions.
compiler/parse_goal.m:
As above.
tests/invalid/field_syntax_error.{m,err_exp}:
Extend this test case with a test of the new warning.
Document its old as well as its new parts.
compiler/options.m:
Merge the two options into one, which can be specified by either name.
compiler/module_qual.m:
Update their documentation.
compiler/module_qual.qualify_items.m:
Conform to the change above.
tests/warnings/help_text.err_exp:
Expect the merged option's documentation.
NEWS.md:
Announce the new option name.
RELEASE_NOTES_NEXT:
Schedule the old option name for deletion.
extras/base64/Mercury.options:
extras/fixed/Mercury.options:
extras/graphics/mercury_allegro/Mercury.options:
extras/graphics/mercury_cairo/Mercury.options:
extras/graphics/mercury_glfw/Mercury.options:
extras/graphics/mercury_glut/Mercury.options:
extras/graphics/mercury_glut/Mmakefile:
extras/graphics/mercury_glut/Mmakefile.MacOSX:
extras/graphics/mercury_opengl/Mercury.options:
extras/graphics/mercury_opengl/Mmakefile:
extras/graphics/mercury_opengl/Mmakefile.MacOSX:
extras/odbc/Mercury.options:
extras/odbc/Mmakefile:
extras/references/Mercury.options:
extras/solver_types/library/Mercury.options:
extras/solver_types/library/Mmakefile:
extras/trail/Mercury.options:
tests/submodules/Mercury.options:
tests/warnings/Mercury.options:
Replace all references to --warn-interface-imports with
--warn-unused-interface-imports, the new preferred name.
In several places, compiler options (both module-specific
and otherwise) were specified in Mmakefiles. Move them
to Mercury.options files. In some cases, this meant creating
new Mercury.options files.
Specifically, make it warn about interface imports that are not used
in the initial HLDS, even if they *are* used after the expansion of
type-, inst- and mode-equivalences.
compiler/hlds_module.m:
Add a slot to the HLDS to store the set of modules that are
imported in the interface but are unused there when the HLDS
is first constructed.
compiler/module_qual.qualify_items.m:
Compute this set, and return it to mercury_compile_make_hlds.m.
Make the code module qualifying aug_compilation_units warn about
unused interface imports only if unused_imports.m won't do the same later.
compiler/mercury_compile_make_hlds.m:
Pass the set to make_hlds_passes.m.
compiler/make_hlds_passes.m:
Store the set in the initial HLDS.
compiler/prog_data_used_modules.m:
Replace set_ordlists with set_tree234s.
compiler/unused_imports.m:
Consider an interface-imported module unused in the interface
if module_qual.qualify_items.m considered it unused, even if
changes made by equiv_type.m has added uses of it later.
compiler/handle_options.m:
Stop making --warn-unused-imports imply --no-warn-unused-interface-imports,
since new logic in module_qual.qualify_items.m makes this unnecessary.
compiler/make_module_file_names.m:
compiler/type_inst_mode_map.m:
compiler/write_deps_file.m:
Move imports from the interface section to the implementation section,
in response to the new, more thorough warnings.
compiler/frameopt.m:
The key decision in frame optimization is "which basic blocks need
a stack frame"?
One aspect of this decision is that if a block needs a frame,
then all successors of that block will get a frame. We therefore
unconditionally propagate the need for a frame forwards.
Another aspect is that if all the successors of a block need a frame,
then it is better for that block to allocate a frame than for
all its successors to do so, since this saves space, and does not
cost any time. We therefore *conditionally* propagate the need
for a frame backwards.
This diff speeds up conditional propagation to predecessors
by processing each predecessor just once, which reduces the
complexity of the algorithm from quadratic to linear. This speeds
up the compilation of options.m by about 13%.
This change can change the output slightly (because the result of the
"do all successors of this predicate need a frame" test can change
as the algorithm learns more about frames), but it seems that
in practice, this happens only very rarely, and even then
its impact on the performance of the generated code is negligible.
The code doing propagation to successors already had a mechanism
to handle each block just once. Speed up this mechanism also by
switching the "have we done this block already" test from using
plain sets (O(N) lookup) to using set_tree234s (O(log N) lookup).
Also improve some minor aspects of programming style.
compiler/var_locn.m:
Do not construct comments for instructions that we decide
not to generate.
Look up a variable in the var_table just once.
Reduce pressure on stack frame sizes by reducing the number
of live variables at some program points.
Use string.format where appropriate.
Use our standard programming style for setter predicates.
compiler/Mercury.options:
Inline getters and setters in var_locn.m.
This yields a speedup of about 2.4% when compiling options.m.
compiler/polymorphism_clause.m:
Don't count the variables in a var_table when we need only
an emptyness test.
library/tree234.m:
Make the code counting map elements partially tail recursive.
The code that checks whether a bound inst wrapped around
a list of bound_functors matched the ground inst did several things
in a suboptimal fashion.
- It looked up the definition of the type constructor of the relevant type
(the type of the variable the inst is for) more than once. (This was
not easily visible because the lookups were in different predicates.)
This diff factors these out, not for the immesurably small speedup,
but to make possible the fixes for the next two issues.
- To simplify the "is there a bound_functor for each constructor in the type"
check, it sorted the constructors of the type by name and arity. (Lists of
bound_functors are always sorted by name and arity.) Given that most
modules contain more than one bound inst for any given type constructor,
any sorting after the first was unnecessarily repeated work. This diff
therefore extends the representation of du types, which until now has
include only a list of the data constructors in the type definition
in definition order, with a list of those exact same data constructors
in name/arity order.
- Even if a list of bound_functors lists all the constructors of a type,
the bound inst containing them is not equivalent to ground if the inst
of some argument of some bound_inst is not equivalent to ground.
This means that we need to know the actual argument of each constructor.
The du type definition lists argument types that refer to the type
constructor's type parameters; we need the instances of these argument types
that apply to type of the variable at hand, which usually binds concrete
types to those type parameters.
We used to apply the type-parameter-to-actual-type substitution to
each argument of each data constructor in the type before we compared
the resulting filled-in data constructor descriptions against the list of
bound_functors. However, in cases where the comparison fails, the
substitution applications to arguments beyond the point of failure
are all wasted work. This diff therefore applies the substitution
only when its result is about to be needed.
This diff leads to a speedup of about 3.5% on tools/speedtest,
and about 38% (yes, more than a third) when compiling options.m.
compiler/hlds_data.m:
Add the new field to the representation of du types.
Add a utility predicate that helps construct that field, since it is
now needed by two modules (add_type.m and equiv_type_hlds.m).
Delete two functions that were used only by det_check_switch.m,
which this diff moves to that module (in modified form).
compiler/inst_match.m:
Implement the first and third changes listed above, and take advantage
of the second.
The old call to all_du_ctor_arg_types, which this diff replaces,
effectively lied about the list of constructors it returned,
by simply not returning any constructors containing existentially
quantified types, on the grounds that they "were not handled yet".
We now fail explicitly when we find any such constructors.
Perform the check for one-to-one match between bound_functors and
constructors with less argument passing.
compiler/det_check_switch.m:
Move the code deleted from hlds_data.m here, and simplify it,
taking advantage of the new field in du types.
compiler/Mercury.options:
Specify --optimize-constructor-last-call for det_check_switch.m
to optimize the updated moved code.
compiler/add_foreign_enum.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/code_info.m:
compiler/dead_proc_elim.m:
compiler/direct_arg_in_out.m:
compiler/du_type_layout.m:
compiler/equiv_type_hlds.m:
compiler/hlds_out_type_table.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/intermod_decide.m:
compiler/lookup_switch_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds.m:
compiler/post_term_analysis.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal_ite.m:
compiler/table_gen.m:
compiler/tag_switch_util.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck_coerce.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the changes above. This mostly means handling
the new field in du types (usually by ignoring it).
compiler/inst_match.m:
The data structure that we pass through most of the code of this module
can be set up to either gather and record substitions, or not.
After initialization with one of these choices, the choice stayed fixed,
with one exception, which turned on gathering substitions. However,
this exception had no effect other than generating a slow-down, because
every predicate that initialized this field to "don't gather substitions"
also ignored any substitions that this turning caused to be gathered.
This diff undoes that exception. It also changes every predicate
that this data structure passes through to have two modes,
one for each choice.
Replace a call to set.fold with a new predicate that does the same job,
but preserves the more-specific-than-ground insts. Do not call it
in cases where every iteration would be a noop.
This diff yields a speedup of about 0.6% on tools/speedtest, and
very roughly three times that when compiling options.m.
deep_profiler/var_use_analysis.m:
Pass never-varying and slower-varying input arguments first.
Consistently pass goal lists before the position of the first goal
in the overall list.
browser/declarative_analyser.m:
browser/declarative_edt.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_types.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/timeout.m:
deep_profiler/top_procs.m:
deep_profiler/util.m:
Minor improvements in programming style.
compiler/convert_parse_tree.m:
compiler/type_inst_mode_map.m:
As above.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add the new module to the parse_tree package, and document it.
compiler/comp_unit_interface.m:
compiler/recompilation.version.m:
Conform to the changes above.
compiler/print_help.m:
... that used to be required to help out switch detection.
configure.ac:
Require the installed compiler to have the commit that makes those
duplicate unifications unnecessary.
compiler/simplify_proc.m:
If a first attempt to analyse and optimize format calls fails
due to insufficient information about format strings and/or values,
then try the whole process again after pushing copies of the format calls,
and the conjuncts that precede them, into the last preceding branched
control structure (disjunction, switch, or if-then-else). This will
fix the problem if each branch does construct known format strings
and/or values, and is harmless if this is not the case.
tests/valid/format_after_switch.m:
A test case for the new capability.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
Enable the new test case.
compiler/error_spec.m:
Delete conditional_spec from the error_spec type, which had
exactly one use left in the compiler. Replace it with a conditional form
of severity_error, which handles that use case.
Rename error_severity to spec_severity, since obviously not all severities
represent errors.
For the same reason, rename error_phase to spec_phase.
compiler/error_util.m:
Export a predicate for write_error_spec.m.
compiler/write_error_spec.m:
Use that export to delete what used to be duplicate code.
compiler/add_pragma.m:
compiler/check_typeclass.m:
compiler/compiler_util.m:
compiler/error_sort.m:
compiler/mark_tail_calls.m:
compiler/parse_error.m:
compiler/parse_item.m:
Conform to the changes above.
compiler/switch_detection.m:
The existing switch detection algorithm does a single forward
traversal of the procedure body, doing only very limited lookahead.
This prevents it from recognizing some switches. To fix this, add
a new prepass that provides unlimited lookahead.
Add one use of this lookahead information. Later diffs should add
more uses.
compiler/print_help.m:
Fix the code that served as motivation for this change.
It was a block of unifications that was intended to supply
the lookahead that the old algorithm needed but did not have,
but it actually lied: it said that the the following disjunction
covered cons_ids that it actually did not cover. The fact that
the compiler did not diagnose this lie until now was a bug.
(After this diff, the compiler now reports an error.)
deep_profiler/message.m:
Avoid the limitation of the new algorithm that was discussed today
on m-dev.
compiler/options.m:
Add a way to test for the presence of this new capability
in the installed compiler.
tests/warnings/help_text.err_exp:
Expect the new option name.