File tree 1 file changed +13
-3
lines changed
compiler/rustc_mir_transform/src
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ use rustc_middle::ty::TyCtxt;
6
6
use rustc_target:: spec:: PanicStrategy ;
7
7
8
8
/// A pass that removes noop landing pads and replaces jumps to them with
9
- /// `None `. This is important because otherwise LLVM generates terrible
10
- /// code for these.
9
+ /// `UnwindAction::Continue `. This is important because otherwise LLVM generates
10
+ /// terrible code for these.
11
11
pub struct RemoveNoopLandingPads ;
12
12
13
13
impl < ' tcx > MirPass < ' tcx > for RemoveNoopLandingPads {
@@ -84,7 +84,17 @@ impl RemoveNoopLandingPads {
84
84
fn remove_nop_landing_pads ( & self , body : & mut Body < ' _ > ) {
85
85
debug ! ( "body: {:#?}" , body) ;
86
86
87
- // make sure there's a resume block
87
+ // Skip the pass if there are no blocks with a resume terminator.
88
+ let has_resume = body
89
+ . basic_blocks
90
+ . iter_enumerated ( )
91
+ . any ( |( _bb, block) | matches ! ( block. terminator( ) . kind, TerminatorKind :: Resume ) ) ;
92
+ if !has_resume {
93
+ debug ! ( "remove_noop_landing_pads: no resume block in MIR" ) ;
94
+ return ;
95
+ }
96
+
97
+ // make sure there's a resume block without any statements
88
98
let resume_block = {
89
99
let mut patch = MirPatch :: new ( body) ;
90
100
let resume_block = patch. resume_block ( ) ;
You can’t perform that action at this time.
0 commit comments