Remove *_builder
This commit is contained in:
parent
e77d928990
commit
ad0a901d37
@ -494,19 +494,13 @@ fn assert_discr_in_range(min: Disr, max: Disr, discr: Disr) {
|
||||
}
|
||||
|
||||
/// Access a field, at a point when the value's case is known.
|
||||
pub fn trans_field_ptr<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>, t: Ty<'tcx>,
|
||||
val: MaybeSizedValue, discr: Disr, ix: usize) -> ValueRef {
|
||||
trans_field_ptr_builder(bcx, t, val, discr, ix)
|
||||
}
|
||||
|
||||
/// Access a field, at a point when the value's case is known.
|
||||
pub fn trans_field_ptr_builder<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
pub fn trans_field_ptr<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
t: Ty<'tcx>,
|
||||
val: MaybeSizedValue,
|
||||
discr: Disr, ix: usize)
|
||||
-> ValueRef {
|
||||
let l = bcx.ccx().layout_of(t);
|
||||
debug!("trans_field_ptr_builder on {} represented as {:#?}", t, l);
|
||||
debug!("trans_field_ptr on {} represented as {:#?}", t, l);
|
||||
// Note: if this ever needs to generate conditionals (e.g., if we
|
||||
// decide to do some kind of cdr-coding-like non-unique repr
|
||||
// someday), it will need to return a possibly-new bcx as well.
|
||||
|
@ -172,22 +172,14 @@ impl<'a, 'tcx> Drop for StatRecorder<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_meta(bcx: &BlockAndBuilder, fat_ptr: ValueRef) -> ValueRef {
|
||||
pub fn get_meta(bcx: &Builder, fat_ptr: ValueRef) -> ValueRef {
|
||||
bcx.struct_gep(fat_ptr, abi::FAT_PTR_EXTRA)
|
||||
}
|
||||
|
||||
pub fn get_dataptr(bcx: &BlockAndBuilder, fat_ptr: ValueRef) -> ValueRef {
|
||||
pub fn get_dataptr(bcx: &Builder, fat_ptr: ValueRef) -> ValueRef {
|
||||
bcx.struct_gep(fat_ptr, abi::FAT_PTR_ADDR)
|
||||
}
|
||||
|
||||
pub fn get_meta_builder(b: &Builder, fat_ptr: ValueRef) -> ValueRef {
|
||||
b.struct_gep(fat_ptr, abi::FAT_PTR_EXTRA)
|
||||
}
|
||||
|
||||
pub fn get_dataptr_builder(b: &Builder, fat_ptr: ValueRef) -> ValueRef {
|
||||
b.struct_gep(fat_ptr, abi::FAT_PTR_ADDR)
|
||||
}
|
||||
|
||||
fn require_alloc_fn<'blk, 'tcx>(
|
||||
bcx: &BlockAndBuilder<'blk, 'tcx>, info_ty: Ty<'tcx>, it: LangItem
|
||||
) -> DefId {
|
||||
@ -516,13 +508,7 @@ pub fn call_assume<'a, 'tcx>(b: &Builder<'a, 'tcx>, val: ValueRef) {
|
||||
/// Helper for loading values from memory. Does the necessary conversion if the in-memory type
|
||||
/// differs from the type used for SSA values. Also handles various special cases where the type
|
||||
/// gives us better information about what we are loading.
|
||||
pub fn load_ty<'blk, 'tcx>(
|
||||
cx: &BlockAndBuilder<'blk, 'tcx>, ptr: ValueRef, t: Ty<'tcx>
|
||||
) -> ValueRef {
|
||||
load_ty_builder(cx, ptr, t)
|
||||
}
|
||||
|
||||
pub fn load_ty_builder<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
|
||||
pub fn load_ty<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
|
||||
let ccx = b.ccx;
|
||||
if type_is_zero_size(ccx, t) {
|
||||
return C_undef(type_of::type_of(ccx, t));
|
||||
@ -581,22 +567,14 @@ pub fn store_fat_ptr<'blk, 'tcx>(cx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
cx.store(extra, get_meta(cx, dst));
|
||||
}
|
||||
|
||||
pub fn load_fat_ptr<'blk, 'tcx>(cx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
src: ValueRef,
|
||||
ty: Ty<'tcx>)
|
||||
-> (ValueRef, ValueRef)
|
||||
{
|
||||
load_fat_ptr_builder(cx, src, ty)
|
||||
}
|
||||
|
||||
pub fn load_fat_ptr_builder<'a, 'tcx>(
|
||||
pub fn load_fat_ptr<'a, 'tcx>(
|
||||
b: &Builder<'a, 'tcx>,
|
||||
src: ValueRef,
|
||||
t: Ty<'tcx>)
|
||||
-> (ValueRef, ValueRef)
|
||||
{
|
||||
|
||||
let ptr = get_dataptr_builder(b, src);
|
||||
let ptr = get_dataptr(b, src);
|
||||
let ptr = if t.is_region_ptr() || t.is_unique() {
|
||||
b.load_nonnull(ptr)
|
||||
} else {
|
||||
@ -604,7 +582,7 @@ pub fn load_fat_ptr_builder<'a, 'tcx>(
|
||||
};
|
||||
|
||||
// FIXME: emit metadata on `meta`.
|
||||
let meta = b.load(get_meta_builder(b, src));
|
||||
let meta = b.load(get_meta(b, src));
|
||||
|
||||
(ptr, meta)
|
||||
}
|
||||
@ -647,58 +625,40 @@ pub fn with_cond<'blk, 'tcx, F>(
|
||||
|
||||
pub enum Lifetime { Start, End }
|
||||
|
||||
// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
|
||||
// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
|
||||
// and the intrinsic for `lt` and passes them to `emit`, which is in
|
||||
// charge of generating code to call the passed intrinsic on whatever
|
||||
// block of generated code is targetted for the intrinsic.
|
||||
//
|
||||
// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
|
||||
// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
|
||||
fn core_lifetime_emit<'blk, 'tcx, F>(ccx: &'blk CrateContext<'blk, 'tcx>,
|
||||
ptr: ValueRef,
|
||||
lt: Lifetime,
|
||||
emit: F)
|
||||
where F: FnOnce(&'blk CrateContext<'blk, 'tcx>, machine::llsize, ValueRef)
|
||||
{
|
||||
if ccx.sess().opts.optimize == config::OptLevel::No {
|
||||
return;
|
||||
}
|
||||
|
||||
let _icx = push_ctxt(match lt {
|
||||
Lifetime::Start => "lifetime_start",
|
||||
Lifetime::End => "lifetime_end"
|
||||
});
|
||||
|
||||
let size = machine::llsize_of_alloc(ccx, val_ty(ptr).element_type());
|
||||
if size == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let lifetime_intrinsic = ccx.get_intrinsic(match lt {
|
||||
Lifetime::Start => "llvm.lifetime.start",
|
||||
Lifetime::End => "llvm.lifetime.end"
|
||||
});
|
||||
emit(ccx, size, lifetime_intrinsic)
|
||||
}
|
||||
|
||||
impl Lifetime {
|
||||
// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
|
||||
// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
|
||||
// and the intrinsic for `lt` and passes them to `emit`, which is in
|
||||
// charge of generating code to call the passed intrinsic on whatever
|
||||
// block of generated code is targetted for the intrinsic.
|
||||
//
|
||||
// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
|
||||
// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
|
||||
pub fn call(self, b: &Builder, ptr: ValueRef) {
|
||||
core_lifetime_emit(b.ccx, ptr, self, |ccx, size, lifetime_intrinsic| {
|
||||
let ptr = b.pointercast(ptr, Type::i8p(ccx));
|
||||
b.call(lifetime_intrinsic, &[C_u64(ccx, size), ptr], None);
|
||||
if b.ccx.sess().opts.optimize == config::OptLevel::No {
|
||||
return;
|
||||
}
|
||||
|
||||
let _icx = push_ctxt(match self {
|
||||
Lifetime::Start => "lifetime_start",
|
||||
Lifetime::End => "lifetime_end"
|
||||
});
|
||||
|
||||
let size = machine::llsize_of_alloc(b.ccx, val_ty(ptr).element_type());
|
||||
if size == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let lifetime_intrinsic = b.ccx.get_intrinsic(match self {
|
||||
Lifetime::Start => "llvm.lifetime.start",
|
||||
Lifetime::End => "llvm.lifetime.end"
|
||||
});
|
||||
|
||||
let ptr = b.pointercast(ptr, Type::i8p(b.ccx));
|
||||
b.call(lifetime_intrinsic, &[C_u64(b.ccx, size), ptr], None);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_lifetime_start(bcx: &BlockAndBuilder, ptr: ValueRef) {
|
||||
Lifetime::Start.call(bcx, ptr);
|
||||
}
|
||||
|
||||
pub fn call_lifetime_end(bcx: &BlockAndBuilder, ptr: ValueRef) {
|
||||
Lifetime::End.call(bcx, ptr);
|
||||
}
|
||||
|
||||
// Generates code for resumption of unwind at the end of a landing pad.
|
||||
pub fn trans_unwind_resume(bcx: &BlockAndBuilder, lpval: ValueRef) {
|
||||
if !bcx.sess().target.target.options.custom_unwind_resume {
|
||||
|
@ -1103,14 +1103,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_case(s: ValueRef, on_val: ValueRef, dest: BasicBlockRef) {
|
||||
pub fn add_case(&self, s: ValueRef, on_val: ValueRef, dest: BasicBlockRef) {
|
||||
unsafe {
|
||||
if llvm::LLVMIsUndef(s) == llvm::True { return; }
|
||||
llvm::LLVMAddCase(s, on_val, dest)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_incoming_to_phi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
||||
pub fn add_incoming_to_phi(&self, phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
||||
unsafe {
|
||||
if llvm::LLVMIsUndef(phi) == llvm::True { return; }
|
||||
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
|
||||
|
@ -117,7 +117,7 @@
|
||||
pub use self::EarlyExitLabel::*;
|
||||
|
||||
use llvm::{BasicBlockRef, ValueRef};
|
||||
use base;
|
||||
use base::{self, Lifetime};
|
||||
use common;
|
||||
use common::{BlockAndBuilder, FunctionContext, LandingPad};
|
||||
use debuginfo::{DebugLoc};
|
||||
@ -422,7 +422,7 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
|
||||
let addr = self.landingpad_alloca.get()
|
||||
.unwrap();
|
||||
let lp = bcx.load(addr);
|
||||
base::call_lifetime_end(&bcx, addr);
|
||||
Lifetime::End.call(&bcx, addr);
|
||||
base::trans_unwind_resume(&bcx, lp);
|
||||
}
|
||||
UnwindKind::CleanupPad(_) => {
|
||||
@ -559,9 +559,8 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
|
||||
let addr = match self.landingpad_alloca.get() {
|
||||
Some(addr) => addr,
|
||||
None => {
|
||||
let addr = base::alloca(&pad_bcx, common::val_ty(llretval),
|
||||
"");
|
||||
base::call_lifetime_start(&pad_bcx, addr);
|
||||
let addr = base::alloca(&pad_bcx, common::val_ty(llretval), "");
|
||||
Lifetime::Start.call(&pad_bcx, addr);
|
||||
self.landingpad_alloca.set(Some(addr));
|
||||
addr
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
use session::Session;
|
||||
use llvm;
|
||||
use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind};
|
||||
use llvm::{True, False, Bool, OperandBundleDef};
|
||||
use llvm::{True, False, Bool, OperandBundleDef, get_param};
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::map::DefPathData;
|
||||
|
@ -23,7 +23,6 @@ use rustc::ty::{self, AdtKind, Ty, TyCtxt, TypeFoldable};
|
||||
use adt;
|
||||
use base::*;
|
||||
use callee::{Callee};
|
||||
use builder::Builder;
|
||||
use common::*;
|
||||
use machine::*;
|
||||
use monomorphize;
|
||||
@ -164,10 +163,10 @@ pub fn drop_ty_immediate<'blk, 'tcx>(bcx: BlockAndBuilder<'blk, 'tcx>,
|
||||
-> BlockAndBuilder<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("drop_ty_immediate");
|
||||
let vp = alloc_ty(&bcx, t, "");
|
||||
call_lifetime_start(&bcx, vp);
|
||||
Lifetime::Start.call(&bcx, vp);
|
||||
store_ty(&bcx, v, vp, t);
|
||||
let bcx = drop_ty_core(bcx, vp, t, skip_dtor);
|
||||
call_lifetime_end(&bcx, vp);
|
||||
Lifetime::End.call(&bcx, vp);
|
||||
bcx
|
||||
}
|
||||
|
||||
@ -602,7 +601,7 @@ fn drop_structural_ty<'blk, 'tcx>(cx: BlockAndBuilder<'blk, 'tcx>,
|
||||
&variant.disr_val.to_string());
|
||||
let variant_cx = fcx.new_block(&variant_cx_name).build();
|
||||
let case_val = adt::trans_case(&cx, t, Disr::from(variant.disr_val));
|
||||
Builder::add_case(llswitch, case_val, variant_cx.llbb());
|
||||
variant_cx.add_case(llswitch, case_val, variant_cx.llbb());
|
||||
let variant_cx = iter_variant(variant_cx, t, value, variant, substs);
|
||||
variant_cx.br(next_cx.llbb());
|
||||
}
|
||||
|
@ -15,11 +15,10 @@ use rustc::ty::{self, layout};
|
||||
use rustc::mir;
|
||||
use abi::{Abi, FnType, ArgType};
|
||||
use adt;
|
||||
use base;
|
||||
use base::{self, Lifetime};
|
||||
use callee::{Callee, CalleeData, Fn, Intrinsic, NamedTupleConstructor, Virtual};
|
||||
use common::{self, Block, BlockAndBuilder, LandingPad};
|
||||
use common::{C_bool, C_str_slice, C_struct, C_u32, C_undef};
|
||||
use builder::Builder;
|
||||
use consts;
|
||||
use debuginfo::DebugLoc;
|
||||
use Disr;
|
||||
@ -122,7 +121,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
|
||||
let ps = self.get_personality_slot(&bcx);
|
||||
let lp = bcx.load(ps);
|
||||
base::call_lifetime_end(&bcx, ps);
|
||||
Lifetime::End.call(&bcx, ps);
|
||||
base::trans_unwind_resume(&bcx, lp);
|
||||
}
|
||||
}
|
||||
@ -167,7 +166,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
if default_bb != Some(target) {
|
||||
let llbb = llblock(self, target);
|
||||
let llval = adt::trans_case(&bcx, ty, Disr::from(adt_variant.disr_val));
|
||||
Builder::add_case(switch, llval, llbb)
|
||||
bcx.add_case(switch, llval, llbb)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,7 +179,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
for (value, target) in values.iter().zip(targets) {
|
||||
let val = Const::from_constval(bcx.ccx(), value.clone(), switch_ty);
|
||||
let llbb = llblock(self, *target);
|
||||
Builder::add_case(switch, val.llval, llbb)
|
||||
bcx.add_case(switch, val.llval, llbb)
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +255,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
// here that can be cleanly backported to beta, so
|
||||
// I want to avoid touching all of trans.
|
||||
let scratch = base::alloc_ty(&bcx, ty, "drop");
|
||||
base::call_lifetime_start(&bcx, scratch);
|
||||
Lifetime::Start.call(&bcx, scratch);
|
||||
bcx.store(lvalue.llval, base::get_dataptr(&bcx, scratch));
|
||||
bcx.store(lvalue.llextra, base::get_meta(&bcx, scratch));
|
||||
scratch
|
||||
@ -478,7 +477,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
// here that can be cleanly backported to beta, so
|
||||
// I want to avoid touching all of trans.
|
||||
let scratch = base::alloc_ty(&bcx, ty, "drop");
|
||||
base::call_lifetime_start(&bcx, scratch);
|
||||
Lifetime::Start.call(&bcx, scratch);
|
||||
bcx.store(llval, base::get_dataptr(&bcx, scratch));
|
||||
bcx.store(llextra, base::get_meta(&bcx, scratch));
|
||||
scratch
|
||||
@ -752,9 +751,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
Ref(llval) => {
|
||||
let base = adt::MaybeSizedValue::sized(llval);
|
||||
for (n, &ty) in arg_types.iter().enumerate() {
|
||||
let ptr = adt::trans_field_ptr_builder(bcx, tuple.ty, base, Disr(0), n);
|
||||
let ptr = adt::trans_field_ptr(bcx, tuple.ty, base, Disr(0), n);
|
||||
let val = if common::type_is_fat_ptr(bcx.tcx(), ty) {
|
||||
let (lldata, llextra) = base::load_fat_ptr_builder(bcx, ptr, ty);
|
||||
let (lldata, llextra) = base::load_fat_ptr(bcx, ptr, ty);
|
||||
Pair(lldata, llextra)
|
||||
} else {
|
||||
// trans_argument will load this if it needs to
|
||||
@ -817,7 +816,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let llretty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)], false);
|
||||
let slot = base::alloca(bcx, llretty, "personalityslot");
|
||||
self.llpersonalityslot = Some(slot);
|
||||
base::call_lifetime_start(bcx, slot);
|
||||
Lifetime::Start.call(bcx, slot);
|
||||
slot
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
} else {
|
||||
adt::MaybeSizedValue::unsized_(tr_base.llval, tr_base.llextra)
|
||||
};
|
||||
let llprojected = adt::trans_field_ptr_builder(bcx, base_ty, base,
|
||||
Disr(discr), field.index());
|
||||
let llprojected = adt::trans_field_ptr(bcx, base_ty, base, Disr(discr),
|
||||
field.index());
|
||||
let llextra = if is_sized {
|
||||
ptr::null_mut()
|
||||
} else {
|
||||
|
@ -361,10 +361,8 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
|
||||
// they are the two sub-fields of a single aggregate field.
|
||||
let meta = &fcx.fn_ty.args[idx];
|
||||
idx += 1;
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx,
|
||||
base::get_dataptr_builder(bcx, dst));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx,
|
||||
base::get_meta_builder(bcx, dst));
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, base::get_dataptr(bcx, dst));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx, base::get_meta(bcx, dst));
|
||||
} else {
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, dst);
|
||||
}
|
||||
@ -436,10 +434,8 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
|
||||
// so make an alloca to store them in.
|
||||
let meta = &fcx.fn_ty.args[idx];
|
||||
idx += 1;
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx,
|
||||
base::get_dataptr_builder(bcx, lltemp));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx,
|
||||
base::get_meta_builder(bcx, lltemp));
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, base::get_dataptr(bcx, lltemp));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx, base::get_meta(bcx, lltemp));
|
||||
} else {
|
||||
// otherwise, arg is passed by value, so make a
|
||||
// temporary and store it there
|
||||
|
@ -144,7 +144,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
debug!("trans_load: {:?} @ {:?}", Value(llval), ty);
|
||||
|
||||
let val = if common::type_is_fat_ptr(bcx.tcx(), ty) {
|
||||
let (lldata, llextra) = base::load_fat_ptr_builder(bcx, llval, ty);
|
||||
let (lldata, llextra) = base::load_fat_ptr(bcx, llval, ty);
|
||||
OperandValue::Pair(lldata, llextra)
|
||||
} else if common::type_is_imm_pair(bcx.ccx(), ty) {
|
||||
let [a_ty, b_ty] = common::type_pair_fields(bcx.ccx(), ty).unwrap();
|
||||
@ -152,11 +152,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let b_ptr = bcx.struct_gep(llval, 1);
|
||||
|
||||
OperandValue::Pair(
|
||||
base::load_ty_builder(bcx, a_ptr, a_ty),
|
||||
base::load_ty_builder(bcx, b_ptr, b_ty)
|
||||
base::load_ty(bcx, a_ptr, a_ty),
|
||||
base::load_ty(bcx, b_ptr, b_ty)
|
||||
)
|
||||
} else if common::type_is_immediate(bcx.ccx(), ty) {
|
||||
OperandValue::Immediate(base::load_ty_builder(bcx, llval, ty))
|
||||
OperandValue::Immediate(base::load_ty(bcx, llval, ty))
|
||||
} else {
|
||||
OperandValue::Ref(llval)
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let tr_elem = self.trans_operand(&bcx, elem);
|
||||
let size = count.value.as_u64(bcx.tcx().sess.target.uint_type);
|
||||
let size = C_uint(bcx.ccx(), size);
|
||||
let base = base::get_dataptr_builder(&bcx, dest.llval);
|
||||
let base = base::get_dataptr(&bcx, dest.llval);
|
||||
let bcx = tvec::slice_for_each(bcx, base, tr_elem.ty, size, |bcx, llslot| {
|
||||
self.store_operand_direct(&bcx, llslot, tr_elem);
|
||||
bcx
|
||||
@ -109,17 +109,16 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
match *kind {
|
||||
mir::AggregateKind::Adt(adt_def, variant_index, _, active_field_index) => {
|
||||
let disr = Disr::from(adt_def.variants[variant_index].disr_val);
|
||||
adt::trans_set_discr(&bcx,
|
||||
dest.ty.to_ty(bcx.tcx()), dest.llval, Disr::from(disr));
|
||||
let dest_ty = dest.ty.to_ty(bcx.tcx());
|
||||
adt::trans_set_discr(&bcx, dest_ty, dest.llval, Disr::from(disr));
|
||||
for (i, operand) in operands.iter().enumerate() {
|
||||
let op = self.trans_operand(&bcx, operand);
|
||||
// Do not generate stores and GEPis for zero-sized fields.
|
||||
if !common::type_is_zero_size(bcx.ccx(), op.ty) {
|
||||
let val = adt::MaybeSizedValue::sized(dest.llval);
|
||||
let field_index = active_field_index.unwrap_or(i);
|
||||
let lldest_i = adt::trans_field_ptr_builder(&bcx,
|
||||
dest.ty.to_ty(bcx.tcx()),
|
||||
val, disr, field_index);
|
||||
let lldest_i = adt::trans_field_ptr(&bcx, dest_ty, val, disr,
|
||||
field_index);
|
||||
self.store_operand(&bcx, lldest_i, op);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ use llvm;
|
||||
use llvm::ValueRef;
|
||||
use base::*;
|
||||
use common::*;
|
||||
use builder::Builder;
|
||||
use rustc::ty::Ty;
|
||||
|
||||
pub fn slice_for_each<'blk, 'tcx, F>(bcx: BlockAndBuilder<'blk, 'tcx>,
|
||||
@ -61,7 +60,7 @@ pub fn slice_for_each<'blk, 'tcx, F>(bcx: BlockAndBuilder<'blk, 'tcx>,
|
||||
} else {
|
||||
body_bcx.inbounds_gep(current, &[C_uint(bcx.ccx(), 1usize)])
|
||||
};
|
||||
Builder::add_incoming_to_phi(current, next, body_bcx.llbb());
|
||||
body_bcx.add_incoming_to_phi(current, next, body_bcx.llbb());
|
||||
body_bcx.br(header_bcx.llbb());
|
||||
next_bcx
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user