Skip to content

Commit cbdb555

Browse files
Eagerly filter reflexive subset relations in naive variant
...instead of removing them at the start of each iteration.
1 parent 1bcf40d commit cbdb555

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

polonius-engine/src/output/naive.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,6 @@ pub(super) fn compute<T: FactTypes>(
104104

105105
// .. and then start iterating rules!
106106
while iteration.changed() {
107-
// Cleanup step: remove symmetries
108-
// - remove origins which are `subset`s of themselves
109-
//
110-
// FIXME: investigate whether is there a better way to do that without complicating
111-
// the rules too much, because it would also require temporary variables and
112-
// impact performance. Until then, the big reduction in tuples improves performance
113-
// a lot, even if we're potentially adding a small number of tuples
114-
// per round just to remove them in the next round.
115-
subset
116-
.recent
117-
.borrow_mut()
118-
.elements
119-
.retain(|&(origin1, origin2, _)| origin1 != origin2);
120-
121107
// Remap fields to re-index by keys, to prepare the data needed by the rules below.
122108
subset_o1p.from_map(&subset, |&(origin1, origin2, point)| {
123109
((origin1, point), origin2)
@@ -137,11 +123,14 @@ pub(super) fn compute<T: FactTypes>(
137123
//
138124
// subset(Origin1, Origin3, Point) :-
139125
// subset(Origin1, Origin2, Point),
140-
// subset(Origin2, Origin3, Point).
141-
subset.from_join(
126+
// subset(Origin2, Origin3, Point),
127+
// Origin1 != Origin3.
128+
subset.from_join_filtered(
142129
&subset_o2p,
143130
&subset_o1p,
144-
|&(_origin2, point), &origin1, &origin3| (origin1, origin3, point),
131+
|&(_origin2, point), &origin1, &origin3| {
132+
(origin1 != origin3).then(|| (origin1, origin3, point))
133+
},
145134
);
146135

147136
// Rule 3: propagate subsets along the CFG, according to liveness.
@@ -238,10 +227,6 @@ pub(super) fn compute<T: FactTypes>(
238227
placeholder_origin.extend_with(|&(_origin1, origin2, _point)| origin2),
239228
known_placeholder_subset
240229
.filter_anti(|&(origin1, origin2, _point)| (origin1, origin2)),
241-
// remove symmetries:
242-
datafrog::ValueFilter::from(|&(origin1, origin2, _point), _| {
243-
origin1 != origin2
244-
}),
245230
),
246231
|&(origin1, origin2, point), _| (origin1, origin2, point),
247232
);

0 commit comments

Comments
 (0)