[m-rev.] [reuse] diff: fix wrong propagation of aliases
Nancy Mazur
Nancy.Mazur at cs.kuleuven.ac.be
Mon Apr 9 19:52:05 AEST 2001
Hi,
while this fix is definitely correct, it also has the disadvantage of
generating more aliases, and thus being a bit less precise. I don't see
a way to avoid it though.
So now the backbone-list of compute_texture is not reusable and cgc-able
at all. I'm still checking what can be done more here...
Nancy
===================================================================
Estimated hours taken: 1 (+ 24 hours to locate and filter out the bug (peter))
Branches: reuse
Bugfix. The aliases didn't propagate correctly:
% deconstruct
List0 => [ FirstElement | Rest ]
If the elements of List0 are already aliased to something else, then
the elements of Rest might also be aliased to that something else. This
wasn't the case, and resulted in wrong reuses (things were reused while
being needed).
The reason of this is that while extending aliases with new sets of aliases,
recursive types were not correctly propagated. The solution to this consists
of a correction of the notion of less-then-or-equal for selectors, in such
a way that the selectors are first normalized, and only then compared:
S1 <= S2 <=> NormalisedS1 <= NormalizedS2
pa_selector.m:
First normalize the selectors before comparing them.
Index: pa_selector.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_selector.m,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 pa_selector.m
--- pa_selector.m 2001/03/29 08:54:36 1.1.2.9
+++ pa_selector.m 2001/04/09 09:42:23
@@ -493,13 +493,21 @@
less_or_equal(HLDS, S1, S2, MainType, EXT):-
+ normalize_wti(MainType, HLDS, S1, NormS1),
+ normalize_wti(MainType, HLDS, S2, NormS2),
+ less_or_equal_2(HLDS, NormS1, NormS2, MainType, EXT).
+
+:- pred less_or_equal_2(module_info::in, selector::in, selector::in,
+ (type)::in, selector::out) is semidet.
+
+less_or_equal_2(HLDS, S1, S2, MainType, EXT):-
(
split_upto_type_selector(S2, S2_part1, TS, S2_part2),
TS = ts(SubType)
->
(
- less_or_equal(HLDS, S1, S2_part1, MainType, Rest)
+ less_or_equal_2(HLDS, S1, S2_part1, MainType, Rest)
% append(S2_part1, Rest, S1) % walk past S2_part1
% S1 = S2_part1.Rest
->
@@ -510,7 +518,7 @@
get_type_of_node(HLDS, MainType, S2_part1, NodeType),
% from NodeType, to TS
type_on_path(HLDS, NodeType, SubType, Rest, Remainder),
- less_or_equal(HLDS, Remainder, S2_part2, SubType, EXT)
+ less_or_equal_2(HLDS, Remainder, S2_part2, SubType, EXT)
;
fail % the walks do not correspond
)
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list