@@ -1112,8 +1112,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
11121112 llvm:: LLVMGetParam ( fcx. llfn , 0 )
11131113 } else {
11141114 let lloutputtype = type_of:: type_of ( fcx. ccx , output_type) ;
1115- let bcx = fcx. entry_bcx . borrow ( ) . clone ( ) . unwrap ( ) ;
1116- Alloca ( bcx, lloutputtype, "__make_return_pointer" )
1115+ AllocaFcx ( fcx, lloutputtype, "__make_return_pointer" )
11171116 }
11181117 }
11191118}
@@ -1154,7 +1153,6 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11541153 llfn : llfndecl,
11551154 llenv : None ,
11561155 llretptr : Cell :: new ( None ) ,
1157- entry_bcx : RefCell :: new ( None ) ,
11581156 alloca_insert_pt : Cell :: new ( None ) ,
11591157 llreturn : Cell :: new ( None ) ,
11601158 personality : Cell :: new ( None ) ,
@@ -1184,11 +1182,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11841182/// and allocating space for the return pointer.
11851183pub fn init_function < ' a > ( fcx : & ' a FunctionContext < ' a > ,
11861184 skip_retptr : bool ,
1187- output_type : ty:: t ) {
1185+ output_type : ty:: t ) -> & ' a Block < ' a > {
11881186 let entry_bcx = fcx. new_temp_block ( "entry-block" ) ;
11891187
1190- * fcx. entry_bcx . borrow_mut ( ) = Some ( entry_bcx) ;
1191-
11921188 // Use a dummy instruction as the insertion point for all allocas.
11931189 // This is later removed in FunctionContext::cleanup.
11941190 fcx. alloca_insert_pt . set ( Some ( unsafe {
@@ -1210,6 +1206,8 @@ pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
12101206 fcx. llretptr . set ( Some ( make_return_pointer ( fcx, substd_output_type) ) ) ;
12111207 }
12121208 }
1209+
1210+ entry_bcx
12131211}
12141212
12151213// NB: must keep 4 fns in sync:
@@ -1364,15 +1362,11 @@ pub fn trans_closure(ccx: &CrateContext,
13641362 param_substs,
13651363 Some ( body. span) ,
13661364 & arena) ;
1367- init_function( & fcx, false , output_type) ;
1365+ let mut bcx = init_function( & fcx, false , output_type) ;
13681366
13691367 // cleanup scope for the incoming arguments
13701368 let arg_scope = fcx. push_custom_cleanup_scope( ) ;
13711369
1372- // Create the first basic block in the function and keep a handle on it to
1373- // pass to finish_fn later.
1374- let bcx_top = fcx. entry_bcx. borrow( ) . clone( ) . unwrap( ) ;
1375- let mut bcx = bcx_top;
13761370 let block_ty = node_id_type( bcx, body. id) ;
13771371
13781372 // Set up arguments to the function.
@@ -1499,14 +1493,12 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
14991493 let arena = TypedArena :: new( ) ;
15001494 let fcx = new_fn_ctxt( ccx, llfndecl, ctor_id, false , result_ty,
15011495 param_substs, None , & arena) ;
1502- init_function( & fcx, false , result_ty) ;
1496+ let bcx = init_function( & fcx, false , result_ty) ;
15031497
15041498 let arg_tys = ty:: ty_fn_args( ctor_ty) ;
15051499
15061500 let arg_datums = create_datums_for_fn_args( & fcx, arg_tys. as_slice( ) ) ;
15071501
1508- let bcx = fcx. entry_bcx. borrow( ) . clone( ) . unwrap( ) ;
1509-
15101502 if !type_is_zero_size( fcx. ccx, result_ty) {
15111503 let repr = adt:: represent_type( ccx, result_ty) ;
15121504 adt:: trans_start_init( bcx, & * repr, fcx. llretptr. get( ) . unwrap( ) , disr) ;
0 commit comments