Skip to main content

Restrict

Struct Restrict 

Source
pub struct Restrict {
    pub clique: u16,
    pub base: u16,
}
Expand description

Which restrict scope an access is in, and which pointer inside that scope it went through.

Two small numbers, which is the whole of the mechanism. GCC spells them MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE at gcc/tree-ssa-alias.cc:2503 and the rule is one line: same clique and different base means the two accesses cannot touch the same byte, because that is exactly what restrict promises. A clique is one scope, numbered as lowering enters it, and a base is one restrict pointer declared inside it. Clique zero means nothing is known, which is what every access that is not under a restrict gets.

This is spec 9.4’s scope tree rather than a blanket assumption, and it costs four bytes that were padding in MemInfo already.

Fields§

§clique: u16

The scope, with zero meaning no information.

§base: u16

The pointer within that scope, which only means anything when the clique is not zero.

Implementations§

Source§

impl Restrict

Source

pub const NONE: Self

No information, which is what an access outside any restrict scope carries.

Source

pub const fn disjoint(self, other: Self) -> bool

Whether restrict says these two accesses cannot touch the same byte.

Only accesses. GCC’s PR71062 is what happens when this answer is used to fold a comparison of the two pointers: restrict constrains what is read and written through a pointer and says nothing about what the pointer’s value is, so two pointers that may not be used to reach the same object can still compare equal. A rule that folds p == q to false on the strength of this is wrong.

Trait Implementations§

Source§

impl Clone for Restrict

Source§

fn clone(&self) -> Restrict

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Restrict

Source§

impl Debug for Restrict

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Restrict

Source§

fn default() -> Restrict

Returns the “default value” for a type. Read more
Source§

impl Eq for Restrict

Source§

impl PartialEq for Restrict

Source§

fn eq(&self, other: &Restrict) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Restrict

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.