[m-dev.] stage 2 broken with --intermod-opt and -O5
Zoltan Somogyi
zoltan.somogyi at runbox.com
Thu Jul 23 09:06:12 AEST 2026
On Thu, 23 Jul 2026 00:26:11 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> Bootchecking in asm_fast.gc with --intermod-opt and -O5 is broken
> on testing.mercurylang. Bootchecking on my machine yields the following
> during stage 2 compilation
>
> gmake[1]: *** [/tmp/mmake.X8Q1BL:572631:
> hlds.make_hlds.make_hlds_passes.c_date] Error 1
> gmake[1]: *** Waiting for unfinished jobs....
> ...
> Uncaught Mercury exception:
> Software Error: map.lookup: key not found
> Key Type: term.var(parse_tree.prog_data.prog_var_type)
> Key Value: var(12)
> Value Type: ll_backend.var_locn.var_state
> Stack dump not available in this grade.
>
> The last ROTD that worked appears to be rotd-2026-07-13.
The bug was tickled, but not caused by, the diff I committed
the next day replacing many diag_specs with err_specs, warn_specs,
and/or info_specs.
The bug occurs in deforestation, as shown by the attached HLDS dumps.
The predicate involved was created by higher order specialization,
which specialized the call to list.filter on line 179 of make_hlds_passes.m
to the higher order constant a few lines above. Inlining then inlined
the call to extract_spec_phase. All good so far. But the next phase,
deforestation, deleted the whole inlined body. Since that body
was the generator of Phase (which was variable 12), the test whether
Phase was bound to phase_tim_check_invalid_inst_mode caused
the code generator to abort.
I tried to create a cut-down version of the problematic setup, attached
as y[12].m, but it does not exhibit the problem. In this case, deforestation
pushes the test for its equivalent of Phase into each arm of its equivalent
of extract_spec_phase, instead of deleting the inlined code of extract_spec_phase.
I don't know what the relevant difference is, do any of you guys?
I would guess that disabling deforestation just for make_hlds_passes.m
would work around this bug.
Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hlds.make_hlds.make_hlds_passes.hlds_dump.155-deforestation
Type: application/octet-stream
Size: 6632 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20260723/fd918624/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hlds.make_hlds.make_hlds_passes.hlds_dump.148-mark_static
Type: application/octet-stream
Size: 11314 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20260723/fd918624/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: y1.m
Type: text/x-objcsrc
Size: 620 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20260723/fd918624/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: y2.m
Type: text/x-objcsrc
Size: 499 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20260723/fd918624/attachment-0003.bin>
More information about the developers
mailing list