Skip to content

Commit bd6a223

Browse files
committed
librustc: De-@mut FunctionContext::llreturn
1 parent a07cee2 commit bd6a223

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16881688
llretptr: Cell::new(None),
16891689
entry_bcx: None,
16901690
alloca_insert_pt: Cell::new(None),
1691-
llreturn: None,
1691+
llreturn: Cell::new(None),
16921692
llself: None,
16931693
personality: None,
16941694
caller_expects_out_pointer: uses_outptr,
@@ -1843,7 +1843,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
18431843
pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @Block) {
18441844
let _icx = push_ctxt("finish_fn");
18451845

1846-
let ret_cx = match fcx.llreturn {
1846+
let ret_cx = match fcx.llreturn.get() {
18471847
Some(llreturn) => {
18481848
if !last_bcx.terminated.get() {
18491849
Br(last_bcx, llreturn);
@@ -1949,15 +1949,16 @@ pub fn trans_closure(ccx: @CrateContext,
19491949
bcx = controlflow::trans_block(bcx, body, dest);
19501950
}
19511951

1952-
match fcx.llreturn {
1952+
match fcx.llreturn.get() {
19531953
Some(llreturn) => cleanup_and_Br(bcx, bcx_top, llreturn),
19541954
None => bcx = cleanup_block(bcx, Some(bcx_top.llbb))
19551955
};
19561956

19571957
// Put return block after all other blocks.
19581958
// This somewhat improves single-stepping experience in debugger.
19591959
unsafe {
1960-
for &llreturn in fcx.llreturn.iter() {
1960+
let llreturn = fcx.llreturn.get();
1961+
for &llreturn in llreturn.iter() {
19611962
llvm::LLVMMoveBasicBlockAfter(llreturn, bcx.llbb);
19621963
}
19631964
}

src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub struct FunctionContext {
222222
// A marker for the place where we want to insert the function's static
223223
// allocas, so that LLVM will coalesce them into a single alloca call.
224224
alloca_insert_pt: Cell<Option<ValueRef>>,
225-
llreturn: Option<BasicBlockRef>,
225+
llreturn: Cell<Option<BasicBlockRef>>,
226226
// The 'self' value currently in use in this function, if there
227227
// is one.
228228
//
@@ -300,11 +300,11 @@ impl FunctionContext {
300300
}
301301

302302
pub fn get_llreturn(&mut self) -> BasicBlockRef {
303-
if self.llreturn.is_none() {
304-
self.llreturn = Some(base::mk_return_basic_block(self.llfn));
303+
if self.llreturn.get().is_none() {
304+
self.llreturn.set(Some(base::mk_return_basic_block(self.llfn)));
305305
}
306306

307-
self.llreturn.unwrap()
307+
self.llreturn.get().unwrap()
308308
}
309309
}
310310

src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl Reflector {
310310
let arg = BitCast(bcx, arg, llptrty);
311311
let ret = adt::trans_get_discr(bcx, repr, arg, Some(Type::i64()));
312312
Store(bcx, ret, fcx.llretptr.get().unwrap());
313-
match fcx.llreturn {
313+
match fcx.llreturn.get() {
314314
Some(llreturn) => cleanup_and_Br(bcx, bcx, llreturn),
315315
None => bcx = cleanup_block(bcx, Some(bcx.llbb))
316316
};

0 commit comments

Comments
 (0)