Skip to content

Commit d911a1c

Browse files
committed
Skip process_constant if state has no matching value.
1 parent b891d80 commit d911a1c

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
@@ -423,6 +423,10 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
423423
constant: OpTy<'tcx>,
424424
state: &mut ConditionSet<'a>,
425425
) {
426+
let values_inside = self.map.values_inside(lhs);
427+
if !state.iter().any(|cond| values_inside.contains(&cond.place)) {
428+
return;
429+
}
426430
self.map.for_each_projection_value(
427431
lhs,
428432
constant,

0 commit comments

Comments
 (0)