Commit Graph

253 Commits

Author SHA1 Message Date
Julien Fischer
2c8ada3dcc Delete unused string formatting predicates.
library/string.format.m:
    Delete the old predicates for formatting ints as unsigned values;
    these are now unused.

configure.ac:
    Require the use of a compiler that does not generate references
    to the deleted predicates.

compiler/introduced_call_table.m:
    Delete the above predicates from the introduced call table.
2023-02-09 10:39:58 +11:00
Peter Wang
b0ae10248b Use --trans-opt-deps-spec option.
Use the recently added --trans-opt-deps-spec option to break cycles in
the trans-opt dependency graph for the standard library. This enables
more parallelism when making the .trans_opt files; it now takes about
half as long as before.

Ordering modules sensibly, so that .trans_opt files are created in a
logical order, also improves analysis results for many predicates and
functions. The only results which show a regression with this change are
for deprecated forwarding predicates/functions.

In future, we will probably be able to trim more dependencies to further
improve parallelism, without impacting analysis results.

configure.ac:
    Check that the bootstrap compiler supports --trans-opt-deps-spec.

library/mer_std.trans_opt_deps_spec:
    Add the spec file that adjusts dependencies in the trans-opt
    dependency graph.

library/INTER_FLAGS:
    Use the --trans-opt-deps-spec option when building with mmake.

scripts/prepare_install_dir.in:
tools/binary:
tools/bootcheck:
tools/unary:
    Copy mer_std.trans_opt_deps_spec when preparing a copy of the
    library directory.
2023-01-25 16:48:45 +11:00
Zoltan Somogyi
d4220530c9 Act on a review comment. 2022-12-30 20:01:54 +11:00
Zoltan Somogyi
05ef8e01fb Rename the .ll_debug grade component to .c_debug.
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.

runtime/mercury_grade.h:
    Rename the .ll_debug grade component to .c_debug. Also rename the C macro
    that controls the presence or absence of this grade component
    from MR_LL_DEBUG to MR_C_DEBUG_GRADE.

runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
    Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
    Previously, the name of this macro wrongly implied that it had
    something to do with the old .ll_debug grade component, even though

    - the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
      since only these existed when it was created, while

    - the .ll_debug grade component (now .c_debug) is useful only for
      MLDS grades targeting C.

compiler/options.m:
    Rename the old confusingly named low_level_debug option to c_debug_grade.
    Move it to the list of grade options, and fix its documentation, which
    was completely wrong:

    - code in compile_target_code.m treated it as being a synonym of
      the .ll_debug (now .c_debug) grade component, while
    - its (commented out) documentation here in options.m said it called for
      the enabling of what is now MR_DEBUG_THE_RUNTIME.

compiler/compile_target_code.m:
    Conform to the rename just above.

    Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.

    Pass -g to the C compiler if either c_debug_grade or target_debug
    is enabled.

    Add an XXX about a missing safety check for an obsolete experimental
    feature.

compiler/compute_grade.m:
    When given a grade with a .c_debug grade component, set only the
    c_debug_grade option; don't set the target_debug option, which is NOT
    a grade option. The change to compile_target_code.m above handles the
    only situation in which this implication was formerly required.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
    Look for and process the .c_debug grade component instead of .ll_debug.
    Use a sh variable named c_debug_grade to record its absence/presence.

    Look for and process the --c-debug-grade grade-component option,
    setting the same sh variable, c_debug_grade. (All grade components
    can be set piecemeal using sh options to the scripts using these
    subroutines.) This replaces the old, confusingly named option
    --low-level-debug.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Consistently use the sh variable c_debug to record the presence of
    the (non-grade) --c-debug option to mgnuc, and the sh variable
    c_debug_grade to record the presence of the .c_debug grade component.

    Stop looking for and handling the --low-level-debug option, which
    mgnuc used to document, even though this duplicated the same documentation
    in init_grade_options.sh-subr, which mgnuc includes. The difference was
    that init_grade_options.sh-subr meant it to represent the old .ll_debug
    MLDS grade component, while mgnuc treated it as specifying what is now
    MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
    with quite different semantics had names that differed only in an
    underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.

scripts/Mmakefile:
    Add a missing dependency to force the rebuild of mgnuc after each update
    of its sh subroutine mgnuc_file_ops.sh-subr.

