[m-rev.] trivial diff: fix a bug in closure analysis

Julien Fischer juliensf at cs.mu.OZ.AU
Wed Jun 29 13:17:53 AEST 2005


Estimated hours taken: 1
Branches: main

Fix a bug in closure analysis where the values of higher-order
variables was not being recorded correctly at generic_calls.

compiler/closure_analysis.m:
	Make sure to record closure information for all of the
	arguments of call/N or apply/N.

	Fix the formatting of the progress message.

Julien.

Index: closure_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/closure_analysis.m,v
retrieving revision 1.1
diff -u -r1.1 closure_analysis.m
--- closure_analysis.m	17 Jun 2005 10:13:52 -0000	1.1
+++ closure_analysis.m	29 Jun 2005 03:13:50 -0000
@@ -154,7 +154,7 @@
     proc_info_argmodes(ProcInfo0, ArgModes),
     ClosureInfo0 = closure_info_init(!.ModuleInfo, VarTypes, HeadVars,
         ArgModes),
-    write_proc_progress_message("Analysing closures in ", PPId, !.ModuleInfo,
+    write_proc_progress_message("% Analysing closures in ", PPId, !.ModuleInfo,
         !IO),
     proc_info_goal(ProcInfo0, Body0),
     process_goal(VarTypes, !.ModuleInfo, Body0, Body,
@@ -235,9 +235,20 @@
     % XXX We should probably just ignore Aditi stuff and unsafe_casts
     % but annotating them with closure_infos won't hurt.
     %
-    GoalExpr = generic_call(_Details, GCallArgs, GCallModes, _),
+    GoalExpr = generic_call(Details, GCallArgs, GCallModes, _),
     partition_arguments(ModuleInfo, VarTypes, GCallArgs, GCallModes,
-        set.init, InputArgs, set.init, OutputArgs),
+        set.init, InputArgs0, set.init, OutputArgs),
+    %
+    % For higher-order calls we need to make sure that the actual higher-order
+    % variable being called is also considered (it will typically be the
+    % variable of interest).  This variable is not included in 'GCallArgs' so
+    % we need to include in the set of input argument separately.
+    %
+    ( Details = higher_order(CalledClosure0, _, _, _) ->
+        svset.insert(CalledClosure0, InputArgs0, InputArgs)
+    ;
+        InputArgs = InputArgs0
+    ),
     AddValues = (pred(Var::in, !.ValueMap::in, !:ValueMap::out) is det :-
         %
         % The closure_info won't yet contain any information about

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