Commit Graph

413 Commits

Author SHA1 Message Date
Zoltan Somogyi
3aca14b385 Compile the Mercury system with --warn-unused-types.
configure.ac:
    Require the installed compiler to support that option.

STANDARD_MCFLAGS:
    Specify that option.

compiler/canonicalize_interface.m:
compiler/comp_unit_interface.m:
compiler/inst_user.m:
compiler/parse_module.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
deep_profiler/mdprof_dump.m:
library/digraph.m:
slice/mcov.m:
    Delete unused equivalence types that were picked up by the option.
2026-03-09 03:07:51 +11:00
Zoltan Somogyi
36e8833145 Add a new option, --warn-unused-types.
When set, this option tells the compiler to generate warnings
about locally-defined types that are neither used in the module
nor exported to any other module.

compiler/options.m:
    Add the new option.

compiler/unused_types.m:
    New module to implement the new option.

compiler/mercury_compile_front_end.m:
    Invoke the new module, unless the presence of previous errors
    would make its warnings just a distraction.

compiler/check_hlds.m:
    Include the new module.

compiler/notes/compiler_design.html:
    Document the new module.

compiler/typecheck_error_wrong_type.m:
    Simplify some code.

browser/declarative_tree.m:
compiler/accumulator.m:
compiler/du_type_layout.m:
compiler/intermod.m:
compiler/mode_errors.m:
compiler/parse_inst_mode_defn.m:
compiler/polyhedron.m:
compiler/split_parse_tree_src.m:
compiler/tag_switch_util.m:
compiler/typecheck_error_unify.m:
compiler/unneeded_code.m:
deep_profiler/mdprof_test.m:
library/getopt.m:
library/getopt_io.m:
    Delete unused types reported by the new option.

library/rtti_implementation.m:
    Comment out unused type reported by the new option. This type was exported
    to both Java and C#, but this diff comments it out because neither language
    the Java or the C# runtime system seems to use the exported versions
    either. (Bootcheck in both java and csharp grades worked, with the
    same number of test case failures as before.) We do not delete it,
    because it may be useful in the future.

tests/warnings/help_text.err_exp:
    Expect the documentation of the new option.

tests/invalid_nodepend/Mmakefile:
    Specify --warn-unused-types for two test cases to test that the compiler
    does NOT generate warnings about unused types in the presence of previous
    errors.

tests/warnings/abstract_type_decl.err_exp:
tests/warnings/bug412.err_exp:
tests/warnings/warn_dead_procs.err_exp:
    Expect the new warnings for unused types.

tests/warnings/Mmakefile:
    Specify --warn-unused-types for the three test cases listed above.
2026-02-15 11:26:34 +11:00
Julien Fischer
579044d267 Update .gitignore files in deep_profiler and slice dirs.
deep_profiler/.gitignore:
slice/.gitignore:
    As aobve.
2026-02-06 17:28:44 +11:00
Zoltan Somogyi
2a1f376c5d Use spaces in all Mercury.options files.
Use consistent indentation.

Sort many blocks of module-specific MCFLAGS settings by module name.

Add XXXs about some questionable options.
2025-12-06 10:39:04 +11:00
Zoltan Somogyi
9baadb3d88 Style improvements in browser and deep_profiler.
deep_profiler/var_use_analysis.m:
    Pass never-varying and slower-varying input arguments first.

    Consistently pass goal lists before the position of the first goal
    in the overall list.

browser/declarative_analyser.m:
browser/declarative_edt.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_types.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/timeout.m:
deep_profiler/top_procs.m:
deep_profiler/util.m:
    Minor improvements in programming style.
2025-11-18 16:11:20 +11:00
Zoltan Somogyi
c9e549996a Let switch detection handle deeper disjunctions.
compiler/switch_detection.m:
    The existing switch detection algorithm does a single forward
    traversal of the procedure body, doing only very limited lookahead.
    This prevents it from recognizing some switches. To fix this, add
    a new prepass that provides unlimited lookahead.

    Add one use of this lookahead information. Later diffs should add
    more uses.

compiler/print_help.m:
    Fix the code that served as motivation for this change.
    It was a block of unifications that was intended to supply
    the lookahead that the old algorithm needed but did not have,
    but it actually lied: it said that the the following disjunction
    covered cons_ids that it actually did not cover. The fact that
    the compiler did not diagnose this lie until now was a bug.
    (After this diff, the compiler now reports an error.)

deep_profiler/message.m:
    Avoid the limitation of the new algorithm that was discussed today
    on m-dev.

compiler/options.m:
    Add a way to test for the presence of this new capability
    in the installed compiler.

tests/warnings/help_text.err_exp:
    Expect the new option name.
