diff: bug fix to common.m for `any' insts

Fergus Henderson fjh at hydra.cs.mu.oz.au
Fri Nov 14 04:18:50 AEDT 1997


Estimated hours taken: 1

compiler/common.m:
	Fix a bug: don't optimize away duplicate calls to predicates
	whose outputs include `any' insts, because that would create
	spurious aliasing.  (The test case for this bug is in
	extras/trailed_update/samples/tests.m.)

Index: common.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/common.m,v
retrieving revision 1.44
diff -u -u -r1.44 common.m
--- common.m	1997/07/27 14:59:59	1.44
+++ common.m	1997/11/13 17:18:08
@@ -514,8 +514,9 @@
 
 %---------------------------------------------------------------------------%
 
-	% Partition the arguments of a call into inputs and outputs, failing
-	% if any of the outputs have a unique component.
+	% Partition the arguments of a call into inputs and outputs,
+	% failing if any of the outputs have a unique component
+	% or if any of the outputs contain any `any' insts.
 :- pred common__partition_call_args(module_info::in, list(mode)::in,
 		list(var)::in, list(var)::out, list(var)::out) is semidet.
 
@@ -536,9 +537,18 @@
 		% Calls with partly unique outputs cannot be replaced,
 		% since a unique copy of the outputs must be produced.
 		inst_is_not_partly_unique(ModuleInfo, FinalInst),
+
+		% Don't optimize calls whose outputs include any
+		% `any' insts, since that would create false aliasing
+		% between the different variables.
+		% (inst_matches_binding applied to identical insts
+		% fails only for `any' insts.)
+		inst_matches_binding(FinalInst, FinalInst, ModuleInfo),
+
 		% Don't optimize calls where a partially instantiated
-		% variable is further instantiated.
+		% variable is further instantiated (XXX why not???).
 		inst_is_free(ModuleInfo, InitialInst),
+
 		InputArgs = InputArgs1,
 		OutputArgs = [Arg | OutputArgs1]
 	).
-- 
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.



More information about the developers mailing list