Split critical edge targeting the start block

This commit is contained in:
Tomasz Miąsko 2021-08-17 00:00:00 +00:00
parent d83da1d05d
commit 9a0ee05c3d
2 changed files with 13 additions and 1 deletions

View file

@ -38,7 +38,9 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
impl AddCallGuards {
pub fn add_call_guards(&self, body: &mut Body<'_>) {
let pred_count: IndexVec<_, _> = body.predecessors().iter().map(|ps| ps.len()).collect();
let mut pred_count: IndexVec<_, _> =
body.predecessors().iter().map(|ps| ps.len()).collect();
pred_count[START_BLOCK] += 1;
// We need a place to store the new blocks generated
let mut new_blocks = Vec::new();

View file

@ -22,4 +22,14 @@ fn take_until(terminate: impl Fn() -> bool) {
// CHECK-LABEL: @main
fn main() {
take_until(|| true);
f(None);
}
fn f(_a: Option<String>) -> Option<u32> {
loop {
g();
()
}
}
fn g() -> Option<u32> { None }