Skip to content

Commit e9207bf

Browse files
committed
Skip process_constant if state has no matching value.
1 parent bac5941 commit e9207bf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,15 @@ impl<'tcx> Map<'tcx> {
750750
}
751751
}
752752

753+
/// Return the range of value indices inside this place.
754+
pub fn values_inside(&self, root: PlaceIndex) -> &[ValueIndex] {
755+
let range = self.inner_values[root].clone();
756+
&self.inner_values_buffer[range]
757+
}
758+
753759
/// Invoke a function on each value in the given place and all descendants.
754760
fn for_each_value_inside(&self, root: PlaceIndex, f: &mut impl FnMut(ValueIndex)) {
755-
let range = self.inner_values[root].clone();
756-
let values = &self.inner_values_buffer[range];
757-
for &v in values {
761+
for &v in self.values_inside(root) {
758762
f(v)
759763
}
760764
}

compiler/rustc_mir_transform/src/jump_threading.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
422422
constant: OpTy<'tcx>,
423423
state: &mut ConditionSet<'a>,
424424
) {
425+
let values_inside = self.map.values_inside(lhs);
426+
if !state.iter().any(|cond| values_inside.contains(&cond.place)) {
427+
return;
428+
}
425429
self.map.for_each_projection_value(
426430
lhs,
427431
constant,

0 commit comments

Comments
 (0)