提交 f4d8d8c1 编写于 作者: B blake2-ppc

trans::build: Change @mut Block to &Block or &mut Block

Use &mut Block and &Block references where possible in the builder
functions in trans::build.

@mut Block remains in a few functions where I could not (not yet at
least) track down the runtime borrowck failures.
上级 b88517ec
......@@ -1407,7 +1407,10 @@ pub fn cleanup_and_leave(bcx: @mut Block,
}
match leave {
Some(target) => Br(bcx, target),
None => { Resume(bcx, Load(bcx, bcx.fcx.personality.unwrap())); }
None => {
let ll_load = Load(bcx, bcx.fcx.personality.unwrap());
Resume(bcx, ll_load);
}
}
}
......
此差异已折叠。
......@@ -550,7 +550,7 @@ pub fn revoke_clean(cx: @mut Block, val: ValueRef) {
}
}
pub fn block_cleanups(bcx: @mut Block) -> ~[cleanup] {
pub fn block_cleanups(bcx: &mut Block) -> ~[cleanup] {
match bcx.scope {
None => ~[],
Some(inf) => inf.cleanups.clone(),
......@@ -1061,7 +1061,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str {
r
}
pub fn monomorphize_type(bcx: @mut Block, t: ty::t) -> ty::t {
pub fn monomorphize_type(bcx: &mut Block, t: ty::t) -> ty::t {
match bcx.fcx.param_substs {
Some(substs) => {
ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t)
......@@ -1074,23 +1074,23 @@ pub fn monomorphize_type(bcx: @mut Block, t: ty::t) -> ty::t {
}
}
pub fn node_id_type(bcx: @mut Block, id: ast::NodeId) -> ty::t {
pub fn node_id_type(bcx: &mut Block, id: ast::NodeId) -> ty::t {
let tcx = bcx.tcx();
let t = ty::node_id_to_type(tcx, id);
monomorphize_type(bcx, t)
}
pub fn expr_ty(bcx: @mut Block, ex: &ast::Expr) -> ty::t {
pub fn expr_ty(bcx: &mut Block, ex: &ast::Expr) -> ty::t {
node_id_type(bcx, ex.id)
}
pub fn expr_ty_adjusted(bcx: @mut Block, ex: &ast::Expr) -> ty::t {
pub fn expr_ty_adjusted(bcx: &mut Block, ex: &ast::Expr) -> ty::t {
let tcx = bcx.tcx();
let t = ty::expr_ty_adjusted(tcx, ex);
monomorphize_type(bcx, t)
}
pub fn node_id_type_params(bcx: @mut Block, id: ast::NodeId) -> ~[ty::t] {
pub fn node_id_type_params(bcx: &mut Block, id: ast::NodeId) -> ~[ty::t] {
let tcx = bcx.tcx();
let params = ty::node_id_to_type_params(tcx, id);
......
......@@ -552,12 +552,14 @@ pub fn decr_refcnt_maybe_free(bcx: @mut Block, box_ptr: ValueRef,
let decr_bcx = sub_block(bcx, "decr");
let free_bcx = sub_block(decr_bcx, "free");
let next_bcx = sub_block(bcx, "next");
CondBr(bcx, IsNotNull(bcx, box_ptr), decr_bcx.llbb, next_bcx.llbb);
let llnotnull = IsNotNull(bcx, box_ptr);
CondBr(bcx, llnotnull, decr_bcx.llbb, next_bcx.llbb);
let rc_ptr = GEPi(decr_bcx, box_ptr, [0u, abi::box_field_refcnt]);
let rc = Sub(decr_bcx, Load(decr_bcx, rc_ptr), C_int(ccx, 1));
Store(decr_bcx, rc, rc_ptr);
CondBr(decr_bcx, IsNull(decr_bcx, rc), free_bcx.llbb, next_bcx.llbb);
let llisnull = IsNull(decr_bcx, rc);
CondBr(decr_bcx, llisnull, free_bcx.llbb, next_bcx.llbb);
let free_bcx = match box_ptr_ptr {
Some(p) => free_ty(free_bcx, p, t),
......
......@@ -49,7 +49,8 @@ fn simple_llvm_intrinsic(bcx: @mut Block, name: &'static str, num_args: uint) {
args[i] = get_param(bcx.fcx.llfn, first_real_arg + i);
}
let llfn = bcx.ccx().intrinsics.get_copy(&name);
Ret(bcx, Call(bcx, llfn, args.slice(0, num_args), []));
let llcall = Call(bcx, llfn, args.slice(0, num_args), []);
Ret(bcx, llcall);
}
fn with_overflow_instrinsic(bcx: @mut Block, name: &'static str) {
......@@ -116,7 +117,8 @@ fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
let x = get_param(bcx.fcx.llfn, bcx.fcx.arg_pos(0u));
let y = C_i1(false);
let llfn = bcx.ccx().intrinsics.get_copy(&name);
Ret(bcx, Call(bcx, llfn, [x, y], []));
let llcall = Call(bcx, llfn, [x, y], []);
Ret(bcx, llcall);
}
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx, item.id));
......@@ -324,14 +326,19 @@ fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
(Pointer, other) | (other, Pointer) if other != Pointer => {
let tmp = Alloca(bcx, llouttype, "");
Store(bcx, llsrcval, PointerCast(bcx, tmp, llintype.ptr_to()));
Ret(bcx, Load(bcx, tmp));
let ll_load = Load(bcx, tmp);
Ret(bcx, ll_load);
}
_ => {
let llbitcast = BitCast(bcx, llsrcval, llouttype);
Ret(bcx, llbitcast)
}
_ => Ret(bcx, BitCast(bcx, llsrcval, llouttype))
}
}
} else if ty::type_is_immediate(ccx.tcx, out_type) {
let llsrcptr = PointerCast(bcx, llsrcval, llouttype.ptr_to());
Ret(bcx, Load(bcx, llsrcptr));
let ll_load = Load(bcx, llsrcptr);
Ret(bcx, ll_load);
} else {
// NB: Do not use a Load and Store here. This causes massive
// code bloat when `transmute` is used on large structural
......@@ -404,7 +411,8 @@ fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
"offset" => {
let ptr = get_param(decl, first_real_arg);
let offset = get_param(decl, first_real_arg + 1);
Ret(bcx, InBoundsGEP(bcx, ptr, [offset]));
let lladdr = InBoundsGEP(bcx, ptr, [offset]);
Ret(bcx, lladdr);
}
"memcpy32" => memcpy_intrinsic(bcx, "llvm.memcpy.p0i8.p0i8.i32", substs.tys[0], 32),
"memcpy64" => memcpy_intrinsic(bcx, "llvm.memcpy.p0i8.p0i8.i64", substs.tys[0], 64),
......
......@@ -49,7 +49,7 @@ pub fn erase_from_parent(self) {
/// This only performs a search for a trivially dominating store. The store
/// must be the only user of this value, and there must not be any conditional
/// branches between the store and the given block.
pub fn get_dominating_store(self, bcx: @mut Block) -> Option<Value> {
pub fn get_dominating_store(self, bcx: &mut Block) -> Option<Value> {
match self.get_single_user().and_then(|user| user.as_store_inst()) {
Some(store) => {
do store.get_parent().and_then |store_bb| {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册