Update MIR passes that assumed inline can never unwind.

This commit is contained in:
Luqman Aden 2022-05-16 21:46:20 -07:00
parent c1cfdd1fb2
commit f45f826207
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
use crate::MirPass; use crate::MirPass;
use rustc_ast::InlineAsmOptions;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty::layout; use rustc_middle::ty::layout;
@ -85,6 +86,12 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => { TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => {
layout::fn_can_unwind(tcx, None, Abi::Rust) layout::fn_can_unwind(tcx, None, Abi::Rust)
} }
TerminatorKind::InlineAsm { options, .. } => {
options.contains(InlineAsmOptions::MAY_UNWIND)
}
_ if terminator.unwind().is_some() => {
span_bug!(span, "unexpected terminator that may unwind {:?}", terminator)
}
_ => continue, _ => continue,
}; };

View File

@ -1042,8 +1042,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
| TerminatorKind::Unreachable | TerminatorKind::Unreachable
| TerminatorKind::GeneratorDrop | TerminatorKind::GeneratorDrop
| TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. } | TerminatorKind::FalseUnwind { .. } => {}
| TerminatorKind::InlineAsm { .. } => {}
// Resume will *continue* unwinding, but if there's no other unwinding terminator it // Resume will *continue* unwinding, but if there's no other unwinding terminator it
// will never be reached. // will never be reached.
@ -1057,6 +1056,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
TerminatorKind::Drop { .. } TerminatorKind::Drop { .. }
| TerminatorKind::DropAndReplace { .. } | TerminatorKind::DropAndReplace { .. }
| TerminatorKind::Call { .. } | TerminatorKind::Call { .. }
| TerminatorKind::InlineAsm { .. }
| TerminatorKind::Assert { .. } => return true, | TerminatorKind::Assert { .. } => return true,
} }
} }