diff: det_analysis bug fix for mixed cc/non-cc

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 2 18:06:52 AEST 1998


compiler/det_analysis.m:
	Fix a bug in determinism analysis for calls to predicates
	with both `cc_multi' and `multi' modes from all-solution
	contexts: it was incorrectly giving such calls determinism
	`cc_multi' instead of `multi'.
	This bug caused the compiler to generate incorrect code for
	the test case tests/hard_coded/cc_and_non_cc_test.m when
	using optimization levels -O1 or lower.  (At higher optimization
	levels, the calls got inlined, masking the bug.)

Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.133
diff -u -u -1 -9 -r1.133 det_analysis.m
--- det_analysis.m	1998/06/09 02:12:24	1.133
+++ det_analysis.m	1998/07/02 08:00:20
@@ -445,39 +445,39 @@
 det_infer_goal_2(call(PredId, ModeId0, A, B, C, N), GoalInfo, _, SolnContext,
 		DetInfo, _, _,
 		call(PredId, ModeId, A, B, C, N), Detism, Msgs) :-
 	det_lookup_detism(DetInfo, PredId, ModeId0, Detism0),
 	%
 	% Make sure we don't try to call a committed-choice pred
 	% from a non-committed-choice context.
 	%
 	determinism_components(Detism0, CanFail, NumSolns),
 	(
 		NumSolns = at_most_many_cc,
 		SolnContext \= first_soln
 	->
 		(
 			det_find_matching_non_cc_mode(DetInfo, PredId, ModeId0,
 				ModeId1)
 		->
 			ModeId = ModeId1,
 			Msgs = [],
-			Detism = Detism0
+			determinism_components(Detism, CanFail, at_most_many)
 		;
 			Msgs = [cc_pred_in_wrong_context(GoalInfo, Detism0,
 					PredId, ModeId0)],
 			ModeId = ModeId0,
 			% Code elsewhere relies on the assumption that
 			%	SolnContext \= first_soln =>
 			%		NumSolns \= at_most_many_cc,
 			% so we need to enforce that here.
 			determinism_components(Detism, CanFail, at_most_many)
 		)
 	;
 		Msgs = [],
 		ModeId = ModeId0,
 		Detism = Detism0
 	).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list