Make dataflow const-prop handle_switch_int monotonic.
This commit is contained in:
parent
e9990ce89c
commit
b8fed2f21c
@ -257,15 +257,18 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
|
|||||||
ValueOrPlace::Value(value) => value,
|
ValueOrPlace::Value(value) => value,
|
||||||
ValueOrPlace::Place(place) => state.get_idx(place, self.map()),
|
ValueOrPlace::Place(place) => state.get_idx(place, self.map()),
|
||||||
};
|
};
|
||||||
let FlatSet::Elem(ScalarTy(scalar, _)) = value else {
|
match value {
|
||||||
// Do nothing if we don't know which branch will be taken.
|
// We are branching on uninitialized data, this is UB, treat it as unreachable.
|
||||||
return TerminatorEdges::SwitchInt { discr, targets };
|
// This allows the set of visited edges to grow monotonically with the lattice.
|
||||||
};
|
FlatSet::Bottom => TerminatorEdges::None,
|
||||||
|
FlatSet::Elem(ScalarTy(scalar, _)) => {
|
||||||
let int = scalar.assert_int();
|
let int = scalar.assert_int();
|
||||||
let choice = int.assert_bits(int.size());
|
let choice = int.assert_bits(int.size());
|
||||||
TerminatorEdges::Single(targets.target_for_value(choice))
|
TerminatorEdges::Single(targets.target_for_value(choice))
|
||||||
}
|
}
|
||||||
|
FlatSet::Top => TerminatorEdges::SwitchInt { discr, targets },
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user