Commit Graph

18 Commits

Author SHA1 Message Date
Julien Fischer
ac642e9ef7 Update copyright notices for 2026.
LICENSE:
compiler/print_help.m:
doc/*.texi:
profiler/mercury_profile.m:
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_Internal.c:
    As above.
2026-01-01 19:56:20 +11:00
Zoltan Somogyi
f7272d715e Clean up the structure of read_trace_counts.m a bit.
mdbcomp/read_trace_counts.m:
    Delete the mercury_trace_counts_list predicate, whose last
    (and probably only) caller was deleted in 2006. Rename the types
    and function symbols originally named after it.

    Rename the read_trace_counts_source predicate to just
    read_trace_counts_file, because the argument that specified
    where it should get trace counts from (a single file, or a
    list of files) was also deleted about two decaded ago.

    The predicate originally named read_trace_counts, which this diff
    renames to read_trace_counts_base, differed from the predicate
    now named read_trace_counts_file only in the level of detail
    they returned to their callers about any errors they found.
    As it happens, the only call to read_trace_counts_base is from
    read_trace_counts_file, because no callers need the extra info
    about errors (which they can report, but cannot do anything about).
    Therefore keep read_trace_counts_base private, and the mark it
    for future merging with read_trace_counts_file.

mdbcomp/trace_counts.m:
    Use an inst to encode an invariant in types for read_trace_counts.m.

compiler/tupling.m:
mdbcomp/slice_and_dice.m:
slice/mtc_diff.m:
    Conform to the changes above.
2025-07-30 08:11:47 +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
Julien Fischer
f8caed1263 Update copyright notices for 2025.
LICENSE:
compiler/handle_options.m:
doc/*.texi:
profiler/mercury_profile.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_internal.c:
    As above.

slice/mcov.m:
slice/mslice.m:
slice/mdice.m:
    Adjust years printed copyright notice to cover the
    entire program, not just the top-level module.
2025-01-01 15:09:38 +11:00
Julien Fischer
ee13e14ee1 Update copyright notices for 2024.
LICENSE:
compiler/handle_options.m:
doc/*.texi:
profiler/mercury_profile.m:
slice/mcov.m:
slice/mdice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_internal.c:
     As above.
2024-01-03 17:02:19 +11:00
Julien Fischer
db67618649 Fix some error reporting in slice directory.
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
    Fix spots where errors were not being printed to standard error
    and the exit status was not being set to a non-zero value.\

    Rename some predicates.

slice/mtc_diff.m:
    Fix a typo in the short usage message.
2023-10-01 17:16:22 +11:00
Julien Fischer
3513ed602c Improve usage and version messages in the slice directory.
Improve the usage and version messages for the programs in the
slice directory by:

- adding --help and --version options for programs that did
  not already have them (Mantis issue #208);
- making version and usage message consistent in form with other
  programs in the system;
- on a usage error, writing the short usage message to the standard
  error stream and setting a non-zero exit status.

This also prepares the way for creating manual pages for the programs in the
slice directory.

slice/mcov.m:
slice/mslice.m:
slice/mdice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
    As above.
2023-10-01 17:07:22 +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
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
409cbcb6a3 Unify getopt.m and getopt_io.m ...
... using an approach proposed by Peter, with an extra twist from Julien.

Instead of having two modules, getopt.m and getopt_io.m, with the former
defining predicates that do not take an I/O state pair, and the latter
defining predicates that do take an I/O state pair, put both kinds of
predicates into a single module. The versions with an I/O state pair
have an "_io" suffix added to their names for disambiguation.
Both versions are a veneer on top of a common infrastructure,
which relies on a simple type class to implement the operation
"give the contents of the file with this name". The predicate versions
with I/O state pairs have a normal implementation of this typeclass,
while the predicate versions that do not have I/O state pairs
have an implementation that always returns an error indication.

The above change just about doubles the number of exported predicates.
We already had two versions of most exported predicates that differed
in whether we returned errors in the form of a string, or in the form
of a structured representation, with names of the latter having
an "_se" suffix. Since we agreed that the structured representation
is the form we want to encourage, this diff deletes the string versions,
and deletes the "_se" suffix from the predicate names that used to have them.
(It still remains at the end of the name of a type.) This "undoubling"
should offset the effect of the doubling in the previous paragraph.

Eventually, we want to have just one module, getopt.m, containing
the updated code described above, but for now, we put the same code
into both getopt_io.m and getopt.m to prevent too big a shock to
people with existing code that uses getopt_io.m.

library/getopt.m:
library/getopt_io.m:
    Make the changes described above.

library/Mmakefile:
    Instead of building both getopt_io.m and getopt.m from getopt_template,
    build getopt.m from getopt_io.m.

tools/bootcheck:
    Delete references to getopt_template.

compiler/typecheck_errors.m:
    When a type error involves one of the getopt/getopt_io predicates
    whose interfaces are changed by this diff, tell the user about
    how these changes could have caused the error, and thus what the
    probable fix is.

compiler/handle_options.m:
browser/parse.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:
profiler/mercury_profile.m:
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
tests/hard_coded/space.m:
    Use the updated getopt interface.

compiler/compile_target_code.m:
compiler/compute_grade.m:
compiler/deforest.m:
compiler/det_report.m:
compiler/format_call.m:
compiler/globals.m:
compiler/goal_expr_to_goal.m:
compiler/make.build.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/ml_top_gen.m:
compiler/module_cmds.m:
compiler/op_mode.m:
compiler/optimization_options.m:
compiler/options.m:
compiler/write_module_interface_files.m:
tools/make_optimization_options_middle:
tools/make_optimization_options_start:
    Replace references to getopt_io.m with references to getopt.m.

tests/invalid/getopt_io_old.{m,err_exp}:
tests/invalid/getopt_old.{m,err_exp}:
tests/invalid/getopt_old_se.{m, err_exp}:
    New test cases for the extra help

tests/invalid/Mmakefile:
    Enable the new test cases.
2020-10-09 19:30:46 +11:00
Zoltan Somogyi
cbb7d8613b Make --warn-inconsistent-pred-order-clauses the default in most directories.
library/LIB_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Specify --warn-inconsistent-pred-order-clauses as a default flag
    in these directories as well.

library/string.m:
    Reorder code to make this module compile cleanly with
    --warn-inconsistent-pred-order-clauses.

    Don't export base_string_to_int_underscore to lexer.m, since
    lexer.m does not use it anymore, and neither does anything else.
    (The export was not publicly documented.)

library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/map.m:
library/profiling_builtin.m:
library/rbtree.m:
library/table_builtin.m:
library/uint.m:
profiler/globals.m:
profiler/options.m:
profiler/prof_info.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
ssdb/ssdb.m:
    Reorder code to make these modules compile cleanly with
    --warn-inconsistent-pred-order-clauses.

library/Mercury.options:
    Specify --no-warn-inconsistent-pred-order-clauses for the modules
    that would still get warnings without this option.
2019-08-27 14:34:01 +10:00
Zoltan Somogyi
22eefb3c88 Shut up determinism warnings for "sorry" fallback clauses.
Many predicates that do their jobs via foreign_procs in C have a fallback
Mercury clause for non-C backends, which usually throws an exception.
When compiled in non-C grades, these often get a warning that their
determinism declaration could have been tigther, e.g. erroneous instead of det.

*.m:
    Add no_determinism_warnings pragmas before such fallback clauses.

library/dir.m:
    As above, but also remove the unnecessary "dir." prefix on many predicate
    declarations and clause heads.
2017-08-10 18:02:42 +02:00
Zoltan Somogyi
f07145fe9a Use explicit streams in the slice directory's modules.
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
    As above.
2016-10-30 00:54:00 +11:00
Zoltan Somogyi
e6ef693a1d Convert (C->T;E) to (if C then T else E). 2015-09-27 00:28:17 +10:00
Zoltan Somogyi
0d1ac0f053 Prevent not just the deep profiler, but also the other programs in the
Estimated hours taken: 1
Branches: main

Prevent not just the deep profiler, but also the other programs in the
Mercury system from running out of stack in hlc grades.

mdbcomp/shared_utilities.m:
	A new module to contain the predicate that increases OS limits
	on stack usage as much as possible.

mdbcomp/mdbcomp.m:
	Include the new module in this package.

deep_profiler/startup.m:
	Remove the stack unlimit predicate that is now in
	mdbcomp/shared_utilities.m.

deep_profiler/Mmakefile:
slice/Mmakefile:
	Copy the new file over from mdbcomp, along with the rest of the files
	in the mdbcomp package.

compiler/mercury_compile.m:
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
	Invoke the stack unlimit predicate.

mdbcomp/prim_data.m:
	Fix a missing divider.
2012-03-27 23:29:15 +00:00
Julien Fischer
b4c3bb1387 Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3
Branches: main

Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.

analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
	Remove unused module imports.

	Fix some minor departures from our coding standards.

analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
	Set --no-warn-unused-imports for those modules that are used as
	packages or otherwise break --warn-unused-imports, e.g. because they
	contain predicates with both foreign and Mercury clauses and some of
	the imports only depend on the latter.
2006-12-01 15:04:40 +00:00
Zoltan Somogyi
863874df85 Document my recent change implementing coverage testing.
Estimated hours taken: 6
Branches: main

Document my recent change implementing coverage testing. At the same time,
eliminate the old hack that allowed a file containing a list of file names to
be considered a trace count file. We haven't needed it since the addition of
mtc_union, and it can lead to incomprensible error messages. (The presence
of the old hack made documenting coverage testing harder.)

In the process, fix the tools code for rerunning failed test cases only.

doc/user_guide.texi:
	Document my recent change implementing coverage testing, and the
	elimination of the old hack.

mdbcomp/trace_counts.m:
	Modify the predicates for reading in trace count files along the lines
	above.

mdbcomp/slice_and_dice.m:
	Modify the predicates for reading in slices and dices along the lines
	above.

	Rename some function symbols to avoid ambiguities.

compiler/tupling.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_declarative.c:
	Conform to the changes above.

slice/mcov.m:
	Fix the usage message, which referred to this program by its old name
	mct.

	Allow the output to be restricted to a set of named modules only.
	This is to make testing easier.

slice/mtc_diff.m:
	Rename the long form of the -o option from --out to --output-file,
	to make it consistent with the other programs.

tests/run_one_test:
tools/bootcheck:
	Modify the algorithm we use to gather trace counts for the Mercury
	compiler from both passed and failed test cases to run mtc_union
	periodically instead of gathering all the trace counts file and keeping
	them to the end (which takes far too much disk space).

	Fix an old bug: gather trace counts from executions of the Mercury
	compiler only.

tests/debugger/Mmakefile:
tests/debugger/dice.passes:
	Modify the dice test case to compute the union of the trace counts for
	the passed versions of this test case to use mtc_union to create
	dice.passes, instead of having dice.passes statically contain the list
	of the names of the passed trace count files (since that capability
	is deleted by this diff).

tools/bootcheck:
tests/Mmake.common:
	Fix the code for rerunning failed tests only.

mdbcomp/prim_data.m:
	Eliminate some ambiguities in predicate names.

compiler/*.m:
	Conform to the change to prim_data.m.

compiler/error_util.m:
	Add reading files as a phase in error messages.

compiler/mercury_compile.m:
	Use the new facilities in error_util for printing an error message.
2006-10-02 05:21:44 +00:00
Zoltan Somogyi
b82b599ec3 Implement coverage testing. The output format is a bit crude, but people
Estimated hours taken: 60
Branches: main

Implement coverage testing. The output format is a bit crude, but people
have been asking for this capability.

The main problem tackled in this diff is that coverage testing requires
gathering information from a lot of program executions, and the execution count
files for all these executions require a huge amount of disk space. We now
therefore put a limit on the number of files we keep; when this limit is
exceeded, the program execution that reaches the limit will automatically
summarize all these files back into a single file before it exits.

This diff also tackles the same problem along a different axis by changing
the format of execution count files to make them smaller. One way is to factor
out and represent just once some information that is common to many procedures:
the file name and the module name. Another is to abbreviate some keywords,
e.g. "fproc" instead of "proc function". The third is not to write out the
defining module's name unless it differs from the declaring module's name,
which it almost never does. (The two differ only when the compiler is invoked
with intermodule optimization, and creates a specialized version of a predicate
in a module other than its home module.)

Since we are changing the trace count file format anyway, make another change
useful for coverage testing: record the entire provenance of the trace counts
in the file, including the name of the program and what files went into unions
and diffs of trace count files.

When doing coverage testing of the compiler, the compiler *must* be in a debug
grade. However, the tools for summarizing trace files, invoked from the
compiler executable when the compiler is being coverage tested, *cannot* be
in debug grade, because debug grade disables tail recursion, and without tail
recursion the summarization program runs out of stack space. This diff
therefore arranges for the slice directory to not be affected by the parameters
applying to the rest of the workspace (including the top level Mmake.params).

Mmakefile:
	Don't apply the top level mmake's parameters to recursive mmakes in
	the slice directory.

	Factor out some common code.

configure.in:
	Require that the installed compiler contain the renamed standard
	library function names installed by my diff on Sep 20, since the
	slice directory needs them, and cannot get them from the workspace.

mdbcomp/trace_counts.m:
	Update the parsing code to parse the new format for trace count files,
	and update the code for writing out trace counts to generate the new
	format.

	Replace the proc_label_and_filename type with the proc_label_in_context
	type, which makes it easier to keep track of the current module as well
	as the current file (this is required by the new, more compact format
	for trace count files).

	When considering the union of multiple trace counts files, keep track
	of whether they contained all counts or just the nonzero counts. This
	requires keeping track of this info for single files as well.

	Provide ways to represent and to compute differences between trace
	count files, to support the new program in slice/mtc_diff.m.

mdbcomp/slice_and_dice.m:
	Reformat to conform to our Mercury style guide.

	Conform to the change to trace_counts.m.

compiler/tupling.m:
	Conform to the change to mdbcomp.

runtime/mercury_wrapper.c:
	Implement the new option values used to implement coverage testing.
	These allow control of the limit on the number of execution count
	files, and collecting execution counts only from a specified
	executable.

	Add MR_ prefixes.

runtime/mercury_trace_base.[ch]:
	Provide the mechanism for summarizing execution counts when we reach
	the limit on the number of execution counts files.

	Update the code that writes out trace counts files to generate
	the new format for trace counts files. Make this code take the boolean
	that says whether to include labels with zero counts in the output
	as an explicit parameter, not as a global variable.

	Break up an excessively large function.

scripts/mtc:
	Add the options needed to control the process of automatic
	summarization of trace counts files.

slice/.mgnuc_copts:
slice/.mgnuc_opts:
slice/SLICE_FLAGS.in:
	Make these files empty, since we don't want to refer to the rest of the
	workspace. (We could delete them as well, but CVS doesn't handle
	resurrection of deleted files very well, and we don't want to burn any
	bridges.)

slice/Mmakefile:
	Add the new executables, and make the code in this directory
	independent of the other directories in the workspace.

	Since we need the code of the modules in the mdbcomp directory
	but don't want to link to the object files in that directory (since
	the grades may differ), make copies of those modules in this directory.

slice/mcov.m:
	Add this module, the code for the Mercury coverage test tool.

slice/mtc_diff.m:
	Add this module, the code for computing the diff between two trace
	counts files. The intended use is to compare two trace counts files
	dumped at different stages of execution. (Since foreign_procs can be
	used to invoke the C functions in the runtime that write out the trace
	counts files in the middle of a program's execution, not just the end.)

slice/mdice.m:
slice/mslice.m:
slice/mtc_union.m:
	Convert to four space indentation.

tools/bootcheck:
	Since the slice directory's grade is independent of the grade of the
	other directories, don't copy it to the stage2 and stage3 by default.
	If it is copied, then still compile it (and otherwise handle it)
	separate from the other directories.

	Add an option for gathering coverage test data during bootchecking.
2006-09-22 03:50:48 +00:00