@@ -75,13 +75,16 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
75
75
let target_funclet = fx. cleanup_kinds [ target] . funclet_bb ( target) ;
76
76
match ( self . funclet_bb , target_funclet) {
77
77
( None , None ) => ( lltarget, false ) ,
78
- ( Some ( f) , Some ( t_f) ) if f == t_f || !base:: wants_msvc_seh ( fx. cx . tcx ( ) . sess ) => {
79
- ( lltarget, false )
80
- }
81
78
// jump *into* cleanup - need a landing pad if GNU, cleanup pad if MSVC
82
79
( None , Some ( _) ) => ( fx. landing_pad_for ( target) , false ) ,
83
80
( Some ( _) , None ) => span_bug ! ( span, "{:?} - jump out of cleanup?" , self . terminator) ,
84
- ( Some ( _) , Some ( _) ) => ( fx. landing_pad_for ( target) , true ) ,
81
+ ( Some ( f) , Some ( t_f) ) => {
82
+ if f == t_f || !base:: wants_msvc_seh ( fx. cx . tcx ( ) . sess ) {
83
+ ( lltarget, false )
84
+ } else {
85
+ ( fx. landing_pad_for ( target) , true )
86
+ }
87
+ }
85
88
}
86
89
}
87
90
@@ -95,7 +98,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
95
98
let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
96
99
if is_cleanupret {
97
100
// MSVC cross-funclet jump - need a trampoline
98
-
101
+ debug_assert ! ( base :: wants_msvc_seh ( fx . cx . tcx ( ) . sess ) ) ;
99
102
debug ! ( "llbb_with_cleanup: creating cleanup trampoline for {:?}" , target) ;
100
103
let name = & format ! ( "{:?}_cleanup_trampoline_{:?}" , self . bb, target) ;
101
104
let trampoline_llbb = Bx :: append_block ( fx. cx , fx. llfn , name) ;
@@ -115,8 +118,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
115
118
) {
116
119
let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
117
120
if is_cleanupret {
118
- // micro-optimization: generate a `ret` rather than a jump
121
+ // MSVC micro-optimization: generate a `ret` rather than a jump
119
122
// to a trampoline.
123
+ debug_assert ! ( base:: wants_msvc_seh( fx. cx. tcx( ) . sess) ) ;
120
124
bx. cleanup_ret ( self . funclet ( fx) . unwrap ( ) , Some ( lltarget) ) ;
121
125
} else {
122
126
bx. br ( lltarget) ;
0 commit comments