doc/user_guide.texi:
    Document the --c-debug-grade option of mmc. This option was not publicly
    documented under its original misleading name (--low-level-debug), but
    its documentation is now possible without contorted dancing around the
    name.

    Clarify the documentation of mgnuc's --c-debug option.

README.sanitizers:
configure.ac:
    Conform to the rename of the grade component.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
    Conform to the rename of the grade component .ll_debug to .c_debug.

    Don't allow the .c_debug grade component in LLDS grades.

    In grade_string.m, add some obvious implications of some grade components.

grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
    Fix white space.

scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
    Conform to the change in compile_target_code.m to the naming of
    Boehm gc library variants.
2022-12-29 20:33:08 +11:00
Zoltan Somogyi
5206fc5bbc Rename hlc-low-level-debug-grades to hlc-gdb-grades.
This should help reduce confusion.
2022-12-20 00:56:13 +11:00
Zoltan Somogyi
1faa7dc914 Factor out common code in const_prop.m.
compiler/const_prop.m:
    As above.

    Handle / in both int.m and uint.m the same way as //, since / is a
    synonym of // in both modules.

    Also, handle the compile-time evaluation of plus, minus, and
    unchecked_quotient in uint.m. Previusly, we only evaluated
    their synonyms +, -, * and //.

configure.ac:
    Require the installed compiler to contain the fix for a bug that
    prevents compilation of the new code of const_prop.m in hlc grades.
2022-12-09 15:12:03 +11:00
Zoltan Somogyi
4c528d429d Add <<u and >>u to library/{int,uint}*.m ...
... along with their unchecked equivalents. These differ from <<, >> and
their unchecked equivalents in that they take the shift amount as a uint,
instead of an int.

library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/uint.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
    As above. The unchecked versions have only declarations, since
    these operations have been recognized as builtins for a while now.

NEWS:
    Document the new operations, and the recent change to recognize
    <<u and >>u as single tokens, and fix a typo in a recent addition.

configure.ac:
    Require the compiler to be sufficiently recent to be able to parse
    <<u and >>u as operators.

compiler/options.m:
    Provide a way for a later change to configure.ac to detect the presence
    of this change.

tests/hard_coded/bitwise_int.exp:
tests/hard_coded/bitwise_int.exp2:
tests/hard_coded/bitwise_int.m:
tests/hard_coded/bitwise_int16.exp:
tests/hard_coded/bitwise_int16.m:
tests/hard_coded/bitwise_int32.exp:
tests/hard_coded/bitwise_int32.m:
tests/hard_coded/bitwise_int64.exp:
tests/hard_coded/bitwise_int64.m:
tests/hard_coded/bitwise_int8.exp:
tests/hard_coded/bitwise_int8.m:
tests/hard_coded/bitwise_uint.exp:
tests/hard_coded/bitwise_uint.exp2:
tests/hard_coded/bitwise_uint.m:
tests/hard_coded/bitwise_uint16.exp:
tests/hard_coded/bitwise_uint16.m:
tests/hard_coded/bitwise_uint32.exp:
tests/hard_coded/bitwise_uint32.m:
tests/hard_coded/bitwise_uint64.exp:
tests/hard_coded/bitwise_uint64.m:
tests/hard_coded/bitwise_uint8.exp:
tests/hard_coded/bitwise_uint8.m:
    Check that <<u and >>u compute the same results as << and >> respectively.
2022-12-07 23:12:33 +11:00
Peter Wang
36f51d1445 Use value of MACOSX_DEPLOYMENT_TARGET by default.
On MacOS, make configure use the value of MACOSX_DEPLOYMENT_TARGET as
the default deployment target (if set), otherwise falling back to the
host system version.

configure.ac:
    As above.

README.MacOS:
NEWS:
    Document the change.
2022-11-29 12:09:54 +11:00
Julien Fischer
dddf3dd58f Avoid a configure abort with MSVC.
configure.ac:
    The AC_PROG_LEX macro we use to detect flex does not work with MSVC.
    Avoid its use if we are using MSVC.
2022-11-09 21:52:19 +11:00
Zoltan Somogyi
5b2f6e533b Disable unknown_format_call warnings using scopes.
configure.ac:
    Require the installed compiler to support disable_warning scopes
    for unknown_format_calls.

