mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 11:53:51 +00:00
Fix github issue #89.
The current source-to-source debugger transformation cannot handle the
predicates introduced by higher-order specialization. There are likely similar
issues with other HLDS->HLDS transformations.
The fix (for now) is to disable most HLDS->HLDS transformations in .ssdebug
grades.
compiler/handle_options.m:
Disable most HLDS->HLDS optimizations when the ss-trace level is
shallow or deep.
Add an XXX comment about a separate issue.
compiler/ssdebug.m:
Add an XXX comment about predicates produced by higher-order
specialization.
tests/WS_FLAGS.ws:
Add a missing include.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/gh89.m:
Add the test case from github issue 89.
This commit is contained in:
@@ -1635,8 +1635,32 @@ convert_options_to_globals(OptionTable0, OpMode, Target, GC_Method,
|
||||
add_error(phase_options, TraceHLSpec, !Specs)
|
||||
),
|
||||
|
||||
% Source-to-source debugging requires disabling many HLDS->HLDS
|
||||
% optimizations. This is so that the trace being generated relates to the
|
||||
% source code and also because the SSDB transformation cannot (yet) handle
|
||||
% the specialised predicates introduced by many optimizations.
|
||||
(
|
||||
( SSTraceLevel = shallow
|
||||
; SSTraceLevel = deep
|
||||
),
|
||||
globals.set_option(allow_inlining, bool(no), !Globals),
|
||||
globals.set_option(optimize_unused_args, bool(no), !Globals),
|
||||
globals.set_option(optimize_higher_order, bool(no), !Globals),
|
||||
globals.set_option(type_specialization, bool(no), !Globals),
|
||||
globals.set_option(user_guided_type_specialization, bool(no),
|
||||
!Globals),
|
||||
globals.set_option(deforestation, bool(no), !Globals),
|
||||
globals.set_option(constraint_propagation, bool(no), !Globals),
|
||||
globals.set_option(local_constraint_propagation, bool(no), !Globals),
|
||||
globals.set_option(optimize_duplicate_calls, bool(no), !Globals),
|
||||
globals.set_option(optimize_constructor_last_call, bool(no), !Globals)
|
||||
;
|
||||
SSTraceLevel = none
|
||||
),
|
||||
|
||||
% The pthreads headers on some architectures (Solaris, Linux)
|
||||
% don't work with -ansi.
|
||||
% XXX we don't pass -ansi to the C compiler anymore.
|
||||
option_implies(parallel, ansi_c, bool(no), !Globals),
|
||||
|
||||
option_neg_implies(inline_builtins, constant_propagation, bool(no),
|
||||
|
||||
@@ -1035,6 +1035,8 @@ ssdebug_process_proc_erroneous(SSTraceLevel, PredId, ProcId,
|
||||
list(prog_var)::out, list(prog_var)::out, list(mer_mode)::out) is det.
|
||||
|
||||
get_stripped_headvars(PredInfo, ProcInfo, FullHeadVars, HeadVars, ArgModes) :-
|
||||
% XXX using orig_arity here does not work when the predicate is one
|
||||
% produced by higher-order specialization. See tests/valid/gh89.m.
|
||||
PredArity = pred_info_orig_arity(PredInfo),
|
||||
proc_info_get_headvars(ProcInfo, FullHeadVars),
|
||||
proc_info_get_argmodes(ProcInfo, FullArgModes),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
-I@WORKSPACE@/library
|
||||
-I@WORKSPACE@/browser
|
||||
-I@WORKSPACE@/mdbcomp
|
||||
-I@WORKSPACE@/ssdb
|
||||
--c-include-directory @WORKSPACE@/boehm_gc
|
||||
--c-include-directory @WORKSPACE@/boehm_gc/include
|
||||
--c-include-directory @WORKSPACE@/runtime
|
||||
|
||||
@@ -54,6 +54,9 @@ MCFLAGS-exists_cast_bug = --trace rep -O0 --optimize-saved-vars-const
|
||||
MCFLAGS-explicit_quant = --halt-at-warn
|
||||
MCFLAGS-foreign_underscore_var = --halt-at-warn
|
||||
MCFLAGS-fzn_debug_abort = --trace rep
|
||||
# XXX we should pass --ssdb-trace deep or --ss-debug to gh89
|
||||
# but that currently doesn't work in non ssdb grades.
|
||||
MCFLAGS-gh89 = --intermodule-optimization -O3 --no-warn-missing-opt-files
|
||||
MCFLAGS-higher_order4 = -O3
|
||||
MCFLAGS-higher_order_implied_mode = -O-1
|
||||
MCFLAGS-ho_and_type_spec_bug = -O4
|
||||
|
||||
@@ -135,6 +135,7 @@ OTHER_PROGS = \
|
||||
func_default_modes \
|
||||
func_in_head \
|
||||
gh65 \
|
||||
gh89 \
|
||||
github_50 \
|
||||
hawkins_switch_bug \
|
||||
headvar_not_found \
|
||||
|
||||
59
tests/valid/gh89.m
Normal file
59
tests/valid/gh89.m
Normal file
@@ -0,0 +1,59 @@
|
||||
%---------------------------------------------------------------------------%
|
||||
% vim: ts=4 sw=4 et ft=mercury
|
||||
%---------------------------------------------------------------------------%
|
||||
%
|
||||
% This is a regression test for github issue #89.
|
||||
%
|
||||
% Any copyright is dedicated to the Public Domain.
|
||||
% https://creativecommons.org/publicdomain/zero/1.0/
|
||||
%
|
||||
% Released by Transnat Games for testing purposes.
|
||||
%
|
||||
% Crashes with the following compiler flags:
|
||||
% mmc --make crash -O 6 --intermodule-optimization --use-grade-subdirs \
|
||||
% --grade=hlc.gc.spf.ssdebug
|
||||
%
|
||||
% Crashes as:
|
||||
% Making Mercury/hlc.gc.spf.ssdebug/x86_64-unknown-openbsd6.5/Mercury/cs/crash.c
|
||||
% Uncaught Mercury exception:
|
||||
% Software Error: list.m: predicate `list.det_drop'/3: Unexpected: index out of range
|
||||
% ** Error making `Mercury/hlc.gc.spf.ssdebug/x86_64-unknown-openbsd6.5/Mercury/cs/crash.c'.
|
||||
%
|
||||
% The crash requires an optimization level (I'm not sure which, 1 is fine but 6
|
||||
% is not), intermodule optimizations, grade subdirs, and an ssdebug grade.
|
||||
%
|
||||
%---------------------------------------------------------------------------%
|
||||
%
|
||||
% The cause of the abort is the the source-to-source debugging transformation
|
||||
% does not understand how to process the specializations produced by the
|
||||
% higher-order optimization. Until it does, we have disabled the use of that
|
||||
% optimization (and a bunch of others) by default with source-to-source
|
||||
% debugging.
|
||||
%
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
:- module gh89.
|
||||
:- interface.
|
||||
|
||||
:- use_module array.
|
||||
|
||||
:- pred measure(array.array(int)::in, int::out, int::out) is det.
|
||||
|
||||
%---------------------------------------------------------------------------%
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
:- implementation.
|
||||
|
||||
%------------------------------------------------------------------------------%
|
||||
|
||||
:- pred measure(_, int, int, int, int).
|
||||
:- mode measure(in, in, out, in, out) is det.
|
||||
|
||||
measure(_, W, W, H, H).
|
||||
|
||||
%------------------------------------------------------------------------------%
|
||||
|
||||
measure(Glyphs, W, H) :-
|
||||
% There has to be something that actually uses the first argument to this
|
||||
% predicate, otherwise the crash doesn't happen.
|
||||
array.foldl2(measure, Glyphs, 0, W, 0, H).
|
||||
Reference in New Issue
Block a user