[m-rev.] diff: fix MLDS tail-call bug

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Sep 20 20:16:17 AEST 2002


Estimated hours taken: 1
Branches: main, 0_10_y

compiler/ml_tailcall.m:
	Fix a bug: calls to functions nested within the current function
	must not be marked as tail calls, because the callee may access
	the environment, so the caller's stack frame can't be deallocated.

Workspace: /home/ceres/fjh/ws-gcc-basic-improvements-patched/mercury
Index: compiler/ml_tailcall.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_tailcall.m,v
retrieving revision 1.17
diff -u -d -p -r1.17 ml_tailcall.m
--- compiler/ml_tailcall.m	2 Apr 2002 16:36:12 -0000	1.17
+++ compiler/ml_tailcall.m	20 Sep 2002 07:10:10 -0000
@@ -296,7 +296,12 @@ mark_tailcalls_in_stmt(Stmt0, AtTail, Lo
 			% local variables or nested functions
 			%
 			check_maybe_rval(Obj, Locals),
-			check_rvals(Args, Locals)
+			check_rvals(Args, Locals),
+			%
+			% the call must not be to a function nested within
+			% this function
+			%
+			check_rval(Func, Locals)
 		->
 			% mark this call as a tail call
 			CallKind = tail_call,

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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