2025-11-15 05:08:29 +11:00
Zoltan Somogyi
1a5568fbfd Put switch arms in type declaration order. 2025-11-13 14:30:26 +11:00
Julien Fischer
f36510b22e Make stage 1 C# executables work with Mono.
They do not currently work in-situ because the launcher scripts we generate do
not set MONO_PATH appropriately. Use the new --mono-path-directory option to
remedy this.

compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
mfilterjava/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
    As above.
2025-08-02 15:07:25 +10:00
Zoltan Somogyi
6628fa52bc Add missing flags. 2025-07-31 10:27:56 +02:00
Zoltan Somogyi
5e9590b3be Carve two modules out of mdbcomp/trace_counts.m.
mdbcomp/read_trace_counts.m:
mdbcomp/write_trace_counts.m:
    Carve these two modules out of trace_counts.m.

    Put the lowest-level building block, the read_trace_counts predicate,
    last in read_trace_counts.m.

    Stop exporting write_proc_label from write_trace_counts.m.

mdbcomp/trace_counts.m:
    Delete the moved code, and export the trace_count_file_id function
    to both new modules.

mdbcomp/mdbcomp.m:
    Include the new modules.

deep_profiler/Mmakefile:
slice/Mmakefile:
    Copy the new modules to these directories.

deep_profiler/.gitignore:
slice/.gitignore:
    Ignore the newly-copied source files.

compiler/tupling.m:
mdbcomp/slice_and_dice.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
    Update the set of imports needed.
2025-07-30 01:43:39 +02:00
Zoltan Somogyi
0e41d41286 Make mdprof_create_feedback/feedback.m a package.
mdbcomp/feedback.feedback_info.m:
mdbcomp/feedback.m:
    Move all the contents of feedback.m other than include_module items
    into the new module feedback_info.m, leaving feedback.m a package.

mdbcomp/feedback.automatic_parallelism.m:
    Group the types exported by this module into groups of related types.

    Delete a totally unused type.

deep_profiler/Mmakefile:
slice/Mmakefile:
    Copy the new module.

compiler/check_options.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/introduce_parallelism.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_report_feedback.m:
    Import the new module.
2025-07-25 18:52:31 +02:00
Zoltan Somogyi
3dd0f2e03b Act on all remaining warnings about unused state vars.
compiler/add_heap_ops.m:
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_import_use.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/higher_order.specialize_unify_compare.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make_hlds_passes.m:
compiler/make_module_file_names.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/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_target_util.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/optimize.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_string_format.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/simplify_goal_disj.m:
compiler/ssdebug.m:
compiler/stack_opt.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/term_constr_build.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/write_deps_file.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/html_format.m:
deep_profiler/startup.m:
profiler/mercury_profile.m:
profiler/propagate.m:
    Act on the new warnings. In a few cases, conform to the changes
    resulting from acting on the warnings in other modules.

browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
ssdb/Mercury.options:
    Specify options for disabling the new warnings for modules
    where we (probably) won't want them.

configure.ac:
    Require the installed compiler to understand the options that
    we now reference in the Mercury.options files above.

tests/debugger/tailrec1.exp:
    Expect variable names for the middle versions of state vars
    using the new naming scheme.

tests/invalid/Mercury.options:
    Fix references to obsolete test names.

tests/warnings/Mercury.options:
    Avoid a test failure with intermodule optimization.
2025-05-19 00:33:06 +10:00
Zoltan Somogyi
a70dc4b257 Generate a warning for moved trace goals.
compiler/mark_trace_goals.m:
    When we find a trace goal that occurs at a higher line number in a file
    than the line number of a goal to its left, generate a warning about the
    move.

compiler/goal_expr_to_goal.m:
    When converting the parse tree's try goals to HLDS goals, we need
    to add some goals to the start of code pieces that catch exceptions.
    Give these goals the context of the try goal as a whole, which will be
    the context of its start, rather that the context of the catching goal,
    which (e.g. if it is a conjunction) may point to the *middle* of that goal.
    This is needed to avoid spurious warnings from the new code in
    mark_trace_goals.m when the catching goal contains a trace goal.

The rest of the changes in the compiler are there to track down
the reason why we do not yet pass the test case mentioned below.
It has done that job: the cause is that the code that computes the
set of variables that a conjunction being delayed is waiting on
is wrong in two separate ways. First, it gets the set of waiting-on vars
from only *some* of the conjuncts being delayed, not all, which makes it
possible to some variables to be erroneously excluded from that set.
Second, it can include variables in a goal's waiting-on set that are
not in the delayed goal's nonlocals set, and thus *cannot possibly*
be instantiated by textually later goals.

The result is that in the test case below, the first trace goal is delayed
waiting *not* for the variables it wants to print, but on the local variable
holding the created-from-thin-air I/O state.

