[m-dev.] diff: fix instmap_deltas computed by table_gen
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Feb 7 11:31:33 AEDT 2000
Estimated hours taken: 0.5
compiler/table_gen.m:
Recompute instmap_deltas after the transformation,
because the instmap_deltas computed for if-then-elses
are incorrect. There is no test case for this -- I've
only seen it cause problems for the alias branch.
compiler/mode_util.m:
Add recompute_instmap_delta_proc, for use by table_gen.m
recompute_instmap_delta_proc extracts the fields it
needs from a proc_info, then calls recompute_instmap_delta.
Index: mode_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_util.m,v
retrieving revision 1.118
diff -u -u -r1.118 mode_util.m
--- mode_util.m 1999/10/25 03:49:19 1.118
+++ mode_util.m 2000/01/20 00:41:36
@@ -108,6 +108,10 @@
% may need to insert new merge_insts into the merge_inst table.
% If the first argument is yes, the instmap_deltas for calls
% and deconstruction unifications are also recomputed.
+:- pred recompute_instmap_delta_proc(bool, proc_info, proc_info,
+ module_info, module_info).
+:- mode recompute_instmap_delta_proc(in, in, out, in, out) is det.
+
:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes, instmap,
module_info, module_info).
:- mode recompute_instmap_delta(in, in, out, in, in, in, out) is det.
@@ -1076,8 +1080,18 @@
% and deconstructions may become non-local (XXX does this require
% rerunning mode analysis rather than just recompute_instmap_delta?).
+recompute_instmap_delta_proc(RecomputeAtomic, ProcInfo0, ProcInfo) -->
+ =(ModuleInfo0),
+ { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0) },
+ { proc_info_vartypes(ProcInfo0, VarTypes) },
+ { proc_info_goal(ProcInfo0, Goal0) },
+ recompute_instmap_delta(RecomputeAtomic, Goal0, Goal,
+ VarTypes, InstMap0),
+ { proc_info_set_goal(ProcInfo0, Goal, ProcInfo) }.
+
recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes, InstMap0) -->
- recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes, InstMap0, _).
+ recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes,
+ InstMap0, _).
:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes, instmap,
instmap_delta, module_info, module_info).
Index: table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.15
diff -u -u -r1.15 table_gen.m
--- table_gen.m 2000/01/26 02:04:29 1.15
+++ table_gen.m 2000/02/04 04:42:08
@@ -273,14 +273,21 @@
% and save in the module info
proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
proc_info_set_varset(ProcInfo2, VarSet, ProcInfo3),
- proc_info_set_vartypes(ProcInfo3, VarTypes, ProcInfo),
+ proc_info_set_vartypes(ProcInfo3, VarTypes, ProcInfo4),
+ % Some of the instmap_deltas generated in this module
+ % are pretty dodgy (especially those for if-then-elses), so
+ % recompute them here.
+ RecomputeAtomic = no,
+ recompute_instmap_delta_proc(RecomputeAtomic,
+ ProcInfo4, ProcInfo, Module1, Module2),
+
pred_info_procedures(PredInfo1, ProcTable1),
map__det_update(ProcTable1, ProcId, ProcInfo, ProcTable),
pred_info_set_procedures(PredInfo1, ProcTable, PredInfo),
- module_info_preds(Module1, PredTable1),
+ module_info_preds(Module2, PredTable1),
map__det_update(PredTable1, PredId, PredInfo, PredTable),
- module_info_set_preds(Module1, PredTable, Module).
+ module_info_set_preds(Module2, PredTable, Module).
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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