mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 13:23:47 +00:00
b357a3dadcdf29c8d8ca184d65f7634a1a94de36
42 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b21e9e459a |
Delete all calls to get_progress_output_stream ...
... and almost all calls to get_error_output_stream. Replace them
with ProgressStreams and ErrorStreams passed down from higher in the
call tree.
Use ProgressStreams, not ErrorStreams, to write out error messages about
any failures of filesystem operations. These are not appropriate to put
into a module's .err file, since they are not about an error in the
Mercury code of the module.
compiler/globals.m:
Delete the predicates that return progress streams, and the mutable
behind them.
compiler/passes_aux.m:
Delete the predicates that return progress streams. Delete the
versions of the progress-message-writing predicates that didn't get
the progress stream from their caller.
compiler/*.m:
Pass around ProgressStreams and/or ErrorStreams explicitly,
as mentioned at the top of log message.
In a few places, don't write out error_specs to ErrorStream,
returning it to be printed by our caller, or its caller etc instead.
In some of those places, this allowed the deletion an existing
ErrorStream argument.
Given that get_{progress,error}_output_stream took a ModuleName input,
deleting some of the calls to those predicates left ModuleName unused.
Delete such unused ModuleNames.
In a few places, change argument orders to conform to our usual
programming style.
Fix too-long lines.
|
||
|
|
e1e5480f16 |
Eliminate calls to io.output_stream in read_modules.m.
compiler/read_modules.m:
When invoked to read a file specified by file name (as opposed to
by module name), the code of this module wrote out progress messages
to the current output stream, as returned by io.output_stream.
Fix this by consistently requiring the ancestors of the predicates involved
to pass an explicit stream to write progress messages to.
The interfaces of some of the exported predicates allowed their callers
to either pass a progress stream or not; if they didn't, this prevented
the generation of any progress messages with -v and the generation of
any statistics with -S. Most callers did specify the progress stream;
the main parts of the compiler that did not were
- the code that read the old versions of interface files in order to see
whether the new version was identical to it, or not, and
- the intermodule analysis framework.
This diff requires callers to always pass a progress stream, because
we *always* want to write out any error messages about nonexistent
or unreadable files, and we don't want to write these to an implicitly
specified file. We *could* add a parameter to the affected predicates
to shut up progress messages and statistics for use at the call sites
that previously passed us "no" as the maybe progress stream argument,
but I see no reason why one wouldn't want -v and -S to work as usual
in these above circumstances. If anyone ever finds such a reason,
there is a simpler fix anyway: turning off -v and -S in the globals
passed along next to the progress stream.
compiler/module_cmds.m:
Stop requiring an error stream and as well as a progress stream
when touching files. If the two streams were ever different, the
output would have looked strange, as the error message would NOT follow
the progress message announcing the operation that failed.
compiler/analysis.m:
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by passing along
an explicit progress stream.
|
||
|
|
691e5ca0c5 |
Group extensions by their translation algorithms.
compiler/file_names.m:
Replace the current groups of extensions, which are based on the
shared purpose of the files with those extensions, with a smaller
number of groups, which are based on the algorithm we use to decide
in what (sub)directories we want to place files with those extensions.
The old distinctions based on purpose still remain in the naming
convention for the enum values within each of the new groups.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
compiler/make.file_names.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above.
|
||
|
|
d302a4e5ca |
Give some predicates/constructors more meaningful names.
compiler/module_cmds.m:
Rename the update_interface_X predicates to copy_dot_tmp_to_base_file_X,
because
- this better describes what they do, and
- some of the files they are invoked on are *not* interface files.
Add an extra parameter to copy_dot_tmp_to_base_file_report_any_error
that specifies what kind of file is being copied, and print *that*
as part of any error message.
Do a similar rename of update_interface_result type, and of its
function symbols.
Give more meaningful names to touch_interface_datestamp and
touch_datestamp as well.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/intermod.m:
compiler/make.module_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mlds_to_c_file.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
17cbe6c928 |
Split two extension categories ...
compiler/file_names.m:
... which treated some extensions in the category differently than others.
This allows the code that converts each category's extensions to the
final filename to test nothing except the search/nosearch parameter
and the subdir options.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/write_deps_file.m:
Conform to the new designations of the extensions that
moved to a new category.
|
||
|
|
6517982c87 | s/newext/ext/g and s/NewExt/Ext/g. | ||
|
|
0b60f07c46 |
Cut over to the new code in file_names.m.
compiler/file_names.m:
Delete the old code for doing filename translations, and use
just the new code.
Delete all the code that was needed only for comparing the old and
new code.
Delete the newext_other extension category, since it was also needed
only for that purpose. Delete all the code that supported it.
Switch the infrastructure for recording the demand for translations
to work with the new code.
compiler/analysis.file.m:
Delete functions that returned old-style extensions, which are
not useful anymore. The new-style extensions, by identifying
extensions via enums rather than strings, serve the purpose
for which these functions were created.
compiler/mercury_compile_main.m:
Move the code to call to write out the translation record
from just after a call to real_main_after_expansion to the
end of real_main_after_expansion. The reason is that the
predicate being called now needs access to a globals structure,
real_main_after_expansion has access to a globals structure,
but its caller does not.
Don't try to test the equivalence of the old and new algorithms
for file name translation, since that test code has been deleted.
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes in file_names.m.
|
||
|
|
edeb58bc16 |
Start using the new code in file_names.m.
compiler/file_names.m:
Change the argument vectors of the predicates that compute filenames
by taking *two* arguments to specify the extension: adding an argument
value of the "newext" type right after the old "ext" type. To make this
possible, export the newext type.
By default, use the new argument to do every filename computation twice,
with the old and new algorithms, throwing an exception if their results
differ. (There is no easy way to test whether the "make-any-needed-dirs"
part was done the same way, but this is reasonably easy to check
visually in the code.)
In case an exception does get thrown, this can be suppressed (hopefully
after the exception being reported) by setting the environment variable
"NO_EXT_CHECKS" to any value.
Add representations of "get the value of this extension from this option"
style extensions to the newext type, for each of the options that the
compiler uses this way. The one exception is java_object_file_extension,
which was used in this way, but which had no code handling it in
file_names.m.
Add a representation of ".$(EXT_FOR_PIC_OBJECTS)" as a value
to the newext type.
Shorten some function symbol names in the newext type and its components,
to make them easier to fit without excessive line lengths in the modules
listed below.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Pass extensions as ext/newext pairs, not just as exts.
To make this possible, change functions and predicates that returned
just old-style extensions to return new-style extensions as well.
compiler/make.program_target.m:
Pass extensions as ext/newext pairs, not just as exts.
Add an XXX about java_object_file_extension for Julien, since he added
this option (in 2001 :-().
|
||
|
|
961577c7d0 | Fix indentation. | ||
|
|
cf66008788 |
Stop using exceptions in the analysis package.
compiler/analysis.m:
compiler/analysis.file.m:
Instead of throwing an exception when we find an unexpected version
number or an unrecognized item in a file, construct an error_spec
describing the problem, add it to the list, and continue processing,
if this is possible.
In some places, pass around the information needed for the construction
of meaningful error messages.
Note a limitation of the new approach to error handling (that it inherits
from the old approach).
Instead of reading in each item in analysis request/result files
separately, read in their whole files all at once, and just parse it
item by item.
Stop marking module_cmds as an unwanted dependency; it defines
undate_interface_return_changed, which is required for this module's job.
Give some predicates more meaningful names.
compiler/error_spec.m:
Fix some documentation rot.
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
Act on the error_specs that the analysis package can now return.
|
||
|
|
8eda3b065f | Replace more rafe-isms in analysis.m. | ||
|
|
1659e9e2cb |
Use explicit streams in analysis*.m.
compiler/analysis.m:
compiler/analysis.file.m:
Switch to using explicit streams.
Use io.format when relevant.
Give some fields, predicates and variables more meaningful names.
Replace some rafe-isms with code in our usual coding style.
Add XXXs for possible future improvements.
Replace the flag that says whether debug is enabled with a maybe
wrapped around the stream where debug output should go.
compiler/handle_options.m:
Initialize the maybe debug stream.
compiler/Mercury.options:
Stop disabling the warning for the use of implicit streams
for analysis.m and analysis.file.m.
|
||
|
|
07f877bc3f |
Carve term_context.m out of term.m.
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
|
||
|
|
ea4f95a7ed |
Use var_tables in lco.m, and when dumping goals.
Since this is the first converted module that dumps out goals when
debugging trace flags are enabled, this required generalizing the code
that does that, to take either varsets or var_tables as a means of
specifying the names of variables. We do this via a new type,
var_name_source, which contains either a varset or a var_table.
Almost all of this diff is there to implement this generalization.
A large part of it affects code in the parse_tree package that we use
to write out the parts of HLDS goals that are defined by types defined
in that package. Since we want to avoid making any part of the parse_tree
package dependent on the hlds package, this required defining the
var_name_source type in the parse_tree package, which in turn requires
var_table.m to be in that same package.
compiler/lco.m:
Convert this module to use var_tables instead of varsets and vartypes.
compiler/var_table.m:
Move this module from the hlds package to the parse_tree package.
To make this, possible, move the parts that required access to the HLDS
to hlds_pred.m, from where it was usually invoked.
Export some utility predicates to allow the moved code to work
in hlds_pred.m without access to the actual definition of the
var_table type.
Define the var_name_source type.
Add some utility functions for use by code writing out variable names.
compiler/hlds_pred.m:
Add the code moved from var_table.m.
compiler/vartypes.m:
Move this module from the hlds package to the parse_tree package,
for symmetry with var_table.m. It did not depend on being in hlds
in any way.
compiler/hlds.m:
compiler/parse_tree.m:
Move vartypes.m and var_table.m from the hlds package
to the parse_tree package.
compiler/hlds_out_goal.m:
Change all the predicates in this module to take a var_name_source
instead of a prog_varset.
Fix some comments.
compiler/hlds_out_util.m:
Change some of the predicates in this module (those called from
hlds_out_goal.m) to take a var_name_source instead of a prog_varset.
compiler/parse_tree_out_term.m:
Provide variants of some existing predicates and functions that take
var_name_sources instead of varsets. The code of the copies
duplicates the logic of the originals, though I hope that this
duplication can be done away with at the end of the transition.
(The best solution would be to use a typeclass with methods
that convert vars to their names, but we would want to ensure
that the compiler can specialize all the affected predicates
and functions to the two instances of this typeclass, which is
something that we cannot do yet. In the meantime, the lack of
any generalization in the old versions preserves their performance.)
tools/sort_imports:
tools/filter_sort_imports:
A new tool that automatically sorts any occurrences of consecutive
":- import_module" declarations in the named files. The sorting is done
in filter_sort_imports; sort_imports loops over the named files.
After automatically replacing all occurrences of hlds.{vartypes,var_table}
in import_module declarations with their parse_tree versions, the updated
import_module declarations were usually out of order with respect to
their neighbours. I used this script to fix that, and some earlier
out-of-order imports.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/analysis.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/check_promise.m:
compiler/closure_analysis.m:
compiler/closure_gen.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/file_names.m:
compiler/float_regs.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_code_util.m:
compiler/hlds_error_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_user.m:
compiler/instance_method_clauses.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/interval.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/lookup_switch.m:
compiler/loop_inv.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/make_goal.m:
compiler/make_hlds_separate_items.m:
compiler/make_hlds_types.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_unify_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_global.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_stmt.m:
compiler/mlds_to_java_type.m:
compiler/mmc_analysis.m:
compiler/mode_comparison.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/options_file.m:
compiler/ordering_mode_constraints.m:
compiler/par_loop_control.m:
compiler/parse_item.m:
compiler/parse_string_format.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_to_term.m:
compiler/parse_util.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_lambda.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_resurrection_renaming.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/recompute_instmap_deltas.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/smm_common.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/var_locn.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
e657a091e4 |
Encode the arity kind in the type in pred lookups.
compiler/pred_table.m:
Some predicates in this module have traditionally taken an arity argument
that *included* function result arguments, while others took an arity
arguments that *excluded* function result arguments. While the difference
was documented, it was not enforced in the types. Change this by
switching the two kinds of arities to pred_form_arities and user_arities
respectively.
Change the internal data structures to specify in the types
that they operate on user_arities.
Change the operation of lookup_builtin_pred_proc_id as part of the
change to goal_util.m (described below).
compiler/goal_util.m:
When looking up the pred_info of a builtin, callers used to pass to the
predicates that did that (generate_simple_call and generate_foreign_proc)
a list of the arguments of the call without specifying which arguments
were type_info/typeclass_info arguments added by polymorphism.
This meant that the length of the argument list was *not* necessarily
the called predicate or function's pred form arity, but could exceed it
by the number of arguments added by polymorphism. The only reason this
worked was because the lookup_builtin_pred_proc_id procedure they used
to look up the named predicate in the pred table compensated for it
- by doing a lookup on the original arity plus one, if the lookup on the
original arity failed, and
- in all the calls to generate_simple_call and generate_foreign_proc,
the number of arguments added by polymorphism was either zero or one.
Nevertheless, the system was fragile. It could have broken either
- because when looking up the arity that included a type_info argument,
(e.g. one typeinfo and two original args) the lookup could have found
a false match (a predicate with the same name with three original args),
- or because a new call to a new builtin could need to specify two or more
arguments added by polymorphism.
Fix this issue by
- requiring calls to generate_simple_call and generate_foreign_proc
to pass the arguments added by polymorphism separately, so the number
of the original arguments specifies the predicate's pred_form_arity, and
- deleting the code in lookup_builtin_pred_proc_id that tried to
compensate for the presence of an "unannounced" typeinfo argument.
compiler/analysis.m:
Change the type of a slot in a structure from arity to pred_form_arity,
since that seems to have been how that slot was used.
compiler/recompilation.check.m:
compiler/recompilation.m:
compiler/recompilation.usage.m:
Conform to the changes above, but only in a minimal fashion,
because I don't *know* whether the values of type 'arity' passed around
in the recompilation modules represent user arities or pred form arities.
Record my guesses, but also record the fact that they are *only* guesses.
Mark suspect code with "XXX ARITY BUG".
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/stm_expand.m:
compiler/table_gen.m:
Conform to the changes above.
Rationalize the argument order of the internal module-specific predicates
they use to generate calls to builtins.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/analysis.file.m:
compiler/check_typeclass.m:
compiler/complexity.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/dep_par_conj.m:
compiler/direct_arg_in_out.m:
compiler/distance_granularity.m:
compiler/format_call.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/lco.m:
compiler/make_hlds_passes.m:
compiler/mmc_analysis.m:
compiler/modecheck_goal.m:
compiler/par_loop_control.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/pred_table.m:
compiler/purity.m:
compiler/rbmm.region_transformation.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_unify.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/ssdebug.m:
compiler/try_expand.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes above.
|
||
|
|
703f52fd7a |
Stop using exit status to report success/failure.
compiler/make.module_dep_file.m:
Judge whether calls to write_short_interface_file_int3 succeeded
by an explicit maybe_succeeded value they now return, instead of
checking the exit status in the I/O state.
compiler/module_cmds.m:
compiler/parse_tree_out.m:
compiler/write_module_interface_files.m:
Make operations on files return a maybe_succeeded argument to indicate
success vs failure.
compiler/make.module_target.m:
compiler/mlds_to_c_file.m:
Take the new maybe_succeeded arguments in calls into account
when computing whether an action succeeded.
compiler/analysis.m:
compiler/export.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/recompilation.check.m:
Ignore the maybe_succeeded results returned by calls, for now.
In export.m, switch from /* */ to // syntax for the C comments we write.
|
||
|
|
93c306916a |
Specify streams explicitly in more modules.
compiler/module_cmds.m:
Require all callers to specify output streams explicitly.
compiler/compile_target_code.m:
Require callers to specify output streams explicitly in most cases.
In the remaining cases, add "XXX STREAM" comments to request that
the explicit streams be passed later.
Add XXXs where preserving old behavior results in wrong-looking code.
Modify the signature of compile_java_files to encode the invariant that
the list of Java files given to it may not be empty.
compiler/error_util.m:
Provide a version of an error predicate that takes explicit streams.
compiler/make.build.m:
Mark predicates that help redirect implicit streams as predicates
that should not be used.
compiler/make.module_target.m:
compiler/make.program_target.m:
Add "XXX STREAM" comments to request that the explicit streams
be passed later.
compiler/module_qual.m:
Provide a means to construct the debug output stream.
compiler/module_qual.collect_mq_info.m:
Use the debug output stream where relevant.
compiler/analysis.m:
compiler/export.m:
compiler/recompilation.check.m:
compiler/source_file_map.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above, mostly by passing explicit streams.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for the above modules
(those that had it specified in the first place).
Delete a long-unneeded workaround.
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
Specify progress and output streams explicitly when calling the modules
above (not in other places, just yet).
|
||
|
|
6223e79ee1 | Make pred defn order match decl order. | ||
|
|
c2f92d5454 |
Partition extensions into ".m" and "all others".
This is a first step towards a much finer grained partition.
compiler/file_names.m:
Split the ext type into ext_src and ext_other, as mentioned above.
Add the first predicate for checking whether a string falls into
a given category of extensions.
Add an XXX proposing a better solution for an old problem that does not
actually arise in practice.
compiler/compile_target_code.m:
Split the two-moded predicate maybe_pic_object_file_extension into
two separate one-mode predicates, one for each old mode. The
implementations of the two modes were already separate, because
the two modes already did different jobs: while one went from PIC
to an "extension", the other went from an "extension string" to PIC.
Until now, "extension" and "extension string" were equivalent;
after this diff, they aren't anymore.
Delete an unused argument.
compiler/make.util.m:
Split the two-moded predicate target_extension into
two separate one-mode predicates, one for each old mode,
for the same reason as maybe_pic_object_file_extension above:
the fact that "extension" and "extension string" are now distinct.
compiler/options_file.m:
Move debug infrastructure here from mercury_compile_main.m, to help
debug possible problems with options files. (I had such a problem
while writing this diff.)
Improve how progress messages are printed.
compiler/options.m:
Make an error message more useful.
compiler/mercury_compile_main.m:
Add infrastructure for debugging possible problems with command lines.
(I had such a problem while writing this diff.)
compiler/analysis.m:
Conform to the changes above. Put the arguments of some methods
into the same order as similar predicates in file_names.m.
compiler/find_module.m:
Conform to the changes above. Delete an unused argument,
compiler/analysis.file.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.deps_set.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
|
||
|
|
52c0919975 |
Make filename extensions a separate type, ...
... to allow later changes to its definition.
compiler/file_names.m:
We used to represent filename extensions simply as strings. This meant
all calls to the predicates in file_names.m that convert module names
to file names with various suffixes had to go through a complicated
sequence of tests that effectively partition the extensions into
several classes, with all extensions in a class being treated the same
but different classes being treated differently. And since this general
translation process is quite convoluted (which is not helped by it
being spread across several predicates), it is very hard to construct
a correctness argument for it.
It would be better to represent the different classes of extensions
explicitly, in a du type, with each function symbol of that type
representing all the extensions in the corresponding class (in the sense
of the paragraph above). However, getting there in one diff would make
that diff far too hard to test and to review. So this first diff
starts by simply making extension a notag type.
The above is the first step in implementing one old XXX. This diff
fully implements another old XXX, which is to make the argument order
of several predicates friendly to higher order code.
Add infrastructure for profiling how often this code makes directories.
Delete an unused type.
Add comments outlining proposed future improvements.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/module_imports.m:
compiler/parse_tree_out.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the change to file_names.m.
Consistently use "Ext" for the abstract representation of extensions
and "ExtStr" for their string representation.
In a few places, add "XXX EXT" where the code manipulates extensions
as strings in a way that potentially inferferes with the partition
of extensions into classes.
In a few places, rename predicates to avoid ambiguities. factor out
common code, delete unneeded arguments, replace bools with bespoke types,
and make similar minor improvements.
In a few places, remove rafe-isms, such as the use ^elem.
|
||
|
|
2c68193c08 |
Mark some redundant library predicates obsolete.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Mark empty/1 and non_empty/1 as obsolete with is_empty and is_non_empty
as suggested replacements, and mark set/1 as obsolete with list_to_set/1
as suggested replacement.
NEWS:
Mention the above changes.
configure.ac:
Require the installed compiler to handle suggested replacements
in obsolete pragmas.
compiler/analysis.m:
Avoid calling the newly obsolete predicates.
Remove a workaround that probably hasn't been needed in a long time.
compiler/error_util.m:
compiler/hlds_args.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/options.m:
compiler/ordering_mode_constraints.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/prog_ctgc.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_region_analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_util.m:
compiler/tupling.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_annotate.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Avoid calling the newly obsolete predicates.
|
||
|
|
c1bdd2100b | Delete unneeded $module args from aborts. | ||
|
|
f1906ece65 | Fix some too-long lines. | ||
|
|
7f2d21f219 |
Make the analysis typeclass a bit more general.
compiler/analysis.m:
Give the analysis typeclass the ability for a compiler to report
which analyses it can do, and turn a semidet function into a semidet
predicate.
compiler/analysis.file.m:
compiler/mmc_analysis.m:
Conform to the above.
|
||
|
|
1da267e9f0 |
Fix a bug in handling instances with --warn-unused-imports.
This fixes Mantis bug #412. compiler/unused_imports.m: Consider that an instance declaration makes a module "used" only if it occurs in the module being compiled, not in an imported or ancestor module. (Mantis bug 412 was caused by instance declarations in implicitly imported modules.) Fixing #412 also exposed another bug. When computing the set of modules used by predicates, we considered (besides some non-type entities) only the types of the predicate's arguments, not the types of non-argument variables. In one case in the compiler (mmc_analysis.m), this lead to some actually-used modules not being marked as such, which lead to false unused-import warnings to be generated for them. Fix this by scanning the types of all variables in all of a predicate's procedures, not just the arguments. Improve the infrastructure for debugging similar problems. Note some possibilities for future improvement. Change a predicate name to fit the naming scheme. compiler/analysis.m: Add an XXX about a possible improvement. compiler/hlds_out_module.m: Make the output we generate for instance methods more readable. As part of this, fix an old bug in the printing of the instance table: the first line of the first method of each concrete instance declaration was accidentally commented out. compiler/parse_tree_out.m: Export a different utility predicate for hlds_out_module.m. Make its name conform to the scheme used by related predicates. browser/browse.m: compiler/add_mutable_aux_preds.m: compiler/add_pred.m: compiler/add_special_pred.m: compiler/check_for_missing_type_defns.m: compiler/check_promise.m: compiler/exception_analysis.m: compiler/handle_options.m: compiler/inst_match.m: compiler/mercury_to_mercury.m: compiler/ml_tailcall.m: compiler/module_qual.m: compiler/op_mode.m: compiler/parse_inst_mode_defn.m: compiler/parse_tree_out_clause.m: compiler/parse_tree_out_info.m: compiler/parse_tree_out_inst.m: compiler/parse_tree_out_pragma.m: compiler/parse_tree_out_pred_decl.m: compiler/parse_tree_out_term.m: compiler/parse_type_defn.m: compiler/parse_type_name.m: compiler/parse_util.m: compiler/parse_vars.m: compiler/prog_ctgc.m: compiler/recompilation.usage.m: compiler/resolve_unify_functor.m: compiler/term_constr_main.m: compiler/term_constr_main_types.m: compiler/write_deps_file.m: library/bt_array.m: Delete unused imports. compiler/module_qual.qual_errors.m: Import a module that the parent module_qual.m doesn't import anymore. tests/warnings/bug412.{m,exp}: The test case for this bug. tests/warnings/Mmakefile: tests/warnings/Mercury.options: Enable the new test case. tests/invalid/import_in_parent.err_exp: Update the expected output for this test case. The parent module does not use the imported module (bool) at all, so this is what the error message says after this diff, though its submodule does use bool. |
||
|
|
0e31c22bee | Convert (C->T;E) to (if C then T else E). | ||
|
|
62ec97d443 |
Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
|
||
|
|
500948d549 |
Break up mdbcomp/prim_data.m. The new modules have much better cohesion.
mdbcomp/sym_name.m:
New module, containing the part of the old prim_data.m that
dealt with sym_names.
mdbcomp/builtin_modules.m:
New module, containing the part of the old prim_data.m that
dealt with builtin modules.
mdbcomp/prim_data.m:
Remove the things that are now in the two new modules.
mdbcomp/mdbcomp.m:
deep_proiler/Mmakefile:
slice/Mmakefile:
Add the two new modules.
browser/*.m:
compiler/*.m:
deep_proiler/*.m:
mdbcomp/*.m:
slice/*.m:
Conform to the above changes.
|
||
|
|
16bd4acd2f |
Shorten lines longer than 79 characters.
Estimated hours taken: 2 Branches: main compiler/*.m: Shorten lines longer than 79 characters. |
||
|
|
295415090e |
Convert almost all remaining modules in the compiler to use
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all remaining modules in the compiler to use "$module, $pred" instead of "this_file" in error messages. In a few cases, the old error message was misleading, since it contained an incorrect, out-of-date or cut-and-pasted predicate name. tests/invalid/unresolved_overloading.err_exp: Update an expected output containing an updated error message. |
||
|
|
9f68c330f0 |
Change the argument order of many of the predicates in the map, bimap, and
Branches: main
Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.
Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.
library/bimap.m:
library/map.m:
library/multi_map.m:
As above.
NEWS:
Announce the change.
Separate out the "highlights" from the "detailed listing" for
the post-11.01 NEWS.
Reorganise the announcement of the Unicode support.
benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
Conform to the above change.
Remove any dependencies on the sv{bimap,map,multi_map} modules.
|
||
|
|
8a28e40c9b |
Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2 Branches: main Add the predicates sorry, unexpected and expect to library/error.m. compiler/compiler_util.m: library/error.m: Move the predicates sorry, unexpected and expect from compiler_util to error. Put the predicates in error.m into the same order as their declarations. compiler/*.m: Change imports as needed. compiler/lp.m: compiler/lp_rational.m: Change imports as needed, and some minor cleanups. deep_profiler/*.m: Switch to using the new library predicates, instead of calling error directly. Some other minor cleanups. NEWS: Mention the new predicates in the standard library. |
||
|
|
4ebe3d0d7e |
Stop storing globals in the I/O state, and divide mercury_compile.m
Estimated hours taken: 60 Branches: main Stop storing globals in the I/O state, and divide mercury_compile.m into smaller, more cohesive modules. (This diff started out as doing only the latter, but it became clear that this was effectively impossible without the former, and the former ended up accounting for the bulk of the changes.) Taking the globals out of the I/O state required figuring out how globals data flowed between pieces of code that were often widely separated. Such flows were invisible when globals could be hidden in the I/O state, but now they are visible, because the affected code now passes around globals structures explicitly. In some cases, the old flow looked buggy, as when one job invoked by mmc --make could affect the globals value of its parent or the globals value passed to the next job. I tried to fix such problems when I saw them. I am not 100% sure I succeeded in every case (I may have replaced old bugs with new ones), but at least now the flow is out in the open, and any bugs should be much easier to track down and fix. In most cases, changes the globals after the initial setup are intended to be in effect only during the invocation of a few calls. This used to be done by remembering the initial values of the to-be-changed options, changing their values in the globals in the I/O state, making the calls, and restoring the old values of the options. We now simply create a new version of the globals structure, pass it to the calls to be affected, and then discard it. In two cases, when discovering reasons why (1) smart recompilation should not be done or (2) item version numbers should not be generated, the record of the discovery needs to survive this discarding. This is why in those cases, we record the discovery by setting a mutable attached to the I/O state. We use pure code (with I/O states) both to read and to write the mutables, so this is no worse semantically than storing the information in the globals structure inside the I/O state. (Also, we were already using such a mutable for recording whether -E could add more information.) In many modules, the globals information had to be threaded through several predicates in the module. In some places, this was made more difficult by predicates being defined by many clauses. In those cases, this diff converts those predicates to using explicit disjunctions. compiler/globals.m: Stop storing the globals structure in the I/O state, and remove the predicates that accessed it there. Move a mutable and its access predicate here from handle_options.m, since here is when the mutables treated the same way are. In a couple of cases, the value of an option is available in a mutable for speed of access from inside performance-critical code. Set the values of those mutables from the option when the processing of option values is finished, not when it is starting, since otherwise the copies of each option could end up inconsistent. Validate the reuse strategy option here, since doing it during ctgc analysis (a) is too late, and (b) would require an update to the globals to be done at an otherwise inconvenient place in the code. Put the reuse strategy into the globals structure. Two fields in the globals structure were unused. One (have_printed_usage) was made redundant when the one predicate that used it itself became unused; the other (source_file_map) was effectively replaced by a mutable some time ago. Delete these fields from the globals. Give the fields of the globals structure a distinguishing prefix. Put the type declarations, predicate declarations and predicate definitions in a consistent order. compiler/source_file_map.m: Record this module's results only in the mutable (it serves as a cache), not in globals structure. Use explicitly passed globals structure for other purposes. compiler/handle_options.m: Rename handle_options as handle_given_options, since it does not process THE options to the program, but the options it is given, and even during the processing of a single module, it can be invoked up the three times in a row, each time being given different options. (It was up to four times in a row before this diff.) Make handle_given_options explicitly return the globals structure it creates. Since it does not take an old global structure as input and globals are not stored in the I/O state, it is now clear that the globals structure it returns is affected only by the default values of the options and the options it processes. Before this diff, in the presence of errors in the options, handle_options *could* return (implicitly, in the I/O state) the globals structure that happened to be in the I/O state when it was invoked. Provide a separate predicate for generating a dummy globals based only on the default values of options. This allows by mercury_compile.m to stop abusing a more general-purpose predicate from handle_options.m, which we no longer export. Remove the mutable and access predicate moved to globals.m. compiler/options.m: Document the fact that two options, smart_recompilation and generate_item_version_numbers, should not be used without seeing whether the functionalities they call for have been disabled. compiler/mercury_compile_front_end.m: compiler/mercury_compile_middle_passes.m: compiler/mercury_compile_llds_back_end.m: compiler/mercury_compile_mlds_back_end.m: compiler/mercury_compile_erl_back_end.m: New modules carved out of the old mercury_compile.m. They each cover exactly the areas suggested by their names. Each of the modules is more cohesive than the old mercury_compile.m. Their code is also arranged in a more logical order, with predicates representing compiler passes being defined in the order of their invocation. Some of these modules export predicates for use by their siblings, showing the dependencies between the groups of passes. compiler/top_level.m: compiler/notes/compiler_design.html: Add the new modules. compiler/mark_static_terms.m: Move this module from the ml_backend package to the hlds package, since (a) it does not depend on the MLDS in any way, and (b) it is also needed by a compiler pass (loop invariants) in the middle passes. compiler/hlds.m: compiler/ml_backend.m: compiler/notes/compiler_design.html: Reflect mark_static_terms.m's change of package. compiler/passes_aux.m: Move the predicates for dumping out the hLDS here from mercury_compile.m, since the new modules also need them. Look up globals in the HLDS, not the I/O state. compiler/hlds_module.m: Store the prefix (common part) of HLDS dump file names in the HLDS itself, so that the code moved to passes_aux.m can figure out the file name for a HLDS dump without doing system calls. Give the field names of some structures prefixes to avoid ambiguity. compiler/mercury_compile.m: Remove the code moved to the other modules. This module now looks after only option handling (such as deciding whether to generate .int3 files, .int files, .opt files etc), and the compilation passes up to and including the creation of the first version of the HLDS. Everything after that is subcontracted to the new modules. Simplify and make explicit the flow of globals information. When invoking predicates that could disable smart recompilation, check whether they have done so, and if yes, update the globals accordingly. When compiling via gcc, we need to link into the executable the object files of any separate C files we generate for C code foreign_procs, which we cannot translate into gcc's internal structures without becoming a C compiler as well as a Mercury compiler. Instead of adding such files to the accumulating option for extra object files in the globals structure, we return their names using the already existing mechanism we have always used to link the object files of fact tables into the executable. Give several predicates more descriptive names. Put predicates in a more logical order. compiler/make.m: compiler/make.dependencies.m: compiler/make.module_target.m: compiler/make.module_dep_file.m: compiler/make.program_target.m: compiler/make.util.m: Require callers to supply globals structures explicitly, not via the I/O state. Afterward pass them around explicitly, passing modified versions to mercury_compile.m when invoking it with module- and/or task-specific options. Due the extensive use of partial application for higher order code in these modules, passing around the globals structures explicitly is quite tricky here. There may be cases where a predicate uses an old globals structure it got from a closure instead of the updated module- and/or task-specific globals it should be using, or vice versa. However, it is just as likely that, this diff fixes old problems by preventing the implicit flow of updated-only-for-one-invocation globals structures back to the original invoking context. Although I have tried to be careful about this, it is also possible that in some places, the code is using an updated-for-an-invocation globals structure in some but not all of the places where it SHOULD be used. compiler/c_util.m: compiler/compile_target_code.m: compiler/compiler_util.m: compiler/error_util.m: compiler/file_names.m: compiler/file_util.m: compiler/ilasm.m: compiler/ml_optimize.m: compiler/mlds_to_managed.m: compiler/module_cmds.m: compiler/modules.m: compiler/options_file.m: compiler/pd_debug.m: compiler/prog_io.m: compiler/transform_llds.m: compiler/write_deps_file.m: Require callers to supply globals structures explicitly, not via the I/O state. In some cases, the explicit globals structure argument allows a predicate to dispense with the I/O states previously passed to it. In some modules, rename some predicates, types and/or function symbols to avoid ambiguity. compiler/read_modules.m: Require callers to supply globals structures explicitly, not via the I/O state. Record when smart recompilation and the generation of item version numbers should be disabled. compiler/opt_debug.m: compiler/process_util.m: Require callers to supply the needed options explicitly, not via the globals in the I/O state. compiler/analysis.m: compiler/analysis.file.m: compiler/mmc_analysis.m: Make the analysis framework's methods take their global structures as explicit arguments, not as implicit data stored in the I/O state. Stop using `with_type` and `with_inst` declarations unnecessarily. Rename some predicates to avoid ambiguity. compiler/hlds_out.m: compiler/llds_out.m: compiler/mercury_to_mercury.m: compiler/mlds_to_c.m: compiler/mlds_to_java.m: compiler/optimize.m: Make these modules stop accessing the globals from the I/O state. Do this by requiring the callers of their top predicates to explicitly supply a globals structure. To compensate for the cost of having to pass around a representation of the options, look up the values of the options of interest just once, to make further access much faster. (In the case of mlds_to_c.m, the code already did much of this, but it still had a few accesses to globals in the I/O state that this diff eliminates.) If the module exports a predicate that needs these pre-looked-up options, then export the type of this data structure and its initialization function. compiler/frameopt.m: Since this module needs only one option from the globals, pass that option instead of the globals. compiler/accumulator.m: compiler/add_clause.m: compiler/closure_analysis.m: compiler/complexity.m: compiler/deforest.m: compiler/delay_construct.m: compiler/elds_to_erlang.m: compiler/exception_analysis.m: compiler/fact_table.m: compiler/intermod.m: compiler/mode_constraints.m: compiler/mode_errors.m: compiler/pd_util.m: compiler/post_term_analysis.m: compiler/recompilation.usage.m: compiler/size_prof.usage.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/term_constr_errors.m: compiler/term_constr_fixpoint.m: compiler/term_constr_initial.m: compiler/term_constr_main.m: compiler/term_constr_util.m: compiler/trailing_analysis.m: compiler/trans_opt.m: compiler/typecheck_info.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. compiler/gcc.m: compiler/maybe_mlds_to_gcc.pp: compiler/mlds_to_gcc.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Convert these modules to our current programming style. compiler/termination.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Report some warnings with error_specs, instead of immediately printing them out. compiler/export.m: compiler/il_peephole.m: compiler/layout_out.m: compiler/rtti_out.m: compiler/liveness.m: compiler/make_hlds.m: compiler/make_hlds_passes.m: compiler/mlds_to_il.m: compiler/mlds_to_ilasm.m: compiler/recompilation.check.m: compiler/stack_opt.m: compiler/superhomogeneous.m: compiler/tupling..m: compiler/unneeded_code.m: compiler/unused_args.m: compiler/unused_import.m: compiler/xml_documentation.m: Conform to the changes above. compiler/equiv_type_hlds.m: Give the field names of a structure prefixes to avoid ambiguity. Stop using `with_type` and `with_inst` declarations unnecessarily. compiler/loop_inv.m: compiler/pd_info.m: compiler/stack_layout.m: Give the field names of some structures prefixes to avoid ambiguity. compiler/add_pragma.m: Add notes. compiler/string.m: NEWS: Add a det version of remove_suffix, for use by new code above. |
||
|
|
5af57da91d |
Further compiler speedups.
Estimated hours taken: 4 Branches: main Further compiler speedups. library/varset.m: Speed up predicates by avoding making the same decisions over and over again. library/tree234.m: library/map.m: NEWS: Add tree234.map_values_only and map.map_values_only. compiler/add_pragma.m: compiler/analysis.m: compiler/code_info.m: compiler/cse_detection.m: compiler/cse_detection.m: compiler/equiv_type_hlds.m: compiler/global_data.m: compiler/hlds_out.m: compiler/hlds_rtti.m: compiler/inst_graph.m: compiler/lp_rational.m: compiler/hlds_out.m: compiler/mlds_to_il.m: compiler/modules.m: compiler/par_conj_gen.m: compiler/polymorphism.m: compiler/prog_data.m: compiler/prog_type_subst.m: compiler/recompilation.version.m: compiler/simplify.m: compiler/stack_layout.m: compiler/type_util.m: compiler/unneeded_code.m: Use the new predicates. compiler/mark_static_terms.m: Do not bother traversing from_ground_term_construct scopes. Remove a redundant test. compiler/ml_unify_gen.m: Speed up a predicate by avoding making the same decisions over and over again. compiler/mlds.m: Factor out some code. compiler/typecheck_info.m: Operate on vartypes directly as maps; don't transform them unnecessarily into association lists. Do not bother to apply empty substitutions. |
||
|
|
a00596c283 |
The file modules.m contains lots of different kinds of functionality.
Estimated hours taken: 16 Branches: main The file modules.m contains lots of different kinds of functionality. While much of it belongs together, much of it does not. This diff moves most of the functionality that does not belong with the rest to several new modules: libs.file_util parse_tree.deps_map parse_tree.file_names parse_tree.module_cmds parse_tree.module_imports parse_tree.read_module parse_tree.write_deps_file To make them coherent, move some predicates from hlds.passes_aux, parse_tree.prog_io and parse_tree.prog_out to the new modules, making them more accessible, reducing the required access from the hlds package to parse_tree, or from the parse_tree package to libs. In the same spirit, this diff also moves some simple predicates and functions dealing with sym_names from prog_util.m to mdbcomp/prim_data.m. This allows several modules to avoid depending on parse_tree.prog_util. Rename some of the moved predicates and function symbols where this avoids ambiguity. (There were several that differed from other predicates or function symbols only in arity.) Replace several uses of bools with purpose-specific types. This makes some of the code significantly easier to read. This diff moves modules.m from being by far the largest module, to being only the seventh largest, from 8900+ lines to just 4200+. It also reduces the number of modules that import parse_tree.modules considerably; most modules that imported it now import only one or two of the new modules instead. Despite the size of the diff, there should be no algorithmic changes. compiler/modules.m: compiler/passes_aux.m: compiler/prog_io.m: compiler/prog_out.m: Delete the moved functionality. compiler/file_util.m: New module in the libs package. Its predicates search for files and do simple error or progress reporting. compiler/file_names.m: New module in the parse_tree package. It contains predicates for converting module names to file names. compiler/module_cmds.m: New module in the parse_tree package. Its predicates handle the commands for manipulating interface files of various kinds. compiler/module_import.m: New module in the parse_tree package. It contains the module_imports type and its access predicates, and the predicates that compute various sorts of direct dependencies (those caused by imports) between modules. compiler/deps_map.m: New module in the parse_tree package. It contains the data structure for recording indirect dependencies between modules, and the predicates for creating it. compiler/read_module.m: New module in the parse_tree package. Its job is reading in modules, both human-written and machine-written (such as interface and optimization files). compiler/write_deps_file.m: New module in the parse_tree package. Its job is writing out makefile fragments. compiler/libs.m: compiler/parse_tree.m: Include the new modules. compiler/notes/compiler_design.m: Document the new modules. mdbcomp/prim_data.m: compiler/prog_util.m: Move the predicates that operate on nothing but sym_names from prog_util to prim_data. Move get_ancestors from modules to prim_data. compiler/prog_item.m: Move stuff that looks for foreign code in a list of items here from modules.m. compiler/source_file_map.m: Note why this module needs to be in the parse_tree package. compiler/add_pred.m: compiler/add_special_pred.m: compiler/analysis.file.m: compiler/analysis.m: compiler/assertion.m: compiler/check_typeclass.m: compiler/compile_target_code.m: compiler/cse_detection.m: compiler/det_analysis.m: compiler/elds_to_erlang.m: compiler/exception_analysis.m: compiler/export.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_module.m: compiler/hlds_pred.m: compiler/intermod.m: compiler/llds_out.m: compiler/make.dependencies.m: compiler/make.m: compiler/make.module_dep_file.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: compiler/make_hlds_passes.m: compiler/maybe_mlds_to_gcc.pp: compiler/mercury_compile.m: compiler/mlds.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_ilasm.m: compiler/mlds_to_java.m: compiler/mmc_analysis.m: compiler/mode_constraints.m: compiler/mode_debug.m: compiler/modes.m: compiler/module_qual.m: compiler/optimize.m: compiler/passes_aux.m: compiler/proc_gen.m: compiler/prog_foreign.m: compiler/prog_io.m: compiler/prog_io_util.m: compiler/prog_mutable.m: compiler/prog_out.m: compiler/pseudo_type_info.m: compiler/purity.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/simplify.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.detect_garbage.m: compiler/structure_reuse.direct.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/term_constr_main.m: compiler/termination.m: compiler/trailing_analysis.m: compiler/trans_opt.m: compiler/type_util.m: compiler/typecheck.m: compiler/typecheck_info.m: compiler/unify_proc.m: compiler/unused_args.m: compiler/unused_imports.m: compiler/xml_documentation.m: Minor changes to conform to the changes above. |
||
|
|
36b7bd4ea0 |
Store call and answer patterns as terms in `.analysis' (and related) files and
Branches: main Store call and answer patterns as terms in `.analysis' (and related) files and not strings. It's easier to convert complex patterns to/from terms than strings. Also change the module names and function-ids while we're at it. compiler/analysis.m: Replace the `to_string' typeclass with a `to_term' typeclass. Make call and answer patterns convert to/from terms instead of strings. compiler/analysis.file.m: Read/write terms for call and answer patterns. Read/write module names and function-ids with more natural syntax than the term representations of internal data structures. Bump the analysis file version number. Move some code around. Use promise_equivalent_solutions goals instead of promise_equivalent_solution_io. compiler/exception_analysis.m: compiler/structure_reuse.analysis.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/trailing_analysis.m: compiler/unused_args.m: Conform to `to_term' typeclass interface. tests/analysis/ctgc/reuse_runtest.sh: tests/analysis/excp/excp_runtest.sh: tests/analysis/sharing/sharing_runtest.sh: tests/analysis/unused_args/unused_args_runtest.sh: Update test scripts for changed file formats. compiler/mercury_compile.m: Print verbose messages and report stats when reading in files for intermodule analysis. |
||
|
|
6eab527191 |
More changes to the intermodule analysis framework.
Branches: main More changes to the intermodule analysis framework. This patch mainly deals with incorrect treatment of :- external procedures, opt_imported procedures, and forcing the correct reanalyses when answers change or requests are satisfied. - Previously, the way to ensure that a module M is reanalysed if a request in module N is satisfied was, while analysing M: assume an answer for the procedure in N; record that as a result in N; and record that M has a dependency on that answer. When N is analysed, if the real answer is better than the assumed answer, M would be marked `suboptimal' and later reanalysed. That's complicated and wasn't always done correctly. Now we remember the module which makes a request. When the request is satisfied, we mark the requesting module as `suboptimal'. This also means the `.analysis' file of a module will only be modified when analysing that module and no others, which should be useful for parallel builds. - In most analyses we weren't recording results for exported `:- external' procedures as we don't have their clauses and don't analyse them. Other modules would happily make requests for `:- external' procedures, which would never be satisfied. - We shouldn't make intermodule requests for `opt_imported' procedures as we actually have their clauses. Even if the request is satisfied, we'd probably not look them up since we do have their clauses. - If a module M opt_imports a procedure P from module N (its clauses are available while analysing M) then M also needs to depend on any answers required by P. Otherwise a change to an answer required by P won't cause M to be reanalysed. - There doesn't seem to be any reason to keep track of the analysis status of individual results. If an answer changes requiring another module to be reanalysed, the *whole module* will be marked suboptimal or invalid. And if that results in changed answers, its dependant modules will be marked. This patch doesn't remove the status of individual results but makes them always `optimal'. compiler/analysis.m: Remember the name of the module being analysed in the analysis_info. Simplify some predicate interfaces with this information. Remember whether we're currently making an analysis file or just reading from them. Make the record_* predicates do nothing in the latter case, so the caller doesn't need to check. Also make the record predicates do the right thing if the callee module is non-local, e.g. don't make requests to non-local modules. Automatically add a request if depending on a result that doesn't exist. Add a procedure to return the existing call patterns for a procedure, regardless of whether the module has been marked `invalid'. Add some assertions to check the analysis framework is being used as intended. Minor cleanups. compiler/analysis.file.m: Record the module that made the request in `.request' files. Bump the analysis file version number. compiler/hlds_module.m: Pass extra arguments to `init_analysis_info'. compiler/hlds_pred.m: Add `pred_info_is_imported_not_external' which doesn't succeed on `:- external' procedures (defined in the current module), unlike `pred_info_is_imported'. compiler/exception_analysis.m: compiler/tabling_analysis.m: compiler/trailing_analysis.m: compiler/unused_args.m: Record results for `:- external' procedures. Don't look up results for our own `:- external' procedures from the analysis registry. In general, fix many spots where external procs would be treated as imported. Write out results for procedures which are exported to submodules. Conform to analysis framework changes. Remove some redundant checks which have been moved into the framework. compiler/mercury_compile.m: Conform to analysis framework changes. compiler/structure_reuse.analysis.m: Be careful not to read in requests and call patterns for `opt_imported' procedures as if they were defined in the current module. If depending on an answer that doesn't exist, also make a request for that answer. Conform to analysis framework changes. Write out messages when removing useless reuse version procedures. compiler/structure_reuse.indirect.m: Use `pred_info_is_imported_not_external' so as not to look up results for our own `:- external' procedures from the analysis registry. Treat `opt_imported' procedures as intra-module as far as requests are concerned. We need to satisfy requests for them in the current compiler invocation rather than when analysing imported modules. compiler/structure_sharing.analysis.m: Fix treatment of `:- external' procedures. Conform to analysis framework changes. compiler/structure_sharing.domain.m: Don't return suboptimal when unable to look up a result. compiler/mmc_analysis.m: Replace pred_or_func_name_arity_to_func_id by a higher-level predicate. tests/Mmakefile: tests/analysis/Mmakefile: tests/analysis/common.sh: tests/analysis/excp/Mercury.options: tests/analysis/excp/Mmakefile: tests/analysis/excp/excp_m1.m.exception: tests/analysis/excp/excp_m1.m.no_exception: tests/analysis/excp/excp_m2.m: tests/analysis/excp/excp_m3.m: tests/analysis/excp/excp_runtest.sh: tests/analysis/ext/Mercury.options: tests/analysis/ext/Mmakefile: tests/analysis/ext/ext.m: tests/analysis/ext/ext2.m: tests/analysis/ext/ext2_runtest.sh: tests/analysis/ext/ext_runtest.sh: tests/analysis/sharing/Mercury.options: tests/analysis/sharing/Mmakefile: tests/analysis/sharing/sharing_m1.m.no_share: tests/analysis/sharing/sharing_m1.m.share: tests/analysis/sharing/sharing_m2.m: tests/analysis/sharing/sharing_m3.m: tests/analysis/sharing/sharing_runtest.sh: tests/analysis/table/Mercury.options: tests/analysis/table/Mmakefile: tests/analysis/table/table_m1.m.no_tabling: tests/analysis/table/table_m1.m.tabling: tests/analysis/table/table_m2.m: tests/analysis/table/table_m3.m: tests/analysis/table/table_runtest.sh: tests/analysis/trail/Mercury.options: tests/analysis/trail/Mmakefile: tests/analysis/trail/trail_m1.m.no_trail: tests/analysis/trail/trail_m1.m.trail: tests/analysis/trail/trail_m2.m: tests/analysis/trail/trail_m3.m: tests/analysis/trail/trail_runtest.sh: tests/analysis/unused_args/Mercury.options: tests/analysis/unused_args/Mmakefile: tests/analysis/unused_args/ua_m1.m.no_unused_args: tests/analysis/unused_args/ua_m1.m.unused_args: tests/analysis/unused_args/ua_m2.m: tests/analysis/unused_args/ua_m3.m: tests/analysis/unused_args/unused_args_runtest.sh: Add test cases. |
||
|
|
0d60ca704c |
The --intermodule-analysis' option was broken in that touching a .m' file
Branches: main The `--intermodule-analysis' option was broken in that touching a `.m' file would cause its `.analysis' file to be remade (correct) but then all the target code files which depend on that `.analysis' file would be remade, even if the `.analysis' file should be unchanged. Fix that by making analysis files work like other interface files: the timestamp on the `.analysis' file reflects the last time it was changed, and the `.analysis_date' file reflects the last time the module was analysed. To that end we need to move the module status out of the `.analysis' file into a corresponding `.analysis_status' file. Then analysing other modules will only touch the `.analysis_status' file. `.analysis_status' are not installed. compiler/analysis.m: compiler/analysis.file.m: Separate predicates for reading/writing the module status from the module analysis results proper. Use the usual technique of writing analysis results to `.analysis.tmp' and only updating the `.analysis' file if its changed. Write analysis results for a single function-id in sorted order to remove spurious differences. Use some standard interface file handling predicates. compiler/make.util.m: Simplify the special treatment of timestamps for `.analysis' files. compiler/make.module_target.m: compiler/make.program_target.m: Conform to interface changes. |
||
|
|
470fc542e7 |
Add initial support for performing call-specific structure reuse analysis.
Branches: main Add initial support for performing call-specific structure reuse analysis. If a call site violates the conditions for calling the reuse version of a procedure, it can request a different reuse version of the procedure with possibly laxer reuse conditions. At least for now, I have chosen call patterns to simply be lists of argument positions, the arguments which cannot be clobbered by the callee. Requests across module boundaries are supported when using the `--intermodule-analysis' option. This initial version does a lot of unnecessary reanalysis so must be switched on explicitly with a `--structure-reuse-repeat <n>' option. This option shouldn't be needed in the future. compiler/options.m: Add a `--structure-reuse-repeat <n>' option. compiler/analysis.m: compiler/mercury_compile.m: Read in the `.request' file for the current module being analysed when we're preparing to use the intermodule analysis framework. Don't return duplicates when looking up analysis requests. compiler/structure_reuse.analysis.m: Read in old reuse analysis answers and new requests when using `--intermodule-analysis'. Make procedures corresponding to old Answers (as expected by other modules) and new requests (so we analyse the procedures with the requested call patterns). When `--structure-reuse-repeat' is used, use the requests from the latest indirect reuse pass to create new reuse procedures with the extra constraints on some of the head variables (that they must not be clobbered). Perform direct reuse analysis on those procedures, then repeat indirect reuse on the whole module so those new procedures might be called. Record intermodule requests when using `--intermodule-analysis'. Delete reuse versions of procedures we may have created, which after analysis turn out to have no reuse opportunities at all. compiler/structure_reuse.lfu.m: Add a procedure that adds a set of variables to all the local-forward-use sets of a procedure. compiler/structure_reuse.direct.m: Add code to perform direct reuse on a specific list of procedures instead of all the procedures in a module. compiler/structure_reuse.indirect.m: Add code to re-run indirect reuse analysis which when analysing an SCC also analyses the reuse versions of procedures that were created from the procedures in the SCC. Remember and return intra- and inter-module requests when existing reuse procedures can't be called, for later passes and for later analyses of other modules. When looking up reuse information for a procedure, if we don't have that information we should take that assumed result is `optimal'. Otherwise, the analysis results of mutually recursive procedures will never get out of the `suboptimal' state. (Other analyses make the same mistake.) compiler/structure_reuse.domain.m: Extend the `reuse_as_table' with a mapping from an original (non-reuse) procedure plus call pattern to the procedure which actually implements that reuse. Make `reuse_as_satisfied' try to return all of the variables at a call site that violate the reuse conditions. That is, instead of just giving one reason that a reuse procedure call can't be made, try to return all the reasons so we don't waste effort requesting laxer reuse procedures which wouldn't be lax enough for the call site anyway. compiler/structure_reuse.versions.m: Account for multiple reuse versions of procedures. compiler/prog_util.m: Use `make_pred_name' to make the names for reuse predicates. compiler/hlds_goal.m: compiler/hlds_out.m: Record in HLDS goals which reuse version of a procedure to call, since there can be multiple to choose from. compiler/hlds_module.m: compiler/trans_opt.m: Replace the `structure_reuse_map' field in the module structure by a simple set of pred_ids of reuse predicates. The old map from procedures to their reuse counterparts is not needed outside of the structure reuse passes, which has the same information in a separate table anyway. compiler/structure_sharing.analysis.m: Assume guessed structure sharing answers are `optimal' instead of `suboptimal', as above. compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.detect_garbage.m: Module import changes. |
||
|
|
2e3b81442c |
Make the structure sharing analysis capable of using the intermodule analysis
Branches: main Make the structure sharing analysis capable of using the intermodule analysis framework. This requires changes to the analysis framework. Structure sharing answer patterns need information from the module_info and proc_info in order to be compared. In Simon Taylor's original analysis framework implementation, this would have been provided for by a `FuncInfo' parameter in the `partial_order' typeclass. I removed it two years ago as it was causing difficulties which couldn't be solved cleanly while the analysis framework was not specific to the Mercury compiler. Also, there were no analyses at the time which needed FuncInfos. Now that we do require it, and the analysis framework has been made Mercury specific, we can restore the `FuncInfo' parameter. Also make some more simplifications to the analysis framework. compiler/analysis.m: compiler/analysis.file.m: Remove the `module_id' type and replace occurrences by `module_name'. Remove "extra info" facilities. They were intended for storing information needed by intermodule inlining and higher order specialisation but now that information is in `.opt' files, even when using `--intermodule-analysis'. Change `func_id' from a string to a structured type so we can extract its components easily. Add a message argument to the `invalid_analysis_file' functor so when we throw an exception due to being unable to parse a `.analysis' we get a meaningful message. Change the `.analysis' file format to account for the changes to `module_id' and `func_id'. Bump the file version number. Add a `FuncInfo' parameter to the `partial_order' typeclass, as explained above. Add a `no_func_info' dummy type. Add a `get_func_info' method to the `analysis' framework. When updating the analysis files after analysing a module, we need to be able to materialise FuncInfos for each procedure in order to compare its call or answer patterns. This is what couldn't be added cleanly while the analysis framework was not specific to the Mercury compiler. compiler/structure_sharing.analysis.m: Make the structure sharing analysis capable of using the analysis framework, i.e. use imported answers from the analysis registry, record new answers, dependencies and requests, and keeping track of the optimality of results during analysis. compiler/structure_sharing.domain.m: Add `sharing_as_and_status' to pair `sharing_as' with an `analysis_status'. Make `sharing_as_table' record the `analysis_status' alongside a sharing domain. Update access predicates. Move `sharing_as' into the interface section as it is needed by structure_sharing.m to convert between `sharing_as' and `structure_sharing_answer' values for the analysis framework. When we can't look up the sharing result for an `:- external' predicate, that should not be a sign that the analysis is non-optimal since we can't get a better result by reanalysis. Make special predicates be approximated by `bottom' sharing as we know they don't introduce sharing. Avoid an assertion failure in removing subsumed sharing pairs from a sharing set. compiler/ctgc.util.m: Make `pred_requires_no_analysis' not succeed on special predicates (unify, compare, index, init) which causes the analysis to assume all possible sharing between its arguments, whereas we know that those predicates don't introduce any sharing. Also make `pred_requires_no_analysis' not succeed on `:- external' predicates. compiler/ctgc.selector.m: Make type_on_path_2 fail instead of aborting if asked to select a subtype which turns out to be existentially typed. compiler/structure_reuse.direct.m: Don't run direct structure reuse on compiler generated special predicates. We need to handle them specifically now due to the change to `pred_requires_no_analysis'. compiler/structure_reuse.indirect.m: Don't run indirect structure reuse on compiler generated special predicates, as for the direct reuse pass. Conform to change to `top_feedback'. Change a semidet function to a predicate. compiler/hlds_pred.m: compiler/hlds_out.m: Change `structure_sharing_info' to associate an analysis status with the structure sharing domain of a procedure (if any). Add a type `structure_sharing_domain_and_status' for this. compiler/prog_data.m: Make `top_feedback' a structured type instead of a string. Divide the reasons that we might approximate structure sharing by `top' into different classes. compiler/exception_analysis.m: compiler/tabling_analysis.m: compiler/trailing_analysis.m: Conform to analysis framework changes. compiler/unused_args.m: Conform to analysis framework changes. Move the predicate arity from the call pattern into a FuncInfo, where it belongs. Bump the analysis version number. compiler/prog_ctgc.m: compiler/structure_reuse.direct.detect_garbage.m: Conform to change to `top_feedback'. compiler/make.dependencies.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: Conform to removal of `module_id' type. compiler/mercury_compile.m: Call mm_tabling_analysis, structure sharing and structure reuse passes when making `.analysis' files. Conform to removal of `module_id' type. compiler/mmc_analysis.m: Add structure sharing to the list of analyses. Add `func_id_to_ppid'. Conform to analysis framework changes. compiler/ctgc.fixpoint_table.m: Replace a semidet function by a predicate. |
||
|
|
8c4bcaf297 |
Make the intermodule analysis framework not require the I/O state for looking
Estimated hours taken: 6
Branches: main
Make the intermodule analysis framework not require the I/O state for looking
up and recording analysis results. The I/O state was required because
analysis files were loaded "on demand" but in most cases this was pointless.
Now we just load all the analysis files of transitively imported modules
before we run anything that uses the analysis framework.
compiler/analysis.file.m:
compiler/analysis.m:
Make the main change above.
Use `unexpected' instead of `error' for fatal errors.
Replace `{Call, Answer, analysis_status}' tuples by a new type
`analysis_result'.
Rename the existing existentially-typed `analysis_result' to
`some_analysis_result'.
Remove the `module_is_local' method from the `compiler' typeclass.
Replace it by a plain procedure that takes an `analysis_info' as
input, instead of using the I/O state.
Use trace goals for debugging output, where we no longer have the I/O
state.
Clean up some code.
compiler/mercury_compile.m:
Before running anything that uses the analysis framework, read in all
the analysis files which might be needed.
compiler/mmc_analysis.m:
Delete `module_is_local' method.
compiler/constraint.m:
compiler/deforest.m:
compiler/exception_analysis.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/pd_util.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Conform to the changes above.
Don't thread I/O state through procedures which no longer require it.
|
||
|
|
ef81b66625 |
Move the intermodule analysis framework into the `compiler' directory, in
Estimated hours taken: 2 Branches: main Move the intermodule analysis framework into the `compiler' directory, in preparation for making it specific to the Mercury compiler, rather than having it generic in case some fictional being might want to use it with a .NET compiler one day. This will make it easier to use and modify. compiler/analysis.file.m: compiler/analysis.m: Copy these files from the `analysis' directory. compiler/top_level.m: Include analysis.m as a new package. compiler/Mercury.options: Add a bug workaround line from analysis/Mercury.options. analysis/Mercury.options: analysis/Mmakefile: analysis/analysis.file.m: analysis/analysis.m: analysis/mer_analysis.m: Replace the contents of these files with comments that the analysis framework is now in the `compiler' directory. We don't actually delete them so their histories remain easily accessible. analysis/README: Mention that the code has been moved. compiler/notes/compiler_design.html: compiler/notes/overall_design.html: Update documentation. Mmake.workspace: Mmakefile: configure.in: compiler/.mgnuc_copts: compiler/COMP_FLAGS.in: compiler/Mmakefile: deep_profiler/.mgnuc_copts: scripts/Mmake.vars.in: scripts/c2init.in: scripts/mercury_config.in: scripts/prepare_tmp_dir_fixed_part.in: tools/binary: tools/binary_step: tools/bootcheck: tools/lmc.in: tools/make_arena: compiler/notes/coding_standards.html: Remove references to the `analysis' directory and `libmer_analysis'. |