[m-rev.] for post-commit review: fix compiler abort in switch detection
Zoltan Somogyi
zs at csse.unimelb.edu.au
Fri Aug 29 15:33:08 AEST 2008
compiler/switch_detect.m:
Fix an overzealous sanity check.
tests/hard_coded/multi_arm_switch.{m,inp,exp}:
New test case to check for this bug.
tests/hard_coded/Mmakefile:
Enable the new test case.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/switch_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/switch_detection.m,v
retrieving revision 1.140
diff -u -b -r1.140 switch_detection.m
--- compiler/switch_detection.m 27 Feb 2008 07:23:15 -0000 1.140
+++ compiler/switch_detection.m 29 Aug 2008 05:13:42 -0000
@@ -385,22 +385,34 @@
!:Cases = [Case | !.Cases]
;
State = cons_id_has_one_multi,
- ( Arms = [multi_cons_id_arm(MainConsId, OtherConsIds0, Goal)] ->
- ( ConsId = MainConsId ->
+ ( Arms = [multi_cons_id_arm(MainConsId0, OtherConsIds0, Goal)] ->
+ % The code that creates multi_cons_id_arms should ensure
+ % that [MainConsId | OtherConsIds0] is sorted, and
+ % convert_cases_table should call convert_case for ConsIds
+ % in the same sorted order. In the usual case, by the time
+ % convert_case is called for any of the cons_ids in
+ % OtherConsIds, the call to convert_case for MainConsId will
+ % have put the cons_ids in OtherConsIds into
+ % !.AlreadyHandledConsIds, so we won't get here. That is when
+ % the entry for MainConsId has state cons_id_has_one_multi.
+ % However, MainConsId0 may have an entry whose state is
+ % cons_id_has_conflict. In that case ConsId will not equal
+ % MainConsId0.
+ AllConsIds0 = [MainConsId0 | OtherConsIds0],
+ % This can filter out MainConsId0.
list.filter(set_tree234.contains(ConflictConsIds),
- OtherConsIds0, _, OtherConsIds),
+ AllConsIds0, _, AllConsIds),
+ (
+ AllConsIds = [MainConsId | OtherConsIds],
Case = case(MainConsId, OtherConsIds, Goal),
set_tree234.insert_list(OtherConsIds,
!AlreadyHandledConsIds),
!:Cases = [Case | !.Cases]
;
- % The code that creates multi_cons_id_arms should ensure
- % that [MainConsId | OtherConsIds] is sorted, and
- % convert_cases_table should call convert_case for
- % ConsIds in the same sorted order. If the first elements
- % of the two lists don't match, something has gone wrong.
+ AllConsIds = [],
+ % At least, AllConsIds should contain ConsId.
unexpected(this_file, "convert_case: " ++
- "cons_id_has_one_multi: ConsId != MainConsId")
+ "cons_id_has_one_multi: AllConsIds = []")
)
;
unexpected(this_file,
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.357
diff -u -b -r1.357 Mmakefile
--- tests/hard_coded/Mmakefile 27 Aug 2008 03:58:43 -0000 1.357
+++ tests/hard_coded/Mmakefile 29 Aug 2008 04:19:08 -0000
@@ -146,6 +146,7 @@
minint_bug \
mode_check_clauses \
mode_choice \
+ multi_arm_switch \
multi_map_test \
multimode \
multimode_addr \
Index: tests/hard_coded/multi_arm_switch.exp
===================================================================
RCS file: tests/hard_coded/multi_arm_switch.exp
diff -N tests/hard_coded/multi_arm_switch.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/multi_arm_switch.exp 29 Aug 2008 01:15:13 -0000
@@ -0,0 +1,5 @@
+[1]
+[2]
+[3, 4]
+[4]
+[4]
Index: tests/hard_coded/multi_arm_switch.inp
===================================================================
RCS file: tests/hard_coded/multi_arm_switch.inp
diff -N tests/hard_coded/multi_arm_switch.inp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/multi_arm_switch.inp 27 Aug 2008 12:32:19 -0000
@@ -0,0 +1,5 @@
+cmd_quit.
+cmd_menu.
+cmd_clique.
+cmd_dump_clique.
+cmd_root.
Index: tests/hard_coded/multi_arm_switch.m
===================================================================
RCS file: tests/hard_coded/multi_arm_switch.m
diff -N tests/hard_coded/multi_arm_switch.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/multi_arm_switch.m 29 Aug 2008 05:31:03 -0000
@@ -0,0 +1,75 @@
+%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
+%
+% This is a test to check the proper functioning of the code that looks for
+% multi-cons_id switch arms in which one of the cons_ids also has its own
+% switch arm. Some old versions of the compiler had an overzealous sanity check
+% that would cause a compiler abort on this code.
+
+:- module multi_arm_switch.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module maybe.
+:- import_module require.
+:- import_module solutions.
+
+:- type t
+ ---> cmd_quit
+ ; cmd_menu
+ ; cmd_clique
+ ; cmd_dump_clique
+ ; cmd_root.
+
+main(!IO) :-
+ read_t(MaybeX, !IO),
+ (
+ MaybeX = yes(X),
+ solutions(p(X), Solns),
+ io.write(Solns, !IO),
+ io.nl(!IO),
+ main(!IO)
+ ;
+ MaybeX = no
+ ).
+
+:- pred p(t::in, int::out) is multi.
+
+p(X, N) :-
+ (
+ X = cmd_quit,
+ N = 1
+ ;
+ X = cmd_menu,
+ N = 2
+ ;
+ X = cmd_clique,
+ N = 3
+ ;
+ ( X = cmd_clique
+ ; X = cmd_dump_clique
+ ; X = cmd_root
+ ),
+ N = 4
+ ).
+
+:- pred read_t(maybe(t)::out, io::di, io::uo) is det.
+
+read_t(MaybeX, !IO) :-
+ io.read(Res, !IO),
+ (
+ Res = ok(X),
+ MaybeX = yes(X)
+ ;
+ Res = error(_, _),
+ error("I/O error")
+ ;
+ Res = eof,
+ MaybeX = no
+ ).
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list