compiler/mode_debug.m:
    Significantly expand the infrastructure for debugging mode analysis,
    by allowing mode_debug.m to print

    - the unique goal_id of the goal being entered, exited, delayed or
      woken up at a checkpoint, and

    - at delay checkpoints, the nonlocal variables of the goal being delayed,
      and the waiting-on variables of the errors that cause the delay.

    Separate the output for different events by consistently putting
    a blank line before the description of each port event.

compiler/mode_info.m:
compiler/options.m:
doc/user_guide.texi:
    Provide the infrastructure needed for the new functionality in
    mode_debug.m.

    Replace booleans with values of bespoke types.

compiler/simplify_proc.m:
    Fill in goals' goal_id fields, if asked for.

compiler/modecheck_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/unique_modes.m:
    Provide the extra info now needed by checkpoints.

tests/warnings/moved_trace_goal.{m,err_exp}:
    A new test case, for which we now generate that is partially correct
    and partially wrong. The .err_exp file contains the correct-and-generated
    parts.

tests/warnings/Mmakefile:
    Enable the new test case.

compiler/try_expand.m:
deep_profiler/Mmakefile:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_search_callgraph.m:
    Style fixes for code I looked at while trying to track down
    the cause of the spurious moved trace goal warning mentioned
    in the entry for goal_expr_to_goal.m.
2025-05-06 10:13:04 +10:00
Zoltan Somogyi
1eb4f55834 Include file names in call site static structures.
Fix a problem that arises in the deep profiler if the program being profiled
was using both intermodule optimization and inlining. The issue was that
even though runtime/mercury_deep_profiling.c had access, for every call site
to the full context of that call site, containing both the file name and
the line number, it wrote out *only* the line number. The deep profiler
then got the file name from the file name stored in the proc_static structure
of the procedure containing the call site.

This works very close to 100% of the time, because

- user-written programs just about never use ":- pragma source_file", and
- in the absence of such pragmas, all the goals in a procedure will be
  from the same file as the procedure's context.

However, if

- a call site calls a procedure in another module,
- the compiler has access to the code of that procedure from a .opt file, and
- the compiler decides to inline that call,

then the call, whose context is in the original source file, will be replaced
by the code of the procedure from the .opt file, whose context will NOT have
the same file name. Any description of this call site will list