compiler/Mercury.options:
library/Mercury.options:
    Do not disable unknown_format_call warnings in whole files.

compiler/parse_tree_out_info.m:
compiler/pd_debug.m:
library/io.m:
library/stream.string_writer.m:
library/string.m:
    Disable unknown_format_call warnings for just the format calls
    that need it.
2022-09-07 12:18:19 +10:00
brendanzab
72ceba7afa Allow STRIP_EXE to be overriden on Darwin
configure.ac:
    Use the AC_CHECK_TOOL macro to search for the strip command on the
    PATH. This is more consistent with how other commands are configured
    (eg. ar and nm).
2022-08-18 14:13:30 +10:00
Julien Fischer
40401a6b5c Fix hlc test failures with GCC 12.
GCC 12 has new warning, -Winfinite-recursion, that is being triggered by six
tests in the directory tests/valid when compiled in high-level C grades. Since
we also enable -Werror, this is causing these test to fail. Fix these failures
by either removing the infinite recursion from them or by disabling the new GCC
warning for the affected test cases.

configure.ac:
tests/DEFNS_FOR_TESTS.in:
    Define a variable whose value is the option for disabling GCC's infinite
    recursion check.

tests/valid/higher_order5.m:
tests/valid/stack_alloc.m:
    Modify these tests so they do not trigger the infinite recursion warning
    in GCC (or Mercury for that matter).

tests/valid/mode_syntax.m:
tests/valid/same_length_2.m:
    Merge these two tests (under the first name) since they both test the same
    thing.  Delete the same_length_2 version.

tests/valid/Mmakefile:
    Conform to the above deletion.

tests/valid/Mercury.options:
    Include DEFNS_FOR_TESTS here so that mmc --make can see it.

    Disable GCC's infinite recursion check for those tests that trigger
    it.

    Shut up a bunch Mercury warnings for the mode_syntax test case that
    are unrelated to what is actually being tested.
2022-07-04 11:01:13 +10:00
Julien Fischer
04c0ead697 Workaround Github issue #103.
The basic block vectorizer optimisation in GCC 11 and 12 is generating code
that causes segmentation faults in grades that use non-local gotos.
As a workaround, disable that optimisation for GCC 11 and later.
(While this problem has presumably always existed for GCC 11, it has not shown
up previously because the affected optimisation is only enabled at -O3; with
GCC 12 it is enabled by default. GCC 10 and earlier do not appear to be
affected.)

configure.ac:
     Add the above workaround.
2022-06-25 21:49:39 +10:00
Julien Fischer
3f225fb4a5 Fix more bad configure escaping.
configure.ac:
    As above.
2022-06-19 00:58:33 +10:00
Julien Fischer
fb8aa65071 Escape square brackets in configure properly.
configure.ac:
    As above.
2022-06-19 00:46:46 +10:00
Julien Fischer
e0c7eedb49 Fix Github issue #102.
Avoid the use of the GCC option -Warray-bounds with GCC version 12 and later.

configure.ac:
scripts/mgnuc.in:
    As above.

NEWS:
    Announce the fix.
2022-06-18 20:12:03 +10:00
Peter Wang
5c8e0c6fce Disable non-local gotos on AArch64 with GCC 9+.
Programs using non-local gotos on AArch64 crash when compiled with
newer versions of GCC:

    gcc 6.3.0 (Debian 9) - ok
    gcc 8.3.0 (Debian 10) - ok
    gcc 9.3.0 (Debian 11) - crash
    gcc 10.2 (Debian 11) - crash

Specifically, the programs only crash when compiled with PIC,
but PIC is commonly the default now.

This is Mantis bug #560.

configure.ac:
    Disable non-local gotos on AArch64 when using GCC 9+.

README.Linux-aarch64:
    Mention the problem.
2022-06-01 12:07:43 +10:00
Zoltan Somogyi
b70ff36def Fix comments. 2022-03-26 03:07:32 +11:00
Julien Fischer
d0f22be99e Avoid spurious warnings from GCC.
As mentioned recently on the developers list, GCC versions 9 10 and 11 are
emitting suprious warnings with -Warray-bounds for the specialised code they
introduce for strcmp etc. Disable that warning for those versions of GCC. In
addition to this issue, according to the GCC bug database is is generating a
lot of false positives anyway.

