pub struct Alias<'a> { /* private fields */ }Expand description
The analysis over one function.
It borrows the function because nearly everything it asks is a question about one, and it
borrows an Outside because the rest is a question about the module: whether two symbols are
two objects, what a callee is declared to do, where a type node sits in the tree, and how wide
an address is. That is a copy of four module facts rather than the module itself, so that a
pass handed &mut module[id] can still build this. See crate::outside for why.
The escape analysis is run once when this is built, since every query may ask it and it is one walk over the function.
Implementations§
Source§impl<'a> Alias<'a>
impl<'a> Alias<'a>
Sourcepub fn new(func: &'a Func, outside: &'a Outside) -> Self
pub fn new(func: &'a Func, outside: &'a Outside) -> Self
The analysis of this function, with the type-based layer on, which is GCC’s -O2.
Sourcepub fn with(func: &'a Func, outside: &'a Outside, options: Options) -> Self
pub fn with(func: &'a Func, outside: &'a Outside, options: Options) -> Self
The same, with the type-based layer where the command line left it.
Sourcepub fn knowing(self, summaries: &'a Summaries) -> Self
pub fn knowing(self, summaries: &'a Summaries) -> Self
The same, with what the whole module’s functions were worked out to do to memory.
Without this the only thing known about a call is what somebody declared about it, which
for most of a real translation unit is nothing. With it, a call to a function in the same
unit is answered from what that function’s body actually does. See crate::modref.
Sourcepub const fn escapes(&self) -> &Escapes
pub const fn escapes(&self) -> &Escapes
Which locals escaped, for a caller that wants the fact on its own.
Sourcepub fn reads(&self, inst: Inst) -> Option<Access>
pub fn reads(&self, inst: Inst) -> Option<Access>
The bytes this instruction reads, if it reads any.
Sourcepub fn writes(&self, inst: Inst) -> Option<Access>
pub fn writes(&self, inst: Inst) -> Option<Access>
The bytes this instruction writes, if it writes any.
Sourcepub fn query(&mut self, a: &Access, b: &Access) -> Answer
pub fn query(&mut self, a: &Access, b: &Access) -> Answer
Whether these two references can touch the same byte.
Sourcepub fn clobbered_by(&mut self, reference: &Access, call: Inst) -> Answer
pub fn clobbered_by(&mut self, reference: &Access, call: Inst) -> Answer
Whether this call can write the bytes the reference covers.
GCC’s call_may_clobber_ref_p_1. Three things answer it and they are asked in that
order: the escape analysis, which is the cheap one and needs nothing outside this
function; the attributes a C programmer already wrote, which are section 8.4’s; and the
mod and ref summaries of document 34, which are what the same three questions look like
when the callee’s body is read rather than taken on trust. Without the last of those the
honest answer for anything whose address escaped was yes, and crate::modref is where it
stopped being. All three are in Alias::decide_call, which is also what
Alias::read_by asks.