Skip to content

Remove entry_bcx from FunctionContext #15439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
llvm::LLVMGetParam(fcx.llfn, 0)
} else {
let lloutputtype = type_of::type_of(fcx.ccx, output_type);
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
Alloca(bcx, lloutputtype, "__make_return_pointer")
AllocaFcx(fcx, lloutputtype, "__make_return_pointer")
}
}
}
Expand Down Expand Up @@ -1155,7 +1154,6 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
llfn: llfndecl,
llenv: None,
llretptr: Cell::new(None),
entry_bcx: RefCell::new(None),
alloca_insert_pt: Cell::new(None),
llreturn: Cell::new(None),
personality: Cell::new(None),
Expand Down Expand Up @@ -1185,11 +1183,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
/// and allocating space for the return pointer.
pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
skip_retptr: bool,
output_type: ty::t) {
output_type: ty::t) -> &'a Block<'a> {
let entry_bcx = fcx.new_temp_block("entry-block");

*fcx.entry_bcx.borrow_mut() = Some(entry_bcx);

// Use a dummy instruction as the insertion point for all allocas.
// This is later removed in FunctionContext::cleanup.
fcx.alloca_insert_pt.set(Some(unsafe {
Expand All @@ -1211,6 +1207,8 @@ pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
fcx.llretptr.set(Some(make_return_pointer(fcx, substd_output_type)));
}
}

entry_bcx
}

// NB: must keep 4 fns in sync:
Expand Down Expand Up @@ -1365,15 +1363,11 @@ pub fn trans_closure(ccx: &CrateContext,
param_substs,
Some(body.span),
&arena);
init_function(&fcx, false, output_type);
let mut bcx = init_function(&fcx, false, output_type);

// cleanup scope for the incoming arguments
let arg_scope = fcx.push_custom_cleanup_scope();

// Create the first basic block in the function and keep a handle on it to
// pass to finish_fn later.
let bcx_top = fcx.entry_bcx.borrow().clone().unwrap();
let mut bcx = bcx_top;
let block_ty = node_id_type(bcx, body.id);

// Set up arguments to the function.
Expand Down Expand Up @@ -1500,14 +1494,12 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
let arena = TypedArena::new();
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
param_substs, None, &arena);
init_function(&fcx, false, result_ty);
let bcx = init_function(&fcx, false, result_ty);

let arg_tys = ty::ty_fn_args(ctor_ty);

let arg_datums = create_datums_for_fn_args(&fcx, arg_tys.as_slice());

let bcx = fcx.entry_bcx.borrow().clone().unwrap();

if !type_is_zero_size(fcx.ccx, result_ty) {
let repr = adt::represent_type(ccx, result_ty);
adt::trans_start_init(bcx, &*repr, fcx.llretptr.get().unwrap(), disr);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,9 @@ pub fn trans_unboxing_shim(bcx: &Block,
&empty_param_substs,
None,
&block_arena);
init_function(&fcx, false, return_type);
let mut bcx = init_function(&fcx, false, return_type);

// Create the substituted versions of the self type.
let mut bcx = fcx.entry_bcx.borrow().clone().unwrap();
let arg_scope = fcx.push_custom_cleanup_scope();
let arg_scope_id = cleanup::CustomScope(arg_scope);
let boxed_arg_types = ty::ty_fn_args(boxed_function_type);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
let empty_param_substs = param_substs::empty();
let fcx = new_fn_ctxt(ccx, llfn, -1, true, f.sig.output,
&empty_param_substs, None, &arena);
init_function(&fcx, true, f.sig.output);
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
let bcx = init_function(&fcx, true, f.sig.output);

let args = create_datums_for_fn_args(&fcx,
ty::ty_fn_args(closure_ty)
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ pub struct FunctionContext<'a> {
// always be Some.
pub llretptr: Cell<Option<ValueRef>>,

pub entry_bcx: RefCell<Option<&'a Block<'a>>>,

// These pub elements: "hoisted basic blocks" containing
// administrative activities that have to happen in only one place in
// the function, due to LLVM's quirks.
Expand Down Expand Up @@ -322,8 +320,6 @@ impl<'a> FunctionContext<'a> {
.get()
.unwrap());
}
// Remove the cycle between fcx and bcx, so memory can be freed
*self.entry_bcx.borrow_mut() = None;
}

pub fn get_llreturn(&self) -> BasicBlockRef {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ fn make_generic_glue(ccx: &CrateContext,
let fcx = new_fn_ctxt(ccx, llfn, -1, false, ty::mk_nil(),
&empty_param_substs, None, &arena);

init_function(&fcx, false, ty::mk_nil());
let bcx = init_function(&fcx, false, ty::mk_nil());

lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
ccx.stats.n_glues_created.set(ccx.stats.n_glues_created.get() + 1u);
Expand All @@ -502,7 +502,6 @@ fn make_generic_glue(ccx: &CrateContext,
// llfn is expected be declared to take a parameter of the appropriate
// type, so we don't need to explicitly cast the function parameter.

let bcx = fcx.entry_bcx.borrow().clone().unwrap();
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, fcx.arg_pos(0) as c_uint) };
let bcx = helper(bcx, llrawptr0, t);
finish_fn(&fcx, bcx);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ pub fn trans_intrinsic(ccx: &CrateContext,
let arena = TypedArena::new();
let fcx = new_fn_ctxt(ccx, decl, item.id, false, output_type,
substs, Some(item.span), &arena);
init_function(&fcx, true, output_type);
let mut bcx = init_function(&fcx, true, output_type);

set_always_inline(fcx.llfn);

let mut bcx = fcx.entry_bcx.borrow().clone().unwrap();
let first_real_arg = fcx.arg_pos(0u);

let name = token::get_ident(item.ident);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
let fcx = new_fn_ctxt(ccx, llfdecl, -1, false,
ty::mk_u64(), &empty_param_substs,
None, &arena);
init_function(&fcx, false, ty::mk_u64());
let bcx = init_function(&fcx, false, ty::mk_u64());

let arg = unsafe {
//
Expand All @@ -323,7 +323,6 @@ impl<'a, 'b> Reflector<'a, 'b> {
//
llvm::LLVMGetParam(llfdecl, fcx.arg_pos(0u) as c_uint)
};
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
let arg = BitCast(bcx, arg, llptrty);
let ret = adt::trans_get_discr(bcx, &*repr, arg, Some(Type::i64(ccx)));
Store(bcx, ret, fcx.llretptr.get().unwrap());
Expand Down