librustc: De-@mut FunctionContext::llretptr
This commit is contained in:
parent
d7392bd3ae
commit
5b0401f0e8
5 changed files with 19 additions and 16 deletions
|
|
@ -1685,7 +1685,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
|
|||
llenv: unsafe {
|
||||
Cell::new(llvm::LLVMGetUndef(Type::i8p().to_ref()))
|
||||
},
|
||||
llretptr: None,
|
||||
llretptr: Cell::new(None),
|
||||
entry_bcx: None,
|
||||
alloca_insert_pt: None,
|
||||
llreturn: None,
|
||||
|
|
@ -1721,7 +1721,8 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
|
|||
// Otherwise, we normally allocate the llretptr, unless we
|
||||
// have been instructed to skip it for immediate return
|
||||
// values.
|
||||
fcx.llretptr = Some(make_return_pointer(fcx, substd_output_type));
|
||||
fcx.llretptr.set(Some(make_return_pointer(fcx,
|
||||
substd_output_type)));
|
||||
}
|
||||
}
|
||||
fcx
|
||||
|
|
@ -1858,11 +1859,11 @@ pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @Block) {
|
|||
// Builds the return block for a function.
|
||||
pub fn build_return_block(fcx: &FunctionContext, ret_cx: @Block) {
|
||||
// Return the value if this function immediate; otherwise, return void.
|
||||
if fcx.llretptr.is_none() || fcx.caller_expects_out_pointer {
|
||||
if fcx.llretptr.get().is_none() || fcx.caller_expects_out_pointer {
|
||||
return RetVoid(ret_cx);
|
||||
}
|
||||
|
||||
let retptr = Value(fcx.llretptr.unwrap());
|
||||
let retptr = Value(fcx.llretptr.get().unwrap());
|
||||
let retval = match retptr.get_dominating_store(ret_cx) {
|
||||
// If there's only a single store to the ret slot, we can directly return
|
||||
// the value that was stored and omit the store and the alloca
|
||||
|
|
@ -1877,7 +1878,7 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: @Block) {
|
|||
retval
|
||||
}
|
||||
// Otherwise, load the return value from the ret slot
|
||||
None => Load(ret_cx, fcx.llretptr.unwrap())
|
||||
None => Load(ret_cx, fcx.llretptr.get().unwrap())
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1943,7 +1944,7 @@ pub fn trans_closure(ccx: @CrateContext,
|
|||
if body.expr.is_none() || ty::type_is_voidish(bcx.tcx(), block_ty) {
|
||||
bcx = controlflow::trans_block(bcx, body, expr::Ignore);
|
||||
} else {
|
||||
let dest = expr::SaveIn(fcx.llretptr.unwrap());
|
||||
let dest = expr::SaveIn(fcx.llretptr.get().unwrap());
|
||||
bcx = controlflow::trans_block(bcx, body, dest);
|
||||
}
|
||||
|
||||
|
|
@ -2139,11 +2140,11 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
|
|||
let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);
|
||||
|
||||
let repr = adt::represent_type(ccx, result_ty);
|
||||
adt::trans_start_init(bcx, repr, fcx.llretptr.unwrap(), disr);
|
||||
adt::trans_start_init(bcx, repr, fcx.llretptr.get().unwrap(), disr);
|
||||
for (i, fn_arg) in fn_args.iter().enumerate() {
|
||||
let lldestptr = adt::trans_field_ptr(bcx,
|
||||
repr,
|
||||
fcx.llretptr.unwrap(),
|
||||
fcx.llretptr.get().unwrap(),
|
||||
disr,
|
||||
i);
|
||||
let llarg = {
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ pub struct FunctionContext {
|
|||
// this is an alloca in the function. Otherwise, it's the hidden first
|
||||
// parameter to the function. After function construction, this should
|
||||
// always be Some.
|
||||
llretptr: Option<ValueRef>,
|
||||
llretptr: Cell<Option<ValueRef>>,
|
||||
|
||||
entry_bcx: Option<@Block>,
|
||||
|
||||
|
|
|
|||
|
|
@ -266,7 +266,9 @@ pub fn trans_break_cont(bcx: @Block,
|
|||
Some(bcx) => bcx,
|
||||
// This is a return from a loop body block
|
||||
None => {
|
||||
Store(bcx, C_bool(!to_end), bcx.fcx.llretptr.unwrap());
|
||||
Store(bcx,
|
||||
C_bool(!to_end),
|
||||
bcx.fcx.llretptr.get().unwrap());
|
||||
cleanup_and_leave(bcx, None, Some(bcx.fcx.get_llreturn()));
|
||||
Unreachable(bcx);
|
||||
return bcx;
|
||||
|
|
@ -292,7 +294,7 @@ pub fn trans_cont(bcx: @Block, label_opt: Option<Name>) -> @Block {
|
|||
pub fn trans_ret(bcx: @Block, e: Option<@ast::Expr>) -> @Block {
|
||||
let _icx = push_ctxt("trans_ret");
|
||||
let mut bcx = bcx;
|
||||
let dest = match bcx.fcx.llretptr {
|
||||
let dest = match bcx.fcx.llretptr.get() {
|
||||
None => expr::Ignore,
|
||||
Some(retptr) => expr::SaveIn(retptr),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
|
|||
// NB: This needs to be kept in lockstep with the TypeId struct in
|
||||
// libstd/unstable/intrinsics.rs
|
||||
let val = C_named_struct(type_of::type_of(ccx, output_type), [C_u64(hash)]);
|
||||
match bcx.fcx.llretptr {
|
||||
match bcx.fcx.llretptr.get() {
|
||||
Some(ptr) => {
|
||||
Store(bcx, val, ptr);
|
||||
RetVoid(bcx);
|
||||
|
|
@ -301,7 +301,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
|
|||
"init" => {
|
||||
let tp_ty = substs.tys[0];
|
||||
let lltp_ty = type_of::type_of(ccx, tp_ty);
|
||||
match bcx.fcx.llretptr {
|
||||
match bcx.fcx.llretptr.get() {
|
||||
Some(ptr) => { Store(bcx, C_null(lltp_ty), ptr); RetVoid(bcx); }
|
||||
None if ty::type_is_nil(tp_ty) => RetVoid(bcx),
|
||||
None => Ret(bcx, C_null(lltp_ty)),
|
||||
|
|
@ -349,7 +349,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
|
|||
if !ty::type_is_voidish(ccx.tcx, out_type) {
|
||||
let llsrcval = get_param(decl, first_real_arg);
|
||||
if type_is_immediate(ccx, in_type) {
|
||||
match fcx.llretptr {
|
||||
match fcx.llretptr.get() {
|
||||
Some(llretptr) => {
|
||||
Store(bcx, llsrcval, PointerCast(bcx, llretptr, llintype.ptr_to()));
|
||||
RetVoid(bcx);
|
||||
|
|
@ -379,7 +379,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
|
|||
// NB: Do not use a Load and Store here. This causes massive
|
||||
// code bloat when `transmute` is used on large structural
|
||||
// types.
|
||||
let lldestptr = fcx.llretptr.unwrap();
|
||||
let lldestptr = fcx.llretptr.get().unwrap();
|
||||
let lldestptr = PointerCast(bcx, lldestptr, Type::i8p());
|
||||
let llsrcptr = PointerCast(bcx, llsrcval, Type::i8p());
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ impl Reflector {
|
|||
let mut bcx = fcx.entry_bcx.unwrap();
|
||||
let arg = BitCast(bcx, arg, llptrty);
|
||||
let ret = adt::trans_get_discr(bcx, repr, arg, Some(Type::i64()));
|
||||
Store(bcx, ret, fcx.llretptr.unwrap());
|
||||
Store(bcx, ret, fcx.llretptr.get().unwrap());
|
||||
match fcx.llreturn {
|
||||
Some(llreturn) => cleanup_and_Br(bcx, bcx, llreturn),
|
||||
None => bcx = cleanup_block(bcx, Some(bcx.llbb))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue