Clarify some cleanup stuff.
- Rearrange the match in `llbb_with_landing_pad` so the `(Some,Some)` cases are together. - Add assertions to indicate two MSVC-only paths.
This commit is contained in:
parent
a5bd5da594
commit
03f350f5a5
1 changed files with 10 additions and 6 deletions
|
@ -75,13 +75,16 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
||||||
let target_funclet = fx.cleanup_kinds[target].funclet_bb(target);
|
let target_funclet = fx.cleanup_kinds[target].funclet_bb(target);
|
||||||
match (self.funclet_bb, target_funclet) {
|
match (self.funclet_bb, target_funclet) {
|
||||||
(None, None) => (lltarget, false),
|
(None, None) => (lltarget, false),
|
||||||
(Some(f), Some(t_f)) if f == t_f || !base::wants_msvc_seh(fx.cx.tcx().sess) => {
|
|
||||||
(lltarget, false)
|
|
||||||
}
|
|
||||||
// jump *into* cleanup - need a landing pad if GNU, cleanup pad if MSVC
|
// jump *into* cleanup - need a landing pad if GNU, cleanup pad if MSVC
|
||||||
(None, Some(_)) => (fx.landing_pad_for(target), false),
|
(None, Some(_)) => (fx.landing_pad_for(target), false),
|
||||||
(Some(_), None) => span_bug!(span, "{:?} - jump out of cleanup?", self.terminator),
|
(Some(_), None) => span_bug!(span, "{:?} - jump out of cleanup?", self.terminator),
|
||||||
(Some(_), Some(_)) => (fx.landing_pad_for(target), true),
|
(Some(f), Some(t_f)) => {
|
||||||
|
if f == t_f || !base::wants_msvc_seh(fx.cx.tcx().sess) {
|
||||||
|
(lltarget, false)
|
||||||
|
} else {
|
||||||
|
(fx.landing_pad_for(target), true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +98,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
||||||
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
||||||
if is_cleanupret {
|
if is_cleanupret {
|
||||||
// MSVC cross-funclet jump - need a trampoline
|
// MSVC cross-funclet jump - need a trampoline
|
||||||
|
debug_assert!(base::wants_msvc_seh(fx.cx.tcx().sess));
|
||||||
debug!("llbb_with_cleanup: creating cleanup trampoline for {:?}", target);
|
debug!("llbb_with_cleanup: creating cleanup trampoline for {:?}", target);
|
||||||
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
|
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
|
||||||
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
|
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
|
||||||
|
@ -115,8 +118,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
||||||
) {
|
) {
|
||||||
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
||||||
if is_cleanupret {
|
if is_cleanupret {
|
||||||
// micro-optimization: generate a `ret` rather than a jump
|
// MSVC micro-optimization: generate a `ret` rather than a jump
|
||||||
// to a trampoline.
|
// to a trampoline.
|
||||||
|
debug_assert!(base::wants_msvc_seh(fx.cx.tcx().sess));
|
||||||
bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
|
bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
|
||||||
} else {
|
} else {
|
||||||
bx.br(lltarget);
|
bx.br(lltarget);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue