[m-dev.] diff: MLDS backend bug fix
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Nov 11 05:35:22 AEDT 1999
Estimated hours taken: 0.5
compiler/ml_code_gen.m:
Fix a bug: cater for the case where the HLDS front-end
over-estimates the non-locals set.
Also add a comment.
Workspace: /d-drive/home/hg/fjh/mercury
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.15
diff -u -d -r1.15 ml_code_gen.m
--- compiler/ml_code_gen.m 1999/11/10 04:13:08 1.15
+++ compiler/ml_code_gen.m 1999/11/10 18:13:49
@@ -560,6 +560,12 @@
% - class method calls
% - type declarations for user-defined types
% ...
+%
+% POTENTIAL EFFICIENCY IMPROVEMENTS:
+% - generate local declarations for the `succeeded' variable;
+% this would help in nondet code, because it would avoid
+% the need to access the outermost function's `succeeded'
+% variable via the environment pointer
%-----------------------------------------------------------------------------%
@@ -772,8 +778,24 @@
module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
_PredInfo, ProcInfo),
proc_info_interface_code_model(ProcInfo, CodeModel),
- proc_info_goal(ProcInfo, Goal),
- Goal = _ - GoalInfo,
+ proc_info_goal(ProcInfo, Goal0),
+
+ %
+ % The HLDS front-end sometimes over-estimates
+ % the set of non-locals. We need to restrict
+ % the set of non-locals for the top-level goal
+ % to just the headvars, because otherwise variables
+ % which occur in the top-level non-locals but which
+ % are not really non-local will not be declared.
+ %
+ proc_info_headvars(ProcInfo, HeadVars),
+ Goal0 = GoalExpr - GoalInfo0,
+ goal_info_get_nonlocals(GoalInfo0, NonLocals0),
+ set__list_to_set(HeadVars, HeadVarsSet),
+ set__intersect(HeadVarsSet, NonLocals0, NonLocals),
+ goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
+ Goal = GoalExpr - GoalInfo,
+
goal_info_get_context(GoalInfo, Context),
MLDSGenInfo0 = ml_gen_info_init(ModuleInfo, PredId, ProcId),
--
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.
--------------------------------------------------------------------------
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