librustc: De-@mut FunctionContext::llreturn

This commit is contained in:
Patrick Walton 2013-12-20 20:41:54 -08:00
parent a07cee26a4
commit bd6a2236e1
3 changed files with 10 additions and 9 deletions

View File

@ -1688,7 +1688,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
llretptr: Cell::new(None),
entry_bcx: None,
alloca_insert_pt: Cell::new(None),
llreturn: None,
llreturn: Cell::new(None),
llself: None,
personality: None,
caller_expects_out_pointer: uses_outptr,
@ -1843,7 +1843,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @Block) {
let _icx = push_ctxt("finish_fn");
let ret_cx = match fcx.llreturn {
let ret_cx = match fcx.llreturn.get() {
Some(llreturn) => {
if !last_bcx.terminated.get() {
Br(last_bcx, llreturn);
@ -1949,7 +1949,7 @@ pub fn trans_closure(ccx: @CrateContext,
bcx = controlflow::trans_block(bcx, body, dest);
}
match fcx.llreturn {
match fcx.llreturn.get() {
Some(llreturn) => cleanup_and_Br(bcx, bcx_top, llreturn),
None => bcx = cleanup_block(bcx, Some(bcx_top.llbb))
};
@ -1957,7 +1957,8 @@ pub fn trans_closure(ccx: @CrateContext,
// Put return block after all other blocks.
// This somewhat improves single-stepping experience in debugger.
unsafe {
for &llreturn in fcx.llreturn.iter() {
let llreturn = fcx.llreturn.get();
for &llreturn in llreturn.iter() {
llvm::LLVMMoveBasicBlockAfter(llreturn, bcx.llbb);
}
}

View File

@ -222,7 +222,7 @@ pub struct FunctionContext {
// A marker for the place where we want to insert the function's static
// allocas, so that LLVM will coalesce them into a single alloca call.
alloca_insert_pt: Cell<Option<ValueRef>>,
llreturn: Option<BasicBlockRef>,
llreturn: Cell<Option<BasicBlockRef>>,
// The 'self' value currently in use in this function, if there
// is one.
//
@ -300,11 +300,11 @@ impl FunctionContext {
}
pub fn get_llreturn(&mut self) -> BasicBlockRef {
if self.llreturn.is_none() {
self.llreturn = Some(base::mk_return_basic_block(self.llfn));
if self.llreturn.get().is_none() {
self.llreturn.set(Some(base::mk_return_basic_block(self.llfn)));
}
self.llreturn.unwrap()
self.llreturn.get().unwrap()
}
}

View File

@ -310,7 +310,7 @@ impl Reflector {
let arg = BitCast(bcx, arg, llptrty);
let ret = adt::trans_get_discr(bcx, repr, arg, Some(Type::i64()));
Store(bcx, ret, fcx.llretptr.get().unwrap());
match fcx.llreturn {
match fcx.llreturn.get() {
Some(llreturn) => cleanup_and_Br(bcx, bcx, llreturn),
None => bcx = cleanup_block(bcx, Some(bcx.llbb))
};