configure.ac:
scripts/mgnuc.in:
    As above.
2022-03-05 22:39:10 +11:00
Peter Wang
f5b4f67d1a Check for gcc generating PIC by default.
In configure, we try detect the non-working combination of gcc 5+,
targeting x86, PIC, and non-local gotos. We assumed that PIC is only
generated when creating shared libraries, but gcc may have been
configured to generate PIC by default. This is very common on more
recent Linux distributions.

configure.ac:
    Extend the test mentioned above: if shared libraries are disabled,
    check whether gcc generates PIC anyway.

    Clean up the code a little.

m4/mercury.m4:
    Add helper macros MERCURY_CC_TARGETS_X86 and
    MERCURY_CC_GENERATES_PIC.

README.x86:
    Update this document.
2022-02-25 13:43:15 +11:00
Julien Fischer
02b502d2c7 Minor fix for configure script.
configure.ac:
    Delete reference to "MC_ERROR", which isn't a thing.
2022-02-09 22:18:00 +11:00
Zoltan Somogyi
77b7626316 Avoid misleading error message. 2022-02-09 12:23:20 +11:00
Zoltan Somogyi
07ffbce8e7 Implement --warn-sdtlib-shadowing.
compiler/mercury_compile_main.m:
    I added that option a week or so ago, but at that time, it did nothing.
    This diff implements the warning.

library/LIB_FLAGS.in:
    Disable the warning for the modules in the library directory.

configure.ac:
    Require the installed compiler to recognize the option, since without this,
    library/LIBFLAGS won't work.

tests/warnings/profiling_builtin.{m,exp}:
tests/warnings/time.{m,exp}:
tests/warnings/time.subtime.m:
    Two test cases for the warning. One, time, shadows the name of
    a documented library module, the other, profiling_builtin,
    shadows the name an undocumented library module.

    The purpose of time.subtime is to test the message when the module name
    *contains* a stdlib module name, but is not *identical* to it.

tests/warnings/Mmakefile:
    Do *not* turn on the new test cases, but do document why we do not do so.
2022-01-08 04:41:55 +11:00
Zoltan Somogyi
81f43b401f Require an up-to-date compiler. 2021-12-26 18:45:02 +11:00
Peter Wang
ae95a01155 Enable munmap support in Boehm GC by default.
configure:
    Change default value of enable_gc_mmap and enable_gc_munmap to yes.

    Invert sense of --enable-gc-mmap and --enable-gc-munmap options in
    the help text.

NEWS:
    Announce change.
