The big diff that replaced the item list with proper parse trees included code
that the compiler couldn't handle in decldebug grades, aborting with a message
about liveness mismatch between different switch arms. The problem occurred
when compiling this code in generate_missing_start_section_warning_int,
which is one arm of a switch on !.MissingStartSectionWarning:
!.MissingStartSectionWarning =
have_not_given_missing_section_start_warning,
!:MissingStartSectionWarning =
have_given_missing_section_start_warning,
Pieces = [invis_order_default_start(1), ...],
_Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(Context, [always(Pieces)])])
The problem was liveness.m's handling of the from_ground_term_construct
scope that is generated for the assigmnet of the ground term to Pieces.
compiler/liveness.m:
During the first pass through the procedure body, the liveness pass,
replace with the empty conjunction any from_ground_term_construct scopes
that construct terms to assign to dead variables. This prevents the
second pass, the deadness pass, from including the dead variable
(Pieces in the above example, after the assignment to _Spec was
optimized away by earlier passes) in the set of variables that
have been seen, since obviously, they won't be seen in the other arms.
This inclusion was the cause of the assertion failure that led to
the compiler abort.
Improve the existing debugging infrastructure to help find bugs like this,
by printing out what the selected procedure's body looks like before
as well as after the initial requantification.
compiler/quantification.m:
Replace from_ground_term_construct scopes whose ground term is assigned
to a dead variable with empty conjunctions, so that the compiler passes
between the first quantification after mode checking and the liveness
pass also see a smaller HLDS.
Implement an unrelated improvement whose possibility I discovered when
investigating why a version of the test case *without* the from_ground_term
scope wasn't getting the abort. When processing unifications, build up the
set of variables in the unification directly, not by recording a bunch
of maybe(somethings)s and then processing the somethings, if they existed,
later. This yields code that is shorter, simpler *and* faster.
tests/valid/liveness_disagree.m:
A new test case for this bug. It is a cut-down version of
generate_missing_start_section_warning_int.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
Enable the new test case, and try to compile it in a declarative debugging
grade.
compiler/assertion.m:
compiler/deep_profiling.m:
compiler/lookup_switch.m:
compiler/par_loop_control.m:
Add module qualifications in several places. I found the need for these
when I temporarily redefined the set_of_var type to use sets instead of
sparse_bitsets, to make debugging the bug in liveness.m easier; without
them, I got errors about excessive overloading.
Do some other cleanups as well.
tests/debugger/all_solutions.exp4:
tests/debugger/exception_cmd.exp3:
tests/debugger/loopcheck.exp3:
tests/debugger/uci_index.exp2:
tests/declarative_debugger/Mmakefile:
tests/declarative_debugger/builtin_call_rep.exp:
tests/declarative_debugger/catch_retry.exp:
tests/declarative_debugger/condition_bug.exp:
tests/declarative_debugger/find_origin.exp3:
tests/declarative_debugger/lpe_example.exp3:
tests/declarative_debugger/priv_builtin_bug.exp:
tests/declarative_debugger/solns.exp3:
tests/declarative_debugger/sort.exp:
tests/declarative_debugger/track_through_catch.exp:
tests/declarative_debugger/typed_unify.exp:
Update all these expected outputs for the changes in line numbers
caused by my cleanups of the test cases early in 2015.
For the declarative_debugger/{condition_bug,sort} test cases, also
update them for the change to print the types and values of foreign types.
tests/hard_coded/type_qual.{m,exp}:
This test case failed for an earlier version of this diff, so add some
context to its outputs, to make such failures easier to debug.
To make *that* easier, bring it to date in programming style.
Estimated hours taken: 2
Branches: main
Remove call depth numbers from standardized event printing. This will make
maintaining the debugger test cases easier since a lot of the expected outputs
differ only in the call depth of their events, because of deep tracing of the
standard library in the decldebug grade.
Not all the debugger tests are run with standardized event printing, so
printing of call depths will still be exercised.
tests/debugger/breakpoints.exp
tests/debugger/breakpoints.exp2
tests/debugger/browser_test.exp
tests/debugger/exception_cmd.exp
tests/debugger/exception_cmd.exp2
tests/debugger/exception_cmd.exp3
tests/debugger/exception_value.exp
tests/debugger/exception_value.exp2
tests/debugger/exception_vars.exp
tests/debugger/existential_type_classes.exp
tests/debugger/existential_type_classes.exp2
tests/debugger/exported_eqv_type.exp
tests/debugger/higher_order.exp
tests/debugger/interpreter.exp2
tests/debugger/lambda_expr.exp
tests/debugger/loopcheck.exp3
tests/debugger/loopcheck.inp2
tests/debugger/nondet_stack.exp
tests/debugger/nondet_stack.exp2
tests/debugger/polymorphic_output.exp
tests/debugger/polymorphic_output.exp2
tests/debugger/polymorphic_output.exp3
tests/debugger/print_goal.exp
tests/debugger/print_table.exp
tests/debugger/queens.exp
tests/debugger/queens.exp2
tests/debugger/resume_typeinfos.exp
tests/debugger/retry.exp
tests/debugger/retry.exp2
tests/debugger/tabled_read.exp
tests/debugger/tabled_read_decl.exp
tests/debugger/tabled_read_unitize.exp
tests/debugger/type_desc_test.exp
tests/debugger/declarative/aadebug.exp
tests/debugger/declarative/app.exp
tests/debugger/declarative/args.exp
tests/debugger/declarative/big.exp
tests/debugger/declarative/filter.exp
tests/debugger/declarative/if_then_else.exp
tests/debugger/declarative/input_term_dep.exp
tests/debugger/declarative/io_stream_test.exp
tests/debugger/declarative/io_stream_test.exp2
tests/debugger/declarative/output_term_dep.exp
tests/debugger/declarative/propositional.exp
tests/debugger/declarative/remember_modes.exp
tests/debugger/declarative/special_term_dep.exp
tests/debugger/declarative/tabled_read_decl.exp
tests/debugger/declarative/trust.exp
Remove call depth numbers from output run with standardized event
printing.
trace/mercury_trace_internal.c
Remove call depth from standardized event printing.
Estimated hours taken: 1
Branches: main
Fix some debugger test cases failing in grade decldebug because the library is
deep traced in that grade.
tests/debugger/Mmakefile
Set INP variable to inp2 for decldebug grade, so loopcheck can have
different input in this grade.
tests/debugger/all_solutions.exp4
tests/debugger/exception_cmd.exp3
tests/debugger/print_table.exp3
tests/debugger/retry.exp3
New expected outputs with the only differences the event and depth
number of some events.
tests/debugger/exception_value.exp3
This expected output had its print format set to verbose for some
reason, so overwrote this expected output with new output with flat
format (the default) and new depth/event numbers for decldebug grade.
tests/debugger/polymorphic_output.exp3
This expected output still used the non-standardized event printing,
even though the test is run with standardized event printing. So
replaced this expected outout file with the decldebug expected output.
tests/debugger/loopcheck.exp3
tests/debugger/loopcheck.inp2
Add new input that only prints events in loopcheck module, otherwise
there are just way too many events printed.