[m-rev.] for review: remove structure sharing info in add_pragma.m

Peter Wang novalazy at gmail.com
Tue Jan 29 11:26:19 AEDT 2008

Branches: main

In the handling of `:- pragma type_spec' declarations, a proc_info may be
derived from a proc_info that holds structure sharing or reuse information.
Since the specialised procedure won't have the same interface as the original
procedure, that information won't be directly usable so we need to delete it.

We do a similar thing in higher_order.m.  However, when making optimisation
interfaces the higher order specialisation pass won't be run so we do it in
add_pragma.m as well.

	As above.

Index: compiler/add_pragma.m
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.77
diff -u -r1.77 add_pragma.m
--- compiler/add_pragma.m	22 Jan 2008 15:06:08 -0000	1.77
+++ compiler/add_pragma.m	28 Jan 2008 23:52:47 -0000
@@ -1442,7 +1442,10 @@
         SubstOk = yes(RenamedSubst),
         pred_info_get_procedures(PredInfo0, Procs0),
         handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes,
-            ProcIds, Procs0, Procs, ModesOk, !ModuleInfo, !Specs),
+            ProcIds, Procs0, Procs1, ModesOk, !ModuleInfo, !Specs),
+        % Remove any imported structure sharing and reuse information for the
+        % original procedure as they won't be (directly) applicable.
+        map.map_values(reset_imported_structure_sharing_reuse, Procs1, Procs),
         module_info_get_globals(!.ModuleInfo, Globals),
         globals.lookup_bool_option(Globals, user_guided_type_specialization,
@@ -1827,6 +1830,13 @@
         ModesOk = yes
+:- pred reset_imported_structure_sharing_reuse(proc_id::in,
+    proc_info::in, proc_info::out) is det.
+reset_imported_structure_sharing_reuse(_, !ProcInfo) :-
+    proc_info_reset_imported_structure_sharing(!ProcInfo),
+    proc_info_reset_imported_structure_reuse(!ProcInfo).
 add_pragma_termination2_info(PredOrFunc, SymName, ModeList,

mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au

More information about the reviews mailing list