[m-dev.] diff: add new test case for compiler aborts with --no-inlining

Julien Fischer juliensf at csse.unimelb.edu.au
Wed May 30 17:05:20 AEST 2007


Add a new test case derived from valid/ho_and_type_spec_bug that causes the
compiler to abort.  This is the same bug that has been cause the
ho_and_type_spec_bug to fail in deep profiling grades.  The problem occurs in
the other grades as well but it is usually masked by the effects of inlining.

tests/valid/ho_and_type_spec_bug2.m:
tests/valid/Mercury.options:
 	A new test case (derived from ho_and_type_spec_bug) that
 	causes the compiler to abort.

compiler/Mercury.options:
 	Delete the comment saying that the workarounds for ho_and_type_spec_bug
 	can be deleted.  Mention that we must pass this new test case as
 	well before this an happen.

tests/EXPECT_FAIL_TESTS.all_grades:
 	Expect the new test case to fail.

Index: compiler/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/Mercury.options,v
retrieving revision 1.29
diff -u -r1.29 Mercury.options
--- compiler/Mercury.options	23 May 2007 09:41:42 -0000	1.29
+++ compiler/Mercury.options	30 May 2007 06:54:36 -0000
@@ -48,9 +48,7 @@

  # Bug workarounds

-# This is the same bug as tests/valid/ho_and_type_spec_bug.
-# The bug has been fixed, but the fix needs to be installed everywhere
-# before these are removed.
+# This is the same bug as tests/valid/ho_and_type_spec_bug2.
  MCFLAGS-mode_robdd.tfeirn = -O3
  MCFLAGS-mode_robdd.implications = -O0

Index: tests/EXPECT_FAIL_TESTS.all_grades
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/EXPECT_FAIL_TESTS.all_grades,v
retrieving revision 1.5
diff -u -r1.5 EXPECT_FAIL_TESTS.all_grades
--- tests/EXPECT_FAIL_TESTS.all_grades	2 May 2007 06:16:39 -0000	1.5
+++ tests/EXPECT_FAIL_TESTS.all_grades	30 May 2007 06:54:36 -0000
@@ -2,3 +2,4 @@
  hard_coded/typeclasses/complicated_constraint
  valid/constraint_prop_bug
  valid/csharp_hello
+valid/ho_and_type_spec_bug2
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.35
diff -u -r1.35 Mercury.options
--- tests/valid/Mercury.options	2 May 2007 06:16:40 -0000	1.35
+++ tests/valid/Mercury.options	30 May 2007 06:54:36 -0000
@@ -36,6 +36,7 @@
  MCFLAGS-higher_order4		= -O3
  MCFLAGS-higher_order_implied_mode = -O-1
  MCFLAGS-ho_and_type_spec_bug = -O4
+MCFLAGS-ho_and_type_spec_bug = -O3 --no-inlining
  MCFLAGS-impure_detism           = -O5 --deep-profiling
  MCFLAGS-inhibit_warn_test       = --inhibit-warnings --halt-at-warn
  MCFLAGS-intermod_bug_nested	= --intermodule-optimization
Index: tests/valid/ho_and_type_spec_bug2.m
===================================================================
RCS file: tests/valid/ho_and_type_spec_bug2.m
diff -N tests/valid/ho_and_type_spec_bug2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/ho_and_type_spec_bug2.m	30 May 2007 06:54:36 -0000
@@ -0,0 +1,52 @@
+% Compiling the following program with -O3 --no-inlining causes the following
+% assertion failure in the compiler:
+%
+% Uncaught Mercury exception:
+% Software Error: map.lookup: key not found
+%	Key Type: term.var(parse_tree.prog_data.prog_var_type)
+%	Key Value: var(16)
+%	Value Type: ll_backend.var_locn.var_state
+%
+:- module ho_and_type_spec_bug2.
+:- interface.
+
+:- type sparse_bitset(T) ---> [] ; [ int | sparse_bitset(T) ].
+
+:- type robdd(T) ---> robdd(int).
+
+:- type unit ---> unit.
+
+:- pragma type_spec(alpha/4, T = unit).
+:- pred alpha(sparse_bitset(int)::in, robdd(T)::in,
+	robdd(T)::in, robdd(T)::out) is det.
+
+:- implementation.
+
+:- typeclass foo(T) where [
+	func from_int(int) = T
+]. 
+
+:- instance foo(int) where [
+	from_int(X) = X
+].
+
+alpha(T, E, R0, R) :-
+	Closure = beta(E),
+	foldl(Closure, T, R0, R).
+
+:- pred beta(robdd(T)::in, int::in, robdd(T)::in, robdd(T)::out) is det.
+
+beta(_E, _V, _R0, R) :- R = robdd(3).
+
+:- pred foldl(pred(T, U, U), sparse_bitset(T), U, U) <= foo(T).
+:- mode foldl(pred(in, in, out) is det, in, in, out) is det.
+
+foldl(P, _, Acc0, Acc) :-
+	fold_bits(P, Acc0, Acc).
+
+:- pred fold_bits(pred(T, U, U), U, U) <= foo(T).
+:- mode fold_bits(pred(in, in, out) is det, in, out) is det.
+
+fold_bits(P, Acc0, Acc) :-
+ 	Elem = from_int(30),
+	P(Elem, Acc0, Acc).

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list