use libc::c_uint;
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
-use rustc::ty::layout::{LayoutOf, TyLayout, HasTyCtxt};
+use rustc::ty::layout::{TyLayout, HasTyCtxt};
use rustc::mir::{self, Mir};
use rustc::ty::subst::Substs;
use rustc::session::config::DebugInfo;
let mut allocate_local = |local| {
let decl = &mir.local_decls[local];
- let layout = bx.cx().layout_of(fx.monomorphize(&decl.ty));
+ let layout = bx.layout_of(fx.monomorphize(&decl.ty));
assert!(!layout.ty.has_erasable_regions());
if let Some(name) = decl.name {
// User variable
let debug_scope = fx.scopes[decl.visibility_scope];
let dbg = debug_scope.is_valid() &&
- bx.cx().sess().opts.debuginfo == DebugInfo::Full;
+ bx.sess().opts.debuginfo == DebugInfo::Full;
if !memory_locals.contains(local) && !dbg {
debug!("alloc: {:?} ({}) -> operand", local, name);
if local == mir::RETURN_PLACE && fx.fn_ty.ret.is_indirect() {
debug!("alloc: {:?} (return place) -> place", local);
let llretptr = fx.cx.get_param(llfn, 0);
- LocalRef::Place(PlaceRef::new_sized(llretptr, layout, layout.align))
+ LocalRef::Place(PlaceRef::new_sized(llretptr, layout, layout.align.abi))
} else if memory_locals.contains(local) {
debug!("alloc: {:?} -> place", local);
if layout.is_unsized() {
{
block_bxs.iter_enumerated().zip(cleanup_kinds).map(|((bb, &llbb), cleanup_kind)| {
match *cleanup_kind {
- CleanupKind::Funclet if base::wants_msvc_seh(bx.cx().sess()) => {}
+ CleanupKind::Funclet if base::wants_msvc_seh(bx.sess()) => {}
_ => return (None, None)
}
// C++ personality function, but `catch (...)` has no type so
// it's null. The 64 here is actually a bitfield which
// represents that this is a catch-all block.
- let null = bx.cx().const_null(bx.cx().type_i8p());
- let sixty_four = bx.cx().const_i32(64);
+ let null = bx.const_null(bx.type_i8p());
+ let sixty_four = bx.const_i32(64);
funclet = cp_bx.catch_pad(cs, &[null, sixty_four, null]);
cp_bx.br(llbb);
}
// Get the argument scope, if it exists and if we need it.
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
- let arg_scope = if bx.cx().sess().opts.debuginfo == DebugInfo::Full {
+ let arg_scope = if bx.sess().opts.debuginfo == DebugInfo::Full {
arg_scope.scope_metadata
} else {
None
};
if Some(local) == mir.spread_arg {
- // This argument (e.g. the last argument in the "rust-call" ABI)
+ // This argument (e.g., the last argument in the "rust-call" ABI)
// is a tuple that was spread at the ABI level and now we have
// to reconstruct it into a tuple local variable, from multiple
// individual LLVM function arguments.
_ => bug!("spread argument isn't a tuple?!")
};
- let place = PlaceRef::alloca(bx, bx.cx().layout_of(arg_ty), &name);
+ let place = PlaceRef::alloca(bx, bx.layout_of(arg_ty), &name);
for i in 0..tupled_arg_tys.len() {
let arg = &fx.fn_ty.args[idx];
idx += 1;
return local(OperandRef::new_zst(bx.cx(), arg.layout));
}
PassMode::Direct(_) => {
- let llarg = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let llarg = bx.get_param(bx.llfn(), llarg_idx as c_uint);
bx.set_value_name(llarg, &name);
llarg_idx += 1;
return local(
OperandRef::from_immediate_or_packed_pair(bx, llarg, arg.layout));
}
PassMode::Pair(..) => {
- let a = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let a = bx.get_param(bx.llfn(), llarg_idx as c_uint);
bx.set_value_name(a, &(name.clone() + ".0"));
llarg_idx += 1;
- let b = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let b = bx.get_param(bx.llfn(), llarg_idx as c_uint);
bx.set_value_name(b, &(name + ".1"));
llarg_idx += 1;
// Don't copy an indirect argument to an alloca, the caller
// already put it in a temporary alloca and gave it up.
// FIXME: lifetimes
- let llarg = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let llarg = bx.get_param(bx.llfn(), llarg_idx as c_uint);
bx.set_value_name(llarg, &name);
llarg_idx += 1;
- PlaceRef::new_sized(llarg, arg.layout, arg.layout.align)
+ PlaceRef::new_sized(llarg, arg.layout, arg.layout.align.abi)
} else if arg.is_unsized_indirect() {
// As the storage for the indirect argument lives during
// the whole function call, we just copy the fat pointer.
- let llarg = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let llarg = bx.get_param(bx.llfn(), llarg_idx as c_uint);
llarg_idx += 1;
- let llextra = bx.cx().get_param(bx.llfn(), llarg_idx as c_uint);
+ let llextra = bx.get_param(bx.llfn(), llarg_idx as c_uint);
llarg_idx += 1;
let indirect_operand = OperandValue::Pair(llarg, llextra);
// Or is it the closure environment?
let (closure_layout, env_ref) = match arg.layout.ty.sty {
ty::RawPtr(ty::TypeAndMut { ty, .. }) |
- ty::Ref(_, ty, _) => (bx.cx().layout_of(ty), true),
+ ty::Ref(_, ty, _) => (bx.layout_of(ty), true),
_ => (arg.layout, false)
};
// because that's what the llvm.dbg.declare intrinsic expects.
// FIXME(eddyb) this shouldn't be necessary but SROA seems to
- // mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
+ // mishandle DW_OP_plus not preceded by DW_OP_deref, i.e., it
// doesn't actually strip the offset when splitting the closure
// environment into its components so it ends up out of bounds.
// (cuviper) It seems to be fine without the alloca on LLVM 6 and later.
- let env_alloca = !env_ref && bx.cx().closure_env_needs_indirect_debuginfo();
+ let env_alloca = !env_ref && bx.closure_env_needs_indirect_debuginfo();
let env_ptr = if env_alloca {
let scratch = PlaceRef::alloca(bx,
- bx.cx().layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
+ bx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
"__debuginfo_env_ptr");
bx.store(place.llval, scratch.llval, scratch.align);
scratch.llval
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
- let ops = bx.cx().debuginfo_upvar_decls_ops_sequence(byte_offset_of_var_in_env);
+ let ops = bx.debuginfo_upvar_decls_ops_sequence(byte_offset_of_var_in_env);
// The environment and the capture can each be indirect.