- the code from the .opt file (such as the callee's callee),
- the file name from the original source file, and
- the line number from the .opt file.

This mismatch is very confusing, which is why this diff fixes it.

runtime/mercury_deep_profiling.c:
    Fix this by writing out the file name part, as well as the line number
    part, of each call site. The space impact is not as big as one might
    expect, because compiler/deep_profiling.m already had an optimization
    that set the filename part of each call site context to the empty string
    if it was identical to the context of the procedure. Therefore for all
    call sites that do NOT exhibit the bug that this diff fixes, the space
    cost is only a single NULL character in the profiling data file.

    Since this IS a change in the file format, bump the format version number
    from 8 to 9.

deep_profiler/profile.m:
deep_profiler/read_profile.m:
    Handle reading in both version 8 and version 9 profiling data files.

deep_profiler/create_report.m:
    When creating descriptions of call sites, use the call site's filename
    if it is not the empty string; if it is the empty string, then use
    the containing procedure's file name, as we have done all along.

deep_profiler/display_report.m:
deep_profiler/dump.m:
deep_profiler/report.m:
    Dump the new field in commands intended only for implementors.

deep_profiler/startup.m:
    Conform to the changes above.
2025-03-20 20:00:15 +11:00
Zoltan Somogyi
57682eb9ba Simplify some deep profiling code.
compiler/deep_profiling.m:
    Replace three predicate lookups with one.

    Simplify the code getting goal contexts.

deep_profiler/read_profile.m:
    Implement a two-level loop in our usual fashion.

    Use our usual state-var-friendly argument order.
2025-03-20 09:16:30 +11:00
Zoltan Somogyi
a92ae7d9bd Update copyright notices. 2025-01-24 13:38:10 +11:00
Zoltan Somogyi
dcf48e2315 Add a new option, --warn-unsorted-import-blocks.
compiler/options.m:
doc/user_guide.texi:
NEWS.md:
    Add, document and announce the new option. It is off by default,
    but of course I tested its behavior when turned on. Most of this
    diff deals with the consequences.

compiler/item_util.m:
    Add code to generate the new warnings if requested.

compiler/convert_parse_tree.m:
    Request the new warning if the new option is set when processing
    source files..

compiler/handle_options.m:
    Disable all style warnings, including the new one, when generating
    .int* files or .*opt files.

compiler/mercury_compile_main.m:
    Fix an unrelated bug I noticed while working on this diff:
    report the "unfindability" of a given file at most once.

browser/dl.m:
browser/io_action.m:
compiler/mercury_compile_augment.m:
compiler/mercury_compile_llds_back_end.m:
compiler/unused_args.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
library/array2d.m:
library/bit_buffer.read.m:
library/construct.m:
library/edit_distance.m:
library/library.m:
library/mercury_term_lexer.m:
library/one_or_more_map.m:
library/private_builtin.m:
library/set_bbbtree.m:
library/string.parse_runtime.m:
library/thread.future.m:
library/univ.m:
library/version_array.m:
library/version_bitmap.m:
mdbcomp/program_representation.m:
profiler/call_graph.m:
profiler/demangle.m:
profiler/output.m:
profiler/process_file.m:
profiler/propagate.m:
slice/mdice.m:
slice/mslice.m:
    Fix unsorted import blocks pointed out by the new option.

tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/bad_tscp.err_exp:
tests/invalid/bug10.err_exp:
tests/invalid/gh72_errors.err_exp:
tests/invalid/ho_default_func_2.err_exp:
tests/invalid/require_scopes.err_exp:
tests/invalid/type_error_use_module.err_exp:
tests/invalid/types.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_nodepend/funcs_as_preds.err_exp:
tests/warnings/ambiguous_overloading.err_exp:
tests/warnings/save.err_exp:
tests/warnings/singleton_test.err_exp:
tests/warnings/unused_interface_import.err_exp:
    Update the expected outputs of these test cases to expect the new warning
    for unsorted import blocks in their source files.

tests/invalid/Mercury.options:
tests/invalid_nodepend/Mercury.options:
tests/warnings/Mercury.options:
    Execute those test cases with the warning enabled.

tests/invalid_nodepend/require_tailrec_invalid.m:
tests/invalid_nodepend/specified.m:
tests/recompilation/pragma_type_spec_r.m.1:
tests/recompilation/type_qual_re.m.1:
tests/recompilation/type_qual_re_2.m.1:
tests/recompilation/type_spec_unname_var_r.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.2:
tests/recompilation/unchanged_pred_nr.m.1:
tests/recompilation/with_type_re.m.1:
    Sort the import blocks in these test cases, and where relevant,
    import only one module per line.

tests/recompilation/with_type_re.err_exp.2:
    Expect updated line numbers after splitting a line that imported
    two modules.

tests/warnings/unsorted_import_blocks.{m,err_exp}:
    New test case to exercise one nontrivial part of the sortedness check,
    numerical non-sortedness. (The other affected test cases already exercise
    all the other parts.)

tests/warnings/Mmakefile:
    Enable the new test case.
2025-01-21 19:19:33 +11:00
Julien Fischer
cfbbf931e8 Update more copyright notices in deep_profiler.
deep_profiler/*.m:
    As above.
2024-12-29 16:53:18 +11:00
Julien Fischer
2424d820f0 Update copyright notices in deep_profiler.
deep_profiler/*.m:
    As above.
2024-12-22 21:33:06 +11:00
Zoltan Somogyi
22ca210056 Mark copied intermediate files as do-not-delete.
slice/Mmakefile:
deep_profiler/Mmakefile:
    As above. This avoids having to rebuild the interface and target
    language files of the modules copied to these directories from
    the mdbcomp directory after the creation of each executable.
2024-12-09 04:36:35 +11:00
Zoltan Somogyi
d0d039c39c Narrow the use of --no-warn-inferred-erroneous.
browser/MDB_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Stop specifying --no-warn-inferred-erroneous as the default for
    every module in these directories, most of which did not even need it
    (the result of blind copying in the absence of STANDARD_MCFLAGS).

browser/Mercury.options:
library/Mercury.options:
    Specify --no-warn-inferred-erroneous for the modules that
    actually do need it.
2024-11-10 04:20:51 +11:00
Zoltan Somogyi
22b058bb34 Make two warnings standard.
STANDARD_MCFLAGS:
    Make --warn-dead-preds and --warn-implicit-stream-calls the defaults.
    Previously, these were the defaults in some directories, but not all.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Delete option settings that are now in STANDARD_MCFLAGS.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/coverage.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
profiler/generate_output.m:
profiler/process_file.m:
profiler/snapshots.m:
    Avoid warnings about dead code by

    - deleting it (if it is trivial recreate if ever needed again,
      or is obviously never going to be needed again,

    - commenting out the dead predicates, if the module concerned already
      has such code, or

    - adding consider_used pragmas for the dead predicates.

grade_lib/choose_grade.m:
grade_lib/grade_setup.m:
grade_lib/grade_solver.m:
grade_lib/test_grades.m:
grade_lib/try_all_grade_structs.m:
library/edit_distance.m:
    Use explicit streams.

deep_profiler/canonical.m:
deep_profiler/Mercury.options:
    Disable --warn-dead-preds for the canonical module, which was
    never finished. Document this fact.

library/Mercury.options:
    Disable --warn-implicit-stream-calls for the modules that export
    predicates that do I/O to implicitly specified streams, since
    they cannot be fixed without breaking backwards compatibility.

ssdb/ssdb.m:
    Document the fact that this module requires nontrivial changes
    (storing the ids of the input/stream streams in the debugger state)
    to avoid warnings from --warn-implicit-stream-calls.

    Document why --warn-dead-preds must be disabled for (the current code of)
    this module.

    Change a type from an equivalence type to a notag type, for additional
    type safety.

    Add some documentation.

    Delete a dead predicate.

ssdb/Mercury.options:
    Disable --warn-dead-preds and --warn-implicit-stream-calls for ssdb.m.
2024-11-10 02:24:18 +11:00
Zoltan Somogyi
2db9ed70c9 Put the standard mmc flags in one file.
STANDARD_MCFLAGS:
    Put the mmc options that are common to either

    - all of the dir/DIR_FLAGS.in files, or
    - all but one of them,

    into this new file.

    (MFILTERJAVAC_FLAGS did not specify --warn-suspicious-foreign-code;
    after this diff, it does.)

configure.ac:
    Enable replacing @STANDARD_MCFLAGS@ with the new file's contents.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Include STANDARD_MCFLAGS instead of listing each option in it
    individually, making future global changes to options easier.
2024-11-09 20:55:44 +11:00
Peter Wang
35e76e41e2 Put .mh files into Mercury/mhs subdirectory.
Put .mh files into a Mercury/mhs subdirectory when --use-subdirs
or --use-grade-subdirs is used.

compiler/file_names.m:
    Replace ext_cur_mh with ext_cur_ngs_max_cur_mh, in the new category
    ext_cur_ngs_max_cur. The new category is similar to that for .mih
    files, except that .mh files are never placed in grade-specific
    subdirectories.

compiler/handle_options.m:
    Add Mercury/mhs subdirs to list of C include directories
    when --use-subdirs or --use-grade-subdirs is in effect.

compiler/write_deps_file.m:
    Add $(mhs_subdir) prefix before %.mh patterns.

    Create a Mercury/mhs -> .. symlink when installing.
    This is required by mmc --make and mmake --use-subdirs.

    Conform to the changes above.

compiler/export.m:
compiler/make.file_names.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
    Conform to the changes above.

scripts/Mmake.vars.in:
    Define the variable mhs_subdir.

scripts/Mmake.rules:
    Add -I option to find .mh files when --use-subdirs is used.

browser/.mgnuc_copts:
browser/MDB_FLAGS.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
deep_profiler/.mgnuc_copts:
deep_profiler/DEEP_FLAGS.in:
extras/EXTRAS_FLAGS.in:
grade_lib/.mgnuc_copts:
grade_lib/GRADE_LIB_FLAGS.in:
library/.mgnuc_copts:
mdbcomp/.mgnuc_copts:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/.mgnuc_copts:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/SLICE_FLAGS.in:
ssdb/.mgnuc_copts:
ssdb/SSDB_FLAGS.in:
tests/.mgnuc_copts.ws:
tests/WS_FLAGS.ws:
trace/.mgnuc_copts:
tools/lmc.in:
    Add -I options to find .mh files when the workspace is built
    with mmake --use-subdirs.

samples/c_interface/standalone_c/Makefile:
    Add option to let the C compiler find the .mh file.

NEWS.md:
    Announce change.

    Delete trailing whitespace.
2024-07-23 17:44:17 +10:00
Zoltan Somogyi
4d602d6ad3 Specify -I search flags in permitted reference order. 2024-07-17 13:48:27 +02:00
Zoltan Somogyi
e2929976ed Fix predicate names. 2024-07-05 16:59:31 +10:00
Zoltan Somogyi
d3dd33b59b Make the integers inside goal_ids unsigned.
mdbcomp/mdbcomp.goal_path.m:
    As above. Instead of using -1 to represent invalid goal_ids, 0 to
    represent whole body goals, and higher values to represent subgoals,
    use 0 to represent invalid goal_ids, 1 to represent whole body goals,
    and higher values to represent subgoals.

    Add a function to return invalid goal_ids, to avoid the need
    for knowledge of this scheme outside this module.

compiler/build_mode_constraints.m:
compiler/closure_gen.m:
compiler/coverage_profiling.m:
compiler/goal_path.m:
compiler/hlds_goal.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/ordering_mode_constraints.m:
compiler/state_var.m:
compiler/unneeded_code.m:
deep_profiler/program_representation_utils.m:
    Conform to the changes above.
2023-11-22 10:03:50 +11:00
Zoltan Somogyi
0c7af82fc6 Use += instead of = to set MCFLAGS-modulename.
*/Mercury.options:
    Specify module-specific Mercury compiler flags using

        MCFLAGS-modulename += options

    instead of

        MCFLAGS-modulename = options

    because unlike the latter, the former allows Mmake.params files
    to add other options.
2023-10-06 00:04:07 +11:00
Zoltan Somogyi
104a8ebd9e Get "make cs"/"mmc --make x.cs" to build a C# file ...
... instead of building a bunch of .c files.

Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".

This diff keeps that synonym, but it changes

- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
        from "trans_opts" to "all_trans_opts"

It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.

To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.

NEWS.md:
    Announce the breaking change.

compiler/make.top_level.m:
    Stop treating the target "cs" as meaning "build all the .c files
    for this program".

    The code of classify_target_2 has long been semidet, but only in a way
    that was not apparent to the compiler. Change the code to allow the
    compiler to see its semidet nature while keeping the algorithm the same,
    except for the change in the paragraph above.

    This includes keeping e.g. "ints" as meaning "build all the .int/.int2
    files needed by this program".

compiler/write_deps_file.m:
    Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
    ".javas" and ".css". The mmake variables with suffixes ".all_cs",
    ".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
    All had the same value as the mmake variable without the "all",
    with one exception: ".cs". However, in this case, the old (and still
    current) value of ".all_cs" is what the value of ".cs" *should* have been.

    Simplify some code.

The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.

compiler/file_names.m:
    Add a version of a fact_table_file_name_return_dirs which does not
    return directories, since most of its callers don't need that info.

compiler/make.program_target.m:
    Clarify code by making variable names more descriptive,

compiler/make.file_names.m:
compiler/make.module_target.m:
    Conform to the changes above,

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
    Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
    and opts to all_opts. (There were no occurrences of trans_opts to rename.)

    Replace [s as sh command names in actions.

scripts/Mmake.vars.in:
    Specify the names of mmake variables holding the names of sets of files
    with a given extension directly, since for some of them, adding an "s"
    at the end of the name of the extension does not generate the name
    of the corresponding mmake variable anymore.

scripts/Mmake.rules:
    Use the directly specified mmake variable names from Mmake.vars.in
    in the rule for installing lbraries. Temporarily add some debugging
    output to make suree that the updated nested mmake variable references
    work as intended.

tools/bootcheck:
    Specify the names of mmake targets for making all the files in a program
    with a given extension directly, since adding an "s" at the end of the
    name of the extension does not generate the name of the corresponding
    mmake target anymore.

    Print timestamps around the action of checking namespace cleanliness,
    to allow the time taken by that action to be measured. (I kept track
    of bootchecks as they happened while working on this diff, and found
    this time to be nontrivial.)
2023-10-05 02:03:47 +11:00
Zoltan Somogyi
a0d6710407 Use "ts=4 sw=4 expandtab" as modeline ...
... in Mercury.options files.
2023-09-16 19:12:52 +10:00
Zoltan Somogyi
5f47a8389b Stop using higher order insts as modes.
configure.ac:
    Require the installed compiler to support --allow-insts-as-modes
    (and therefore its negation).

*/*_FLAGS.in:
    Add -no-allow-ho-insts-as-modes as a default option.

compiler/bytecode_data.m:
compiler/deforest.m:
compiler/inst_graph.m:
compiler/introduce_parallelism.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
compiler/parse_util.m:
compiler/recompilation.version.m:
compiler/set_of_var.m:
compiler/term_constr_fixpoint.m:
deep_profiler/array_util.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/interface.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
    Add in() wrappers around higher order insts used as modes.

    Use simply "in" as the mode of functions with the default mode
    and determinism.

    Fix a few style issues.
2023-08-15 00:19:34 +02:00
Julien Fischer
d0b64c87c7 Ignore files generated by MSVC.
*/.gitignore:
   Ignore any increment linker files (.ilk) and program database (.pdb)
   file that MSVC generates.
2023-07-01 02:25:53 +10:00
Julien Fischer
19d818209f Ignore *.obj files.
*/.gitignore:
    As above.

    Fix a few other omissions.
2023-06-26 20:05:24 +10:00
Zoltan Somogyi
a47de48c4d s/input_stream/text_input_stream/ ...
... and the same for output streams.
2023-04-24 14:59:20 +10:00
Zoltan Somogyi
41d133b8ad Update the "no export" criteria and message.
compiler/check_module_interface.m:
    Generate a "this module does not export anything" warning for modules
    that contain only single include_module declaration, since such modules
    could be deleted with no effect.

    Change the warning message to list every kind of declaration/definition
    that does not depend on the presence of other kinds of declarations or
    definitions.

deep_profiler/Mercury.options:
    Shut up this warning for mdprof_fb, since right now, it contains
    only a single include_module, even it is designed to later contain more.

tests/invalid/empty_interface.err_exp:
tests/invalid/typeclass_missing_det_3.err_exp:
tests/invalid_nodepend/bigtest.err_exp:
tests/invalid_nodepend/duplicate_modes.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_nodepend/no_exports.err_exp:
tests/invalid_nodepend/prog_io_erroneous.err_exp:
tests/invalid_nodepend/typeclass_test_11.err_exp:
tests/invalid_nodepend/vars_in_wrong_places.err_exp:
    Expect the updated wording of the warning message.
2022-04-05 10:32:10 +10:00
Zoltan Somogyi
255835ce2a Make a zero-width space <wbr>, not <wbr />. 2022-03-23 06:43:25 +11:00
Zoltan Somogyi
2954a8765c Improve programming style. 2022-03-17 13:52:46 +11:00
Zoltan Somogyi
c02eb5163e Carve io.{call_system,environment}.m out of io.m.
library/io.call_system.m:
    Move the code in the "system access predicates" section of io.m
    to this new module.

library/io.environment.m:
    Move the predicates dealing with environment variables in io.m
    to this new module.

library/io.m:
    Delete the code moved to the new modules.

    Leave behind in io.m "forwarding predicates", predicates that do nothing
    except call the moved predicates in the new modules, to provide backward
    compatibility. But do mark the forwarding predicates as obsolete,
    to tell people to update their (at their leisure, since the obsoleteness
    warning can be turned off).

    Also leave behind in io.m the definitions of the types used
    by some parameters of some of the moved predicates.

library/MODULES_DOC:
    List the new modules among the documented modules.

library/library.m:
    List the new modules, including io.file.m (added in a previous change)
    among the documented standard library modules.

NEWS:
    Announce the changes.

browser/browse.m:
browser/interactive_query.m:
compiler/fact_table.m:
compiler/handle_options.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/optimize.m:
compiler/options_file.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
library/io.file.m:
mdbcomp/trace_counts.m:
ssdb/ssdb.m:
tests/general/environment.m:
tests/hard_coded/closeable_channel_test.m:
tests/hard_coded/setenv.m:
tests/hard_coded/system_sort.m:
    Call the moved predicates directly in their new modules,
    not indirectly through io.m.
2022-03-08 09:38:27 +11:00
Zoltan Somogyi
25b4b67403 Carve io.file.m out of io.m.
library/io.file.m:
library/io.m:
    Move two sections of io.m, the "file handling predicates" section
    and the "handling temporary files" section to the new submodule io.file.m.

    Leave behind in io.m "forwarding predicates", predicates that do nothing
    except call the moved predicates in io.file.m, to provide backward
    compatibility. But do mark the forwarding predicates as obsolete,
    to tell people to update their (at their leisure, since the obsoleteness
    warning can be turned off).

    Also leave behind in io.m the definitions of the two types used
    by some parameters of some of the moved predicates. Document the reason
    why this is done.

library/MODULES_DOC:
    List the new module among the documented modules.

NEWS:
    Announce the changes.

browser/browse.m:
browser/interactive_query.m:
browser/listing.m:
compiler/analysis.file.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_util.m:
compiler/handle_options.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/parse_module.m:
compiler/passes_aux.m:
compiler/prog_event.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
library/dir.m:
mdbcomp/program_representation.m:
ssdb/ssdb.m:
    Call the file operation predicates directly in io.file.m, not indirectly
    through io.m.

    In two modules, add a #include of fcntl.h in C code. These modules contain
    C code that needs this #include, but until now, they got it via a copy
    in an automatically generated C header file of a foreign_decl pragma
    in io.m that contained that #include. This diff moves that foreign_decl
    to io.file.m, removing that crutch.

tests/debugger/browser_test.m:
tests/hard_coded/bit_buffer_test.m:
tests/hard_coded/bitmap_test.m:
tests/hard_coded/construct_bug.m:
tests/hard_coded/dir_fold.m:
tests/hard_coded/dir_test.m:
tests/hard_coded/read_binary_int16.m:
tests/hard_coded/read_binary_int32.m:
tests/hard_coded/read_binary_int64.m:
tests/hard_coded/read_binary_uint16.m:
tests/hard_coded/read_binary_uint32.m:
tests/hard_coded/read_binary_uint64.m:
tests/hard_coded/read_bitmap_size.m:
tests/hard_coded/remove_file.m:
tests/hard_coded/write_binary.m:
tests/hard_coded/write_binary_int8.m:
tests/hard_coded/write_binary_multibyte_int.m:
tests/hard_coded/write_binary_uint8.m:
    Call the file operation predicates directly in io.file.m, not indirectly
    through io.m.
2022-03-08 06:01:21 +11:00
Zoltan Somogyi
8074e94431 Replace functions with state-var-friendly preds. 2022-03-04 01:11:11 +11:00
Zoltan Somogyi
58aa848cf0 Update programming style. 2022-03-04 01:08:55 +11:00
Zoltan Somogyi
06f81f1cf0 Add end_module declarations ...
.. to modules which did not yet have them.
2022-01-09 10:36:15 +11:00
Zoltan Somogyi
0424c3f947 Specify --no-halt-at-warn-make-{int,opt}. 2021-12-26 03:10:01 +11:00
Zoltan Somogyi
943220205d Avoid using unknown formats.
deep_profiler/measurement_units.m:
    When writing out floats with given numbers of decimal places
    after the dot, use fixed format strings that the compiler can check.

deep_profiler/Mercury.options:
    Stop specifying --no-warn-unknown-format-calls for measurement_units.m.

deep_profiler/display.m:
deep_profiler/display_report.m:
    Conform to the change in measurement_units.m.

deep_profiler/html_format.m:
    Style fix.
2021-07-31 16:53:52 +10:00
Zoltan Somogyi
d854949a9c Specify --warn-potentially-ambiguous-pragma ...
as the default for the Mercury system.

configure.ac:
    Require the installed compiler to support this option.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Specify this option as the default in their directories.
2021-06-23 18:33:59 +10:00
Zoltan Somogyi
3c07fc2121 Use explicit streams in deep_profiler/*.m.
deep_profiler/analysis_utils.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/cliques.m:
deep_profiler/coverage.m:
deep_profiler/dump.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_dump.m:
deep_profiler/mdprof_procrep.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
    Replace implicit streams with explicit streams.

    In some places, simplify some code, often using constructs such as
    string.format that either did not exist or were too expensive to use
    when the original code was written.

    Consistenly use the spelling StdErr over Stderr.

    In mdbprof_dump.m, put filename and reason-for-failing-to-open-that-file
    in the right order in an error message.

deep_profiler/DEEP_FLAGS.in:
    Turn on --warn-implicit-stream-calls for the entire deep_profiler
    directory.

mdbcomp/program_representation.m:
mdbcomp/trace_counts.m:
    Replace implicit streams with explicit streams. These are the two mdbcomp
    modules that (a) used to use implicit streams, and (2) are used by the
    deep profiler.

mdbcomp/Mercury.options:
    Turn on --warn-implicit-stream-calls for these two modules.

slice/mcov.m:
slice/mtc_union.m:
    Conform to the changes in mdbcomp.
2021-03-06 18:30:50 +11:00
Julien Fischer
7cf06ffe6d Use standard names for I/O state variables.
deep_profiler/mdprof_cgi.m:
deep_profiler/timeout.m:
    As above.
2021-01-22 17:26:19 +11:00
Peter Wang
524f4d72e2 Delete references to Erlang backend in makefiles.
Mmake.workspace:
Mmakefile:
*/Mmakefile:
tests/*/Mmakefile:
tests/valid/Mmake.valid.common:
trace/Mmakefile:
    As above.
2020-10-27 11:10:11 +11:00
Peter Wang
c4c840cb7e Delete Erlang backend from configure.
configure.ac:
m4/mercury.m4:
    Delete --enable-erlang-grade configure option.

    Don't search for erlang compiler and interpreter.

    Don't substitute @ERLC@ and @ERL@.

    Don't add erlang to libgrades.

    Don't generate erlang_conf.hrl

library/erlang_conf.hrl.in:
    Delete template file.

.dockerignore:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/.gitignore:
library/Mmakefile:
library/library.m:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
scripts/Mercury.config*.in:
scripts/mercury_config.in:
scripts/prepare_install_dir.in:
ssdb/SSDB_FLAGS.in:
tools/bootcheck:
    Delete references to Erlang .hrl files.

    Delete references to @ERLC@ and @ERL@.
2020-10-27 11:10:11 +11:00
Julien Fischer
b57cfb54a5 Update references to configure.in.
configure.ac:
compiler/notes/overall_design.html:
deep_profiler/conf.m:
runtime/mercury_context.h:
runtime/mercury_goto.h:
runtime/mercury_grade.h:
runtime/mercury_regs.h:
    As above -- the configure template has been named configure.ac
    for a long time now.
2020-10-25 14:45:35 +11:00