mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
fix ice in ssa-range-prop
It used to ICE when hitting an `assert_ne!(location.block, successor.block` due to hitting a self-dominating bb Fixed by checking *strict* domination instead of normal one
This commit is contained in:
@@ -163,8 +163,7 @@ fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Loca
|
||||
&& self.is_ssa(place) =>
|
||||
{
|
||||
let successor = Location { block: *target, statement_index: 0 };
|
||||
if location.dominates(successor, &self.dominators) {
|
||||
assert_ne!(location.block, successor.block);
|
||||
if location.strictly_dominates(successor, &self.dominators) {
|
||||
let val = *expected as u128;
|
||||
let range = WrappingRange { start: val, end: val };
|
||||
self.insert_range(place, successor, range);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/// Regression test for <https://github.com/rust-lang/rust/issues/155836>.
|
||||
///
|
||||
/// SsaRangeProp pass used to fail the assert when encountering self-dominating block
|
||||
/// e.g. small loops like in `a`
|
||||
|
||||
//@ compile-flags: -Copt-level=2
|
||||
//@ build-pass
|
||||
|
||||
use std::hint::black_box;
|
||||
fn a(d: u8) {
|
||||
loop {
|
||||
1 % d;
|
||||
}
|
||||
}
|
||||
pub fn e(d: u8) {
|
||||
if d == 0 || black_box(false) {
|
||||
a(d);
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
e(1);
|
||||
}
|
||||
Reference in New Issue
Block a user