@@ -1113,8 +1113,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
11131113 llvm:: LLVMGetParam ( fcx. llfn , 0 )
11141114 } else {
11151115 let lloutputtype = type_of:: type_of ( fcx. ccx , output_type) ;
1116- let bcx = fcx. entry_bcx . borrow ( ) . clone ( ) . unwrap ( ) ;
1117- Alloca ( bcx, lloutputtype, "__make_return_pointer" )
1116+ AllocaFcx ( fcx, lloutputtype, "__make_return_pointer" )
11181117 }
11191118 }
11201119}
@@ -1155,7 +1154,6 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11551154 llfn : llfndecl,
11561155 llenv : None ,
11571156 llretptr : Cell :: new ( None ) ,
1158- entry_bcx : RefCell :: new ( None ) ,
11591157 alloca_insert_pt : Cell :: new ( None ) ,
11601158 llreturn : Cell :: new ( None ) ,
11611159 personality : Cell :: new ( None ) ,
@@ -1185,11 +1183,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11851183/// and allocating space for the return pointer.
11861184pub fn init_function < ' a > ( fcx : & ' a FunctionContext < ' a > ,
11871185 skip_retptr : bool ,
1188- output_type : ty:: t ) {
1186+ output_type : ty:: t ) -> & ' a Block < ' a > {
11891187 let entry_bcx = fcx. new_temp_block ( "entry-block" ) ;
11901188
1191- * fcx. entry_bcx . borrow_mut ( ) = Some ( entry_bcx) ;
1192-
11931189 // Use a dummy instruction as the insertion point for all allocas.
11941190 // This is later removed in FunctionContext::cleanup.
11951191 fcx. alloca_insert_pt . set ( Some ( unsafe {
@@ -1211,6 +1207,8 @@ pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
12111207 fcx. llretptr . set ( Some ( make_return_pointer ( fcx, substd_output_type) ) ) ;
12121208 }
12131209 }
1210+
1211+ entry_bcx
12141212}
12151213
12161214// NB: must keep 4 fns in sync:
@@ -1365,15 +1363,11 @@ pub fn trans_closure(ccx: &CrateContext,
13651363 param_substs,
13661364 Some ( body. span) ,
13671365 & arena) ;
1368- init_function( & fcx, false , output_type) ;
1366+ let mut bcx = init_function( & fcx, false , output_type) ;
13691367
13701368 // cleanup scope for the incoming arguments
13711369 let arg_scope = fcx. push_custom_cleanup_scope( ) ;
13721370
1373- // Create the first basic block in the function and keep a handle on it to
1374- // pass to finish_fn later.
1375- let bcx_top = fcx. entry_bcx. borrow( ) . clone( ) . unwrap( ) ;
1376- let mut bcx = bcx_top;
13771371 let block_ty = node_id_type( bcx, body. id) ;
13781372
13791373 // Set up arguments to the function.
@@ -1500,14 +1494,12 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
15001494 let arena = TypedArena :: new( ) ;
15011495 let fcx = new_fn_ctxt( ccx, llfndecl, ctor_id, false , result_ty,
15021496 param_substs, None , & arena) ;
1503- init_function( & fcx, false , result_ty) ;
1497+ let bcx = init_function( & fcx, false , result_ty) ;
15041498
15051499 let arg_tys = ty:: ty_fn_args( ctor_ty) ;
15061500
15071501 let arg_datums = create_datums_for_fn_args( & fcx, arg_tys. as_slice( ) ) ;
15081502
1509- let bcx = fcx. entry_bcx. borrow( ) . clone( ) . unwrap( ) ;
1510-
15111503 if !type_is_zero_size( fcx. ccx, result_ty) {
15121504 let repr = adt:: represent_type( ccx, result_ty) ;
15131505 adt:: trans_start_init( bcx, & * repr, fcx. llretptr. get( ) . unwrap( ) , disr) ;
0 commit comments