This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 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;
66use rustc_target:: spec:: PanicStrategy ;
77
88/// 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.
1111pub struct RemoveNoopLandingPads ;
1212
1313impl < ' tcx > MirPass < ' tcx > for RemoveNoopLandingPads {
@@ -84,7 +84,17 @@ impl RemoveNoopLandingPads {
8484 fn remove_nop_landing_pads ( & self , body : & mut Body < ' _ > ) {
8585 debug ! ( "body: {:#?}" , body) ;
8686
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
8898 let resume_block = {
8999 let mut patch = MirPatch :: new ( body) ;
90100 let resume_block = patch. resume_block ( ) ;
You can’t perform that action at this time.
0 commit comments