@@ -63,7 +63,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
63
63
}
64
64
}
65
65
66
- fn lltarget < Bx : BuilderMethods < ' a , ' tcx > > (
66
+ /// Get a basic block (creating it if necessary), possibly with a landing
67
+ /// pad next to it.
68
+ fn llbb_with_landing_pad < Bx : BuilderMethods < ' a , ' tcx > > (
67
69
& self ,
68
70
fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
69
71
target : mir:: BasicBlock ,
@@ -83,17 +85,18 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
83
85
}
84
86
}
85
87
86
- /// Create a basic block.
87
- fn llblock < Bx : BuilderMethods < ' a , ' tcx > > (
88
+ /// Get a basic block (creating it if necessary), possibly with cleanup
89
+ /// stuff in it or next to it.
90
+ fn llbb_with_cleanup < Bx : BuilderMethods < ' a , ' tcx > > (
88
91
& self ,
89
92
fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
90
93
target : mir:: BasicBlock ,
91
94
) -> Bx :: BasicBlock {
92
- let ( lltarget, is_cleanupret) = self . lltarget ( fx, target) ;
95
+ let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
93
96
if is_cleanupret {
94
97
// MSVC cross-funclet jump - need a trampoline
95
98
96
- debug ! ( "llblock : creating cleanup trampoline for {:?}" , target) ;
99
+ debug ! ( "llbb_with_cleanup : creating cleanup trampoline for {:?}" , target) ;
97
100
let name = & format ! ( "{:?}_cleanup_trampoline_{:?}" , self . bb, target) ;
98
101
let trampoline_llbb = Bx :: append_block ( fx. cx , fx. llfn , name) ;
99
102
let mut trampoline_bx = Bx :: build ( fx. cx , trampoline_llbb) ;
@@ -110,7 +113,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
110
113
bx : & mut Bx ,
111
114
target : mir:: BasicBlock ,
112
115
) {
113
- let ( lltarget, is_cleanupret) = self . lltarget ( fx, target) ;
116
+ let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
114
117
if is_cleanupret {
115
118
// micro-optimization: generate a `ret` rather than a jump
116
119
// to a trampoline.
@@ -138,7 +141,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
138
141
let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
139
142
140
143
let unwind_block = if let Some ( cleanup) = cleanup. filter ( |_| fn_abi. can_unwind ) {
141
- Some ( self . llblock ( fx, cleanup) )
144
+ Some ( self . llbb_with_cleanup ( fx, cleanup) )
142
145
} else if fx. mir [ self . bb ] . is_cleanup
143
146
&& fn_abi. can_unwind
144
147
&& !base:: wants_msvc_seh ( fx. cx . tcx ( ) . sess )
@@ -231,7 +234,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
231
234
options,
232
235
line_spans,
233
236
instance,
234
- Some ( ( ret_llbb, self . llblock ( fx, cleanup) , self . funclet ( fx) ) ) ,
237
+ Some ( ( ret_llbb, self . llbb_with_cleanup ( fx, cleanup) , self . funclet ( fx) ) ) ,
235
238
) ;
236
239
} else {
237
240
bx. codegen_inline_asm ( template, & operands, options, line_spans, instance, None ) ;
@@ -281,8 +284,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
281
284
if target_iter. len ( ) == 1 {
282
285
// If there are two targets (one conditional, one fallback), emit br instead of switch
283
286
let ( test_value, target) = target_iter. next ( ) . unwrap ( ) ;
284
- let lltrue = helper. llblock ( self , target) ;
285
- let llfalse = helper. llblock ( self , targets. otherwise ( ) ) ;
287
+ let lltrue = helper. llbb_with_cleanup ( self , target) ;
288
+ let llfalse = helper. llbb_with_cleanup ( self , targets. otherwise ( ) ) ;
286
289
if switch_ty == bx. tcx ( ) . types . bool {
287
290
// Don't generate trivial icmps when switching on bool
288
291
match test_value {
@@ -299,8 +302,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
299
302
} else {
300
303
bx. switch (
301
304
discr. immediate ( ) ,
302
- helper. llblock ( self , targets. otherwise ( ) ) ,
303
- target_iter. map ( |( value, target) | ( value, helper. llblock ( self , target) ) ) ,
305
+ helper. llbb_with_cleanup ( self , targets. otherwise ( ) ) ,
306
+ target_iter. map ( |( value, target) | ( value, helper. llbb_with_cleanup ( self , target) ) ) ,
304
307
) ;
305
308
}
306
309
}
@@ -530,7 +533,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
530
533
let cond = bx. expect ( cond, expected) ;
531
534
532
535
// Create the failure block and the conditional branch to it.
533
- let lltarget = helper. llblock ( self , target) ;
536
+ let lltarget = helper. llbb_with_cleanup ( self , target) ;
534
537
let panic_block = bx. append_sibling_block ( "panic" ) ;
535
538
if expected {
536
539
bx. cond_br ( cond, lltarget, panic_block) ;
0 commit comments