Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
abi: add AddressSpace field to Primitive::Pointer ...and remove it from `PointeeInfo`, which isn't meant for this. There are still various places (marked with FIXMEs) that assume all pointers have the same size and alignment. Fixing this requires parsing non-default address spaces in the data layout string (and various other changes), which will be done in a followup. (That is, if it's actually worth it to support multiple different pointer sizes. There is a lot of code that would be affected by that.) Fixes #106367 r? ``@oli-obk`` cc ``@Patryk27``
This commit is contained in:
commit
a8b5e5d9db
28 changed files with 235 additions and 203 deletions
|
@ -244,7 +244,7 @@ fn adjust_for_rust_scalar<'tcx>(
|
|||
}
|
||||
|
||||
// Only pointer types handled below.
|
||||
let Scalar::Initialized { value: Pointer, valid_range} = scalar else { return };
|
||||
let Scalar::Initialized { value: Pointer(_), valid_range} = scalar else { return };
|
||||
|
||||
if !valid_range.contains(0) {
|
||||
attrs.set(ArgAttribute::NonNull);
|
||||
|
@ -479,7 +479,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
|
|||
}
|
||||
|
||||
let size = arg.layout.size;
|
||||
if arg.layout.is_unsized() || size > Pointer.size(cx) {
|
||||
if arg.layout.is_unsized() || size > Pointer(AddressSpace::DATA).size(cx) {
|
||||
arg.make_indirect();
|
||||
} else {
|
||||
// We want to pass small aggregates as immediates, but using
|
||||
|
|
|
@ -134,7 +134,7 @@ fn layout_of_uncached<'tcx>(
|
|||
ty::FloatTy::F64 => F64,
|
||||
}),
|
||||
ty::FnPtr(_) => {
|
||||
let mut ptr = scalar_unit(Pointer);
|
||||
let mut ptr = scalar_unit(Pointer(dl.instruction_address_space));
|
||||
ptr.valid_range_mut().start = 1;
|
||||
tcx.intern_layout(LayoutS::scalar(cx, ptr))
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ fn layout_of_uncached<'tcx>(
|
|||
|
||||
// Potentially-wide pointers.
|
||||
ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
let mut data_ptr = scalar_unit(Pointer);
|
||||
let mut data_ptr = scalar_unit(Pointer(AddressSpace::DATA));
|
||||
if !ty.is_unsafe_ptr() {
|
||||
data_ptr.valid_range_mut().start = 1;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ fn layout_of_uncached<'tcx>(
|
|||
}
|
||||
ty::Slice(_) | ty::Str => scalar_unit(Int(dl.ptr_sized_integer(), false)),
|
||||
ty::Dynamic(..) => {
|
||||
let mut vtable = scalar_unit(Pointer);
|
||||
let mut vtable = scalar_unit(Pointer(AddressSpace::DATA));
|
||||
vtable.valid_range_mut().start = 1;
|
||||
vtable
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn layout_of_uncached<'tcx>(
|
|||
ty::Dynamic(_, _, ty::DynStar) => {
|
||||
let mut data = scalar_unit(Int(dl.ptr_sized_integer(), false));
|
||||
data.valid_range_mut().start = 0;
|
||||
let mut vtable = scalar_unit(Pointer);
|
||||
let mut vtable = scalar_unit(Pointer(AddressSpace::DATA));
|
||||
vtable.valid_range_mut().start = 1;
|
||||
tcx.intern_layout(cx.scalar_pair(data, vtable))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue