[m-rev.] diff: workaround a bug with lco

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Aug 3 12:24:46 AEST 2006


Workaround a bug reported by Ian.

Estimated hours taken: 0.5
Branches: main

Add a workaround to avoid a sanity check triggered by the last call modulo
constructor optimization.  A longer term fix is to make the purity of the
builtin store_at_ref/2 to impure.

compiler/lco.m:
 	Avoid a purity mismatch when constructing the store goal.
 	Aftewards mark the introduced goal as impure even though it is not.
 	It needs to be marked as impure to prevent simplify from optimising it
 	away.

Julien.

Index: compiler/lco.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lco.m,v
retrieving revision 1.39
diff -u -r1.39 lco.m
--- compiler/lco.m	27 Jul 2006 05:01:09 -0000	1.39
+++ compiler/lco.m	3 Aug 2006 02:13:23 -0000
@@ -974,8 +974,16 @@

  make_store_goal(ModuleInfo, Var - AddrVar, Goal) :-
      generate_simple_call(mercury_private_builtin_module, "store_at_ref",
-        predicate, only_mode, detism_det, purity_impure, [AddrVar, Var],
-        [], [], ModuleInfo, term.context_init, Goal).
+        predicate, only_mode, detism_det, purity_pure, [AddrVar, Var],
+        [], [], ModuleInfo, term.context_init, Goal0),
+    % 
+    % XXX the following hack is used to stop simplify from trying to
+    %      optimise the introduced call away.  store_at_ref/2 should
+    %      really be declared to be impure.
+    %
+    Goal0 = GoalExpr - GoalInfo0,
+    goal_info_set_purity(purity_impure, GoalInfo0, GoalInfo),
+    Goal  = GoalExpr - GoalInfo.

  %-----------------------------------------------------------------------------%

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