diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f11e343581c..c626ddfc184 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -611,7 +611,8 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac let drop_fn_ty = drop_fn.ty(fx.tcx); match ty.kind { ty::Dynamic(..) => { - let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); + let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(fx); + let ptr = ptr.get_addr(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 9c43f2c80af..d37f05cd986 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -119,7 +119,7 @@ pub fn adjust_arg_for_abi<'tcx>( let (a, b) = arg.load_scalar_pair(fx); Pair(a, b) } - PassMode::ByRef => Single(arg.force_stack(fx)), + PassMode::ByRef => Single(arg.force_stack(fx).get_addr(fx)), } } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 489f52b306f..d566a517664 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -58,7 +58,7 @@ pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { - Some(ret_place) => Some(ret_place.to_addr(fx)), + Some(ret_place) => Some(ret_place.to_ptr(fx).get_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index af0f8b0be6f..44118edb6fd 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -598,7 +598,7 @@ pub fn codegen_intrinsic_call<'tcx>( transmute, (c from) { assert_eq!(from.layout().ty, src_ty); - let addr = Pointer::new(from.force_stack(fx)); + let addr = from.force_stack(fx); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; @@ -633,7 +633,7 @@ pub fn codegen_intrinsic_call<'tcx>( fx.bcx.def_var(mir_var(var), val); } _ => { - let addr = ret.to_addr(fx); + let addr = ret.to_ptr(fx).get_addr(fx); let layout = ret.layout(); fx.bcx.emit_small_memset(fx.module.target_config(), addr, 0, layout.size.bytes(), 1); } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 2d3248b94fa..df690468ccb 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -88,14 +88,14 @@ impl<'tcx> CValue<'tcx> { self.1 } - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { let layout = self.1; match self.0 { - CValueInner::ByRef(ptr) => ptr.get_addr(fx), + CValueInner::ByRef(ptr) => ptr, CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { let cplace = CPlace::new_stack_slot(fx, layout.ty); cplace.write_cvalue(fx, self); - cplace.to_addr(fx) + cplace.to_ptr(fx) } } } @@ -331,10 +331,6 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { - self.to_ptr(fx).get_addr(fx) - } - pub fn to_ptr_maybe_unsized( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, @@ -355,14 +351,6 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn to_addr_maybe_unsized( - self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ) -> (Value, Option) { - let (ptr, extra) = self.to_ptr_maybe_unsized(fx); - (ptr.get_addr(fx), extra) - } - pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { use rustc::hir::Mutability::*; @@ -533,15 +521,15 @@ impl<'tcx> CPlace<'tcx> { pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if has_ptr_meta(fx.tcx, self.layout().ty) { - let (value, extra) = self.to_addr_maybe_unsized(fx); + let (ptr, extra) = self.to_ptr_maybe_unsized(fx); let ptr = CValue::by_val_pair( - value, + ptr.get_addr(fx), extra.expect("unsized type without metadata"), dest.layout(), ); dest.write_cvalue(fx, ptr); } else { - let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); + let ptr = CValue::by_val(self.to_ptr(fx).get_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } }