Skip to content

Commit

Permalink
Split critical edge targeting the start block
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Aug 17, 2021
1 parent d83da1d commit 9a0ee05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_mir/src/transform/add_call_guards.rs
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs
Expand Up @@ -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 }

0 comments on commit 9a0ee05

Please sign in to comment.