Skip to content

Commit 9a0ee05

Browse files
committed
Split critical edge targeting the start block
1 parent d83da1d commit 9a0ee05

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/rustc_mir/src/transform/add_call_guards.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
3838

3939
impl AddCallGuards {
4040
pub fn add_call_guards(&self, body: &mut Body<'_>) {
41-
let pred_count: IndexVec<_, _> = body.predecessors().iter().map(|ps| ps.len()).collect();
41+
let mut pred_count: IndexVec<_, _> =
42+
body.predecessors().iter().map(|ps| ps.len()).collect();
43+
pred_count[START_BLOCK] += 1;
4244

4345
// We need a place to store the new blocks generated
4446
let mut new_blocks = Vec::new();

src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs

+10
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ fn take_until(terminate: impl Fn() -> bool) {
2222
// CHECK-LABEL: @main
2323
fn main() {
2424
take_until(|| true);
25+
f(None);
2526
}
27+
28+
fn f(_a: Option<String>) -> Option<u32> {
29+
loop {
30+
g();
31+
()
32+
}
33+
}
34+
35+
fn g() -> Option<u32> { None }

0 commit comments

Comments
 (0)