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: u16The scope, with zero meaning no information.
base: u16The pointer within that scope, which only means anything when the clique is not zero.
Implementations§
Source§impl Restrict
impl Restrict
Sourcepub const NONE: Self
pub const NONE: Self
No information, which is what an access outside any restrict scope carries.
Sourcepub const fn disjoint(self, other: Self) -> bool
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.