Rollup merge of #134073 - DianQK:fix-131227, r=oli-obk
dataflow_const_prop: do not eval a ptr address in SwitchInt Fixes #131227.
This commit is contained in:
commit
cb5f03cbce
3 changed files with 26 additions and 18 deletions
|
@ -534,8 +534,13 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
|
|||
// This allows the set of visited edges to grow monotonically with the lattice.
|
||||
FlatSet::Bottom => TerminatorEdges::None,
|
||||
FlatSet::Elem(scalar) => {
|
||||
let choice = scalar.assert_scalar_int().to_bits_unchecked();
|
||||
TerminatorEdges::Single(targets.target_for_value(choice))
|
||||
if let Ok(scalar_int) = scalar.try_to_scalar_int() {
|
||||
TerminatorEdges::Single(
|
||||
targets.target_for_value(scalar_int.to_bits_unchecked()),
|
||||
)
|
||||
} else {
|
||||
TerminatorEdges::SwitchInt { discr, targets }
|
||||
}
|
||||
}
|
||||
FlatSet::Top => TerminatorEdges::SwitchInt { discr, targets },
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue