[m-rev.] diff: mlds_to_c.m: fix tail-call type error

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Feb 6 21:27:27 AEDT 2002


On 06-Feb-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Fix a bug caused by my previous change to ml_call_gen.m
> where calls to procedures with determinism `erroneous' or `failure'
> get marked as tail calls.
> 
> compiler/mlds_to_c.m:
> 	Only output `return' statements for calls marked as tail calls
> 	if the callee argument types match the caller argument types.

I meant to say "return types" rather than "argument types".

Similar changes are also needed in mlds_to_il.m and mlds_to_java.m.
Here's a fix for mlds_to_il.m.

----------

Estimated hours taken: 0.5
Branches: main

Fix a bug caused by my previous change to ml_call_gen.m
where calls to procedures with determinism `erroneous' or `failure'
get marked as tail calls.

compiler/mlds_to_il.m:
	When generating verifiable code, only output `tail.' prefixes
	il calls if the callee return type matches the caller return types.

Workspace: /home/earth/fjh/ws-earth4/mercury
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.99
diff -u -d -r1.99 mlds_to_il.m
--- compiler/mlds_to_il.m	30 Jan 2002 05:08:42 -0000	1.99
+++ compiler/mlds_to_il.m	6 Feb 2002 10:22:47 -0000
@@ -1520,6 +1520,8 @@
 	DataRep =^ il_data_rep,
 	{ TypeParams = mlds_signature_to_ilds_type_params(DataRep, Sig) },
 	{ ReturnParam = mlds_signature_to_il_return_param(DataRep, Sig) },
+	CallerSig =^ signature,
+	{ CallerSig = signature(_, CallerReturnParam, _) },
 	(
 		{ IsTail = tail_call },
 		% if --verifiable-code is enabled,
@@ -1536,6 +1538,13 @@
 				}
 			),
 			{ ByRefTailCalls = no }
+		),
+		% if --verifiable-code is enabled, then we must not output
+		% the "tail." prefix unless the callee return type is
+		% compatible with the caller return type
+		\+ (
+			{ VerifiableCode = yes },
+			{ ReturnParam \= CallerReturnParam }
 		)
 	->
 		{ TailCallInstrs = [tailcall] },

-- 
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