diff: bug fix for `-O0 --warn-duplicate-calls'

Fergus Henderson fjh at cs.mu.oz.au
Sat Jul 12 23:17:33 AEST 1997


Hi,

Simon, can you please review this change?

compiler/simplify.m:
	Fix a bug: the `--warn-duplicate-calls' option did not work
	unless the `--optimize-duplicate-calls' option was also enabled.
	This caused the test case tests/warnings/duplicate_call.m to fail
	when MCFLAGS was set to `-O0'.

Index: simplify.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/simplify.m,v
retrieving revision 1.34
diff -u -5 -r1.34 simplify.m
--- simplify.m	1997/06/25 08:43:15	1.34
+++ simplify.m	1997/07/12 10:43:47
@@ -350,10 +350,16 @@
 simplify__goal_2(Goal0, GoalInfo, Goal, GoalInfo, Info0, Info) :-
 	Goal0 = higher_order_call(Closure, Args, _, Modes, Det),
 	( simplify_do_calls(Info0) ->
 		common__optimise_higher_order_call(Closure, Args, Modes, Det,
 			Goal0, GoalInfo, Goal, Info0, Info)
+	; simplify_do_warn_calls(Info0) ->
+		% we need to do the pass, for the warnings, but we ignore
+		% the optimized goal and instead use the original one
+		common__optimise_higher_order_call(Closure, Args, Modes, Det,
+			Goal0, GoalInfo, _Goal1, Info0, Info),
+		Goal = Goal0
 	;
 		Goal = Goal0,
 		Info = Info0
 	).
 
@@ -426,10 +432,16 @@
 	% check for duplicate calls to the same procedure
 	%
 	( simplify_do_calls(Info2) ->
 		common__optimise_call(PredId, ProcId, Args, Goal0, GoalInfo,
 			Goal, Info2, Info)
+	; simplify_do_warn_calls(Info0) ->
+		% we need to do the pass, for the warnings, but we ignore
+		% the optimized goal and instead use the original one
+		common__optimise_call(PredId, ProcId, Args, Goal0, GoalInfo,
+			_Goal1, Info2, Info),
+		Goal = Goal0
 	;
 		Goal = Goal0,
 		Info = Info2
 	).
 
@@ -463,10 +475,24 @@
 	;
 		simplify_do_common(Info0)
 	->
 		common__optimise_unification(U0, LT0, RT0, M, C,
 			Goal0, GoalInfo0, Goal, GoalInfo, Info0, Info)
+	;
+		( simplify_do_calls(Info0)
+		; simplify_do_warn_calls(Info0)
+		)
+	->
+		% We need to do the pass, to record the variable
+		% equivalences used for optimizing or warning about
+		% duplicate calls.  But we don't want to perform
+		% the optimization, so we disregard the optimized goal
+		% and instead use the original one.
+		common__optimise_unification(U0, LT0, RT0, M, C,
+			Goal0, GoalInfo0, _Goal1, _GoalInfo1, Info0, Info),
+		Goal = Goal0,
+		GoalInfo = GoalInfo0
 	;
 		Goal = Goal0,
 		GoalInfo = GoalInfo0,
 		Info = Info0
 	).
-- 
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