[m-rev.] diff: fix failure tests/tabling/memo_non

Julien Fischer juliensf at cs.mu.OZ.AU
Wed May 4 11:29:04 AEST 2005


(This test causes an assertion failure in the runtime in .profdeep
grades - this diff doesn't deal with that though).

Estimated hours taken: 0.5
Branches: main

Fix the test case tests/tabling/memo_non which was failing at the higher
levels of optimization, e.g. -O5, because the compiler was pushing the
call to marker/4 into the 'then' branch of the if-then-else (which is
the only place that actually uses the output of marker/4).  The reason
that this has started happening is that I recently modified the compiler
to take account of the default termination/exception properties of
foreign procs during optimization passes and marker/4 fulfills all the
criteria for something that the compiler thinks it can reorder
The fix is to make marker/4 impure.

tests/tabling/memo_non.m:
	Make marker/4 impure, so that the compiler doesn't
	reorder it at higher optimization levels.

Julien.

Workspace:/home/aral/juliensf/tests
Index: memo_non.m
===================================================================
RCS file: /home/mercury1/repository/tests/tabling/memo_non.m,v
retrieving revision 1.1
diff -u -r1.1 memo_non.m
--- memo_non.m	20 Jul 2004 04:41:42 -0000	1.1
+++ memo_non.m	4 May 2005 01:13:18 -0000
@@ -40,9 +40,9 @@

 :- pred test_non(int::in, int::in, int::out) is nondet.
 :- pragma memo(test_non/3).
-
+:- pragma promise_pure(test_non/3).
 test_non(A, B, C) :-
-	marker("non", A, B, Zero),
+	impure marker("non", A, B, Zero),
 	( A = 1 ->
 		(
 			C = Zero + (A * 100) + (B * 10)
@@ -55,20 +55,19 @@

 :- pred test_multi(int::in, int::in, int::out) is multi.
 :- pragma memo(test_multi/3).
-
+:- pragma promise_pure(test_multi/3).
 test_multi(A, B, C) :-
-	marker("multi", A, B, Zero),
+	impure marker("multi", A, B, Zero),
 	(
 		C = Zero + (A * 100) + (B * 10)
 	;
 		C = Zero + (B * 100) + (A * 10)
 	).

-:- pred marker(string::in, int::in, int::in, int::out) is det.
-
+:- impure pred marker(string::in, int::in, int::in, int::out) is det.
 :- pragma foreign_proc("C",
 	marker(S::in, A::in, B::in, X::out),
-	[will_not_call_mercury, promise_pure],
+	[may_call_mercury],
 "
 	printf(""marker executed: %s %d %d\\n"", S, A, B);
 	X = 0;

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list