@@ -63,7 +63,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
6363 }
6464 }
6565
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 > > (
6769 & self ,
6870 fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
6971 target : mir:: BasicBlock ,
@@ -83,17 +85,18 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
8385 }
8486 }
8587
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 > > (
8891 & self ,
8992 fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
9093 target : mir:: BasicBlock ,
9194 ) -> Bx :: BasicBlock {
92- let ( lltarget, is_cleanupret) = self . lltarget ( fx, target) ;
95+ let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
9396 if is_cleanupret {
9497 // MSVC cross-funclet jump - need a trampoline
9598
96- debug ! ( "llblock : creating cleanup trampoline for {:?}" , target) ;
99+ debug ! ( "llbb_with_cleanup : creating cleanup trampoline for {:?}" , target) ;
97100 let name = & format ! ( "{:?}_cleanup_trampoline_{:?}" , self . bb, target) ;
98101 let trampoline_llbb = Bx :: append_block ( fx. cx , fx. llfn , name) ;
99102 let mut trampoline_bx = Bx :: build ( fx. cx , trampoline_llbb) ;
@@ -110,7 +113,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
110113 bx : & mut Bx ,
111114 target : mir:: BasicBlock ,
112115 ) {
113- let ( lltarget, is_cleanupret) = self . lltarget ( fx, target) ;
116+ let ( lltarget, is_cleanupret) = self . llbb_with_landing_pad ( fx, target) ;
114117 if is_cleanupret {
115118 // micro-optimization: generate a `ret` rather than a jump
116119 // to a trampoline.
@@ -138,7 +141,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
138141 let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
139142
140143 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) )
142145 } else if fx. mir [ self . bb ] . is_cleanup
143146 && fn_abi. can_unwind
144147 && !base:: wants_msvc_seh ( fx. cx . tcx ( ) . sess )
@@ -231,7 +234,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
231234 options,
232235 line_spans,
233236 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) ) ) ,
235238 ) ;
236239 } else {
237240 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> {
281284 if target_iter. len ( ) == 1 {
282285 // If there are two targets (one conditional, one fallback), emit br instead of switch
283286 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 ( ) ) ;
286289 if switch_ty == bx. tcx ( ) . types . bool {
287290 // Don't generate trivial icmps when switching on bool
288291 match test_value {
@@ -299,8 +302,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
299302 } else {
300303 bx. switch (
301304 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) ) ) ,
304307 ) ;
305308 }
306309 }
@@ -530,7 +533,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
530533 let cond = bx. expect ( cond, expected) ;
531534
532535 // 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) ;
534537 let panic_block = bx. append_sibling_block ( "panic" ) ;
535538 if expected {
536539 bx. cond_br ( cond, lltarget, panic_block) ;
0 commit comments