remove the 'dereferenceable' attribute from Box
This commit is contained in:
parent
083b5a0a1b
commit
be079117f0
@ -2526,9 +2526,15 @@ where
|
|||||||
|
|
||||||
if let Some(pointee) = layout.pointee_info_at(cx, offset) {
|
if let Some(pointee) = layout.pointee_info_at(cx, offset) {
|
||||||
if let Some(kind) = pointee.safe {
|
if let Some(kind) = pointee.safe {
|
||||||
attrs.pointee_size = pointee.size;
|
|
||||||
attrs.pointee_align = Some(pointee.align);
|
attrs.pointee_align = Some(pointee.align);
|
||||||
|
|
||||||
|
// `Box` (`UniqueBorrowed`) are not necessarily dereferencable
|
||||||
|
// for the entire duration of the function, so set their size to 0.
|
||||||
|
attrs.pointee_size = match kind {
|
||||||
|
PointerKind::UniqueOwned => Size::ZERO,
|
||||||
|
_ => pointee.size
|
||||||
|
};
|
||||||
|
|
||||||
// `Box` pointer parameters never alias because ownership is transferred
|
// `Box` pointer parameters never alias because ownership is transferred
|
||||||
// `&mut` pointer parameters never alias other parameters,
|
// `&mut` pointer parameters never alias other parameters,
|
||||||
// or mutable global data
|
// or mutable global data
|
||||||
|
@ -69,6 +69,7 @@ mod attr_impl {
|
|||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct ArgAttributes {
|
pub struct ArgAttributes {
|
||||||
pub regular: ArgAttribute,
|
pub regular: ArgAttribute,
|
||||||
|
/// The dereferenceable size of the pointee.
|
||||||
pub pointee_size: Size,
|
pub pointee_size: Size,
|
||||||
pub pointee_align: Option<Align>
|
pub pointee_align: Option<Align>
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,9 @@ pub fn indirect_struct(_: S) {
|
|||||||
pub fn borrowed_struct(_: &S) {
|
pub fn borrowed_struct(_: &S) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: noalias align 4 dereferenceable(4) i32* @_box(i32* noalias align 4 dereferenceable(4) %x)
|
// `Box` can get deallocated during execution of the function, so it should
|
||||||
|
// not get `dereferenceable`.
|
||||||
|
// CHECK: noalias nonnull align 4 i32* @_box(i32* noalias nonnull align 4 %x)
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn _box(x: Box<i32>) -> Box<i32> {
|
pub fn _box(x: Box<i32>) -> Box<i32> {
|
||||||
x
|
x
|
||||||
|
Loading…
x
Reference in New Issue
Block a user