File tree 2 files changed +38
-1
lines changed
compiler/rustc_mir/src/transform
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,9 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
38
38
39
39
impl AddCallGuards {
40
40
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 ;
42
44
43
45
// We need a place to store the new blocks generated
44
46
let mut new_blocks = Vec :: new ( ) ;
Original file line number Diff line number Diff line change
1
+ // build-pass
2
+ // compile-flags: -Copt-level=0
3
+
4
+ // Regression test for #88043: LLVM crash when the RemoveZsts mir-opt pass is enabled.
5
+ // We should not see the error:
6
+ // `Basic Block in function '_ZN4main10take_until17h0067b8a660429bc9E' does not have terminator!`
7
+
8
+ fn bump ( ) -> Option < usize > {
9
+ unreachable ! ( )
10
+ }
11
+
12
+ fn take_until ( terminate : impl Fn ( ) -> bool ) {
13
+ loop {
14
+ if terminate ( ) {
15
+ return ;
16
+ } else {
17
+ bump ( ) ;
18
+ }
19
+ }
20
+ }
21
+
22
+ // CHECK-LABEL: @main
23
+ fn main ( ) {
24
+ take_until ( || true ) ;
25
+ f ( None ) ;
26
+ }
27
+
28
+ fn f ( _a : Option < String > ) -> Option < u32 > {
29
+ loop {
30
+ g ( ) ;
31
+ ( )
32
+ }
33
+ }
34
+
35
+ fn g ( ) -> Option < u32 > { None }
You can’t perform that action at this time.
0 commit comments