2021-12-07 11:12:18 +11:00
Julien Fischer
19d4aee81a Avoid warnings from autoconf.
configure.ac:
     Use single quotes for quoting in configure script messages.
     Using `' results in warnings from autoconf.

     Delete a stray comma from the test for GNU make.
2021-06-26 20:32:58 +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
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
Julien Fischer
65f78b8e7e Replace more deprecated autoconf macros.
configure.ac:
    As above.
2021-06-05 01:08:26 +10:00
Julien Fischer
dc45a7082f Apply more suggestions from autoupdate.
configure.ac:
    As above.
2021-05-30 03:04:22 +10:00
Julien Fischer
02375907ac Fix argument quotation problems in the configure script.
According to the changelog for autoconf 2.70, many macros have become pickier
about argument quotation.  Add quotes to the configure script to avoid these
problems.

Delete unnecessary use of changequote (whose use the autoconf manual recommends
against anyway.)

configure.ac:
    As above.
2021-05-30 02:47:47 +10:00
Julien Fischer
567704838b Replace deprecated autoconf variables.
configure.ac:
    As above.
2021-05-29 21:12:42 +10:00
Julien Fischer
62a82af1ef Avoid another deprecated autoconf macro.
configure.ac:
    As above.
2021-05-29 04:45:35 +10:00
Julien Fischer
ff452e7040 Undo my last commit.
configure.ac:
    As above -- this broke the configure script on some of my
    test systems.
2021-05-29 04:38:23 +10:00
Julien Fischer
f4bdd2c0a9 Avoid more warnings from autoconf.
configure.ac:
    Do not escape quotes; autoconf 2.70 emits warnings about it
    by default.
2021-05-29 04:07:28 +10:00
Julien Fischer
ee44858b22 Replace more deprecated autoconf macros.
configure.ac:
     As above; the updates were done using the autoupdate script.
2021-05-29 03:48:12 +10:00
Julien Fischer
9e1f42f484 More obsolete autoconf macro replacement.
configure.ac:
    As above; most of these updates were done by the autoupdate
    script.
2021-05-25 21:38:56 +10:00
Julien Fischer
28cc1233a6 Avoid another deprecated autoconf macro.
configure.ac:
    The use of AC_OUTPUT with arguments is deprecated; replace
    it with what is recommended in the autoconf manual.
2021-05-24 21:30:12 +10:00
Julien Fischer
6d80e4c573 Add a note about autoconf 2.70+.
configure.ac:
    As above.
2021-05-24 20:59:07 +10:00
Julien Fischer
959b966533 Avoid another deprecated autoconf macro.
configure.ac:
    Replace the use of AC_FD_MSG with AS_MESSAGE_FD.
2021-05-24 19:04:11 +10:00
Julien Fischer
75e0251d43 Replace another deprecated autoconf macro.
configure.ac:
     Replace the use of the deprecated AC_PROGRAMS_CHECK macro
     with AC_CHECK_PROGS.
2021-05-24 18:59:28 +10:00
Julien Fischer
b28dcccad6 Avoid more deprecated autoconf macros.
configure.ac:
     s/AC_FD_CC/AS_MESSAGE_LOG_FD/

INSTALL.git:
    Bump the minimum required version of autoconf.
2021-05-24 18:45:33 +10:00
Julien Fischer
0383491264 Avoid the use of a deprecated autoconf macro.
configure.ac:
    Use AC_CONFIG_HEADERS in place of the deprecated AC_CONFIG_HEADER.
2021-05-24 18:24:27 +10:00
Julien Fischer
bc20b3193b Fix problems with recent versions of autoconf.
configure.ac:
    Require at least autoconf 2.69 (released 2012).

    Avoid a warning about an obsolete macro from autoconf 2.70 onwards:
    s/AC_HELP_STRING/AS_HELP_/STRING/
2021-05-24 18:16:47 +10:00
Peter Wang
e5c89216a3 Avoid potential loop when checking for SIGSEGV signal handling.
configure.ac:
    Detect a signal handler being invoked over and over in a loop for a
    single SIGSEGV signal; fail the test in that case.

    This has been observed on Ubuntu 18.04.5 amd64 (running on a VPS),
    when using gcc -m32 to target x86. As far as I understand, this is
    not supposed to happen, so it is probably a bug.
2021-05-10 15:21:22 +10:00
Peter Wang
6a18491e03 Further prevent use of non-local gotos with PIC on x86 with GCC 5+.
configure.ac:
    Run the C compiler to check if it actually targets x86-64.
    Previously we assumed if $host is x86_64 then the C compiler will be
    targeting x86-64, but that is not true if gcc -m32 or gcc -mx32 is
    used.

    Then, as before, if the C compiler targets x86 and dynamic linking
    is enabled (except on Windows) and GCC is version 5+ then disable
    selection of any grades that use gcc labels.

runtime/mercury_goto.h:
    Report an error if the user tries to use non-local gotos with PIC
    on x86 with GCC 5+.

README.x86:
    Document the issue.

README.md:
    Add reference to README.x86.
2021-05-10 15:21:04 +10:00
Julien Fischer
4abc9b550e Support asm_fast grades on aarch64 Linux.
configure.ac:
    Set CFLAGS_FOR_GOTOS appropriately for aarch64 Linux.
2021-01-23 17:17:47 +11:00
Julien Fischer
bd298e68dd Fix a cut-and-paste error.
configure.ac:
    Compile with -fomit-frame-pointer on aarch64, not
    its negation.
2021-01-14 02:30:28 +11:00
Julien Fischer
84b561a2a0 Use global registers on aarch64.
runtime/machdeps/aarch64_regs.h:
runtime/mercury_regs.h:
     Define global registers for aarch64.

configure.ac:
     Compile with -fomit-frame-pointer on aarch64.  (Doing so frees
     up register x29.)

     Compile with -fPIC instead of -fpic on aarch64-*-linux* systems
     in order to avoid size limits on the global offset table.
2021-01-13 14:22:21 +11:00
Zoltan Somogyi
63dabcfcf8 Fix filling in partial terms that use direct_arg tags.
This fix uses the approach discussed on m-dev 2020 nov 16/17 for fixing
github issue #72, whose core problem is a need for information flow
back to a the caller from a callee when the callee fills in the
argument of a function symbol whose representation is a direct_arg tag.
In most cases when the callee fills in the value of an argument,
the caller can see it because the argument is in a word on the heap,
but when the function symbol uses a direct_arg tag, that is not the case.

compiler/direct_arg_in_out.m:
    A new module that implements the transformation proposed on m-dev.
    It creates a fresh clone variable every time an argument of a direct_arg
    tag function symbol is (or may be) updated. This can happen several
    times if a type has more than one function symbol with a direct_arg tag.
    Since the affected variable can be bound to only one function symbol
    at the start, its argument can be filled in only once, but the
    compiler cannot know in advance what function symbol the variable
    contains, and therefore which of the possibly several fill-in sites
    (which fill in the arguments of different function symbols) executed
    in sequence will actually update the variable.

    The transformation ensures that once a variable is cloned, it is
    never referred to again. It also ensures that in a branched control
    structure (if-then-else, disjunction or switch), all branches will use
    the *same* variable to represent the latest version of each cloned
    variable at the end, so that following code has a consistent view
    regardless of through which branch execution has reached it.

    There are three situations that the transformation cannot and does not
    handle.

    1. Situations in which the mode of an argument is either an inst variable,
       or an abstract inst. In either case, the pass cannot know whether
       it should apply its transformation to the argument.

    2. Situations where a procedure that has such an argument is
       exported to C code as a function. In that case, the C signature
       of the function we would generate would be different from what
       the user would normally expect. We could modify the documentation
       of the export pragma, but I don't think there much point due to
       lack of demand. (The problem cannot arise when targeting any language
       other than C, because we use direct_arg tags only with the low level
       data representation, which we only use for C.)

    3. Situations where a procedure that has such an argument is defined
       by foreign_proc. Again, dealing with the problem would require
       nontrivial changes to the documented interface between code in
       foreign_procs and the surrounding Mercury code, and I see no demand
       for code that could benefit from that.

    In these cases, this module generates error messages.

compiler/transform_hlds.m:
    Include the new module in the transform_hlds package.

    Delete unnecessary module qualification on some existing inclusions.
    Put some existing inclusions into a more meaningful order.

compiler/notes/compiler_design.html:
    Document the new pass. Fix some nearby prose.

compiler/lambda.m:
compiler/simplify_proc.m:
    Use a predicate exported by direct_arg_in_out.m to test, for each
    procedure, whether the procedure has any argument positions that are
    subject to the problem that direct_arg_in_out.m addresses.
    simplify_proc.m does this for all procedures it processes;
    lambda.m does this for all the procedures it creates from
    lambda expressions.

    Give a predicate in simplify_proc.m a better name.

    Sort a list of predicate names.

compiler/hlds_module.m:
    Add a field to the module_info that simplify_proc.m and lambda.m
    can use to tell direct_arg_in_out.m what work (if any) it needs to do.

compiler/mercury_compile_middle_passes.m:
    Invoke direct_arg_in_out.m if the new field in the HLDS indicates
    that it has some work to do. (In the vast majority of compiler invocations,
    it won't have any.)

compiler/hlds_pred.m:
    The new code in direct_arg_in_out.m creates a clone of each procedure
    affected by the problem, before deleting the originals (to make sure that
    no references to the unfixed versions of now-fixed procedures remain.)
    Make it possible to create exact clones of both predicates and procedures
    by adding two pairs of predicates, {pred,proc}_prepare_to_clone and
    {pred,proc}_create.

    Add the direct_arg_in_out transformation as a possible source
    of transformed predicates.

library/private_builtin.m:
    Add a new builtin operation, partial_inst_copy, that the new module
    generates calls to.

configure.ac:
    Require the installed compiler to recognize partial_inst_copy
    as a no_type_info builtin.

compiler/builtin_ops.m:
    Recognize the new builtin. (This was committed before the rest; the diff
    to private_builtin.m can be done only once the change to builtin_ops.m
    is part of the installed compiler.)

compiler/options.m:
    Add a way to test whether the builtin_ops.m in the installed compiler
    recognizes the new builtin.

compiler/dead_proc_elim.m:
    Do not delete the new primitive before direct_arg_in_out.m has had
    a chance to generate calls to it.

    Add an XXX.

compiler/error_util.m:
    Recognize the new module as a source of error messages.

compiler/pred_table.m:
    Add a pair of utility predicates to be used when looking up
    builtin predicates, for which the compiler writer knows that
    there should be exactly one match. These are used in direct_arg_in_out.m.

compiler/simplify_goal_call.m:
    Replace some existing code with calls to the new predicates
    in pred_table.m.

compiler/hlds_goal.m:
    Add modes to rename_vars_in_goal_expr that express the fact
    that when an atomic goal_expr has some variables renamed inside it,
    it does not suddenly become some *other* kind of goal_expr.
    New code in direct_arg_in_out.m relies on this.

compiler/hlds_out_goal.m:
    When the HLDS we are dumping out is malformed because it contains
    calls to predicates that have been deleted, the compiler used to abort
    at such calls. (I ran into this while debugging direct_arg_in_out.m.)

    Fix this. When such calls are encountered, we now print out as much
    information we can about the call, and prefix the call with an
    unmistakable prefix to draw attention to the problem.

compiler/inst_util.m:
    Fix a bug that prevented direct_arg_in_out.m from even being invoked
    on some test code for it.

    The bug was in code that we use to unify a headvar's initial inst
    with its final inst. When the initial inst was a non-ground bound_inst
    such as the ones used in tests/hard_coded/gh72.m, and the final inst
    was simply "ground", this code quite properly returned a bound_inst
    (which, unlike ground, can show the exact set of function symbols
    that the headvar could be bound to). The problem was that it
    reused the original bound_inst's test results, including the one
    that said the final inst is NOT ground, which of course is wrong
    for any inst unified with ground. Fix two instances of this bug.

compiler/modes.m:
    Make some of the code I had to traverse to find the bug in inst_util.m
    easier to read and understand.

    Replace some uses of booleans with bespoke enum types.

    Change the argument lists of some predicates to put related arguments
    next to each other.

    Give some variables more descriptive names.

compiler/layout_out.m:
    Conform to the change in hlds_pred.m.

compiler/var_locn.m:
    Fix a code generation bug. When filling-in the value of the argument
    of a function symbol represented by a direct_arg tag, the code we
    generated for it worked only if the direct_arg tag used 0
    as its ptag value. In the test cases we initially used for
    github issue 72, that was the case, but the new tests/hard_coded/gh72.m
    has direct_tag args that use other ptag values as well.

    Document the reason why the updated code works.

compiler/term_constr_initial.m:
    Add the new primitive predicate added to private_builtin.m,
    partial_inst_copy, to a table of builtins that do not take type_infos,
    even though their signatures contain type variables.

    Fix a bunch of old bugs: most other such primitives were not listed
    either.

mdbcomp/program_representation.m:
    Add partial_inst_copy to the master list of builtins that do not take
    type_infos even though their signatures contain type variables. (Done
    by an earlier commit.)

    Document the fact that any updates here require updates to
    term_constr_initial.m.

library/multi_map.m:
    We have long had multi_map.add and multi_map.set as synonyms,
    but we only had multi_map.reverse_set. Add multi_map.reverse_add
    as a synonym for it.

    Define the "set" versions in terms of the "add" versions,
    instead of vice versa.

NEWS:
    Document the new predicates in multi_map.m.

tests/hard_coded/gh72a.m:
    Fix typo.

tests/hard_coded/gh72.{m,exp}:
    A new, much more comprehensive test case than gh72a.m.
    This one tries to tickle github issue 72 in as many forms of code
    as I can think of.

tests/invalid/gh72_errors.{m,err_exp}:
    A test case for testing the generation of error messages for
    two out of the three kinds of situations that direct_arg_in_out.m
    cannot handle. (Proposals for how to test the third category welcome.)

tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
    Enable the two new test cases, as well as two old ones, gh72[ab].m,
    that previously we didn't pass.

tests/invalid/Mercury.option:
    Do not compile gh72_error.m with --errorcheck-only, since its errors
    are reported by a pass that --errorcheck-only does not invoke.
2021-01-13 05:35:40 +11:00