[m-dev.] diff: fix bug in lambda.m

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 1 17:43:00 AEDT 2001


I'll commit this on both the main branch and the release branch.

----------

Estimated hours taken: 5

Fix a bug that was causing the GCC back-end to abort with an internal
compiler error (map__det_insert failed) in mlds_to_gcc.m
for tests/hard_coded/curry2 and tests/higher_order_syntax2.m.
The C back-end also had a bug for these test cases: it generated
incorrect code, which `gcc -Wshadow' even warned about,
but that by coincidence didn't cause the test to fail.

The root cause was that lambda.m was generating incorrect HLDS:
it was not recomputing the non-locals properly.

compiler/lambda.m:
	Recompute the non-locals of the introduced procedure,
	if needed, to handle the case where extra non-locals
	need to be added for a lambda expression that is itself
	nested inside another lambda expression.
	(Also wrap some long lines.)

Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.70
diff -u -d -r1.70 lambda.m
--- compiler/lambda.m	2000/11/23 04:32:37	1.70
+++ compiler/lambda.m	2001/02/01 06:27:37
@@ -415,7 +415,8 @@
 		proc_info_interface_code_model(Call_ProcInfo, Call_CodeModel),
 		determinism_to_code_model(Detism, CodeModel),
 		module_info_globals(ModuleInfo0, Globals),
-		globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode),
+		globals__lookup_bool_option(Globals, highlevel_code,
+			HighLevelCode),
 		(
 			HighLevelCode = no,
 			( CodeModel = Call_CodeModel
@@ -423,7 +424,8 @@
 			)
 		;
 			HighLevelCode = yes,
-			pred_info_get_is_pred_or_func(Call_PredInfo, Call_PredOrFunc),
+			pred_info_get_is_pred_or_func(Call_PredInfo,
+				Call_PredOrFunc),
 			PredOrFunc = Call_PredOrFunc,
 			CodeModel = Call_CodeModel
 		),
@@ -549,7 +551,15 @@
 
 		proc_info_create(VarSet, VarTypes, AllArgVars, AllArgModes,
 			InstVarSet, Detism, LambdaGoal, LambdaContext,
-			TVarMap, TCVarMap, address_is_taken, ProcInfo),
+			TVarMap, TCVarMap, address_is_taken, ProcInfo0),
+		% If we previously already needed to recompute the nonlocals,
+		% then we'd better to that recomputation for the procedure
+		% that we just created.
+		( MustRecomputeNonLocals0 = yes ->
+			requantify_proc(ProcInfo0, ProcInfo)
+		;
+			ProcInfo = ProcInfo0
+		),
 
 		set__init(Assertions),
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list