Skip to main content

Alias

Struct Alias 

Source
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>

Source

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.

Source

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.

Source

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.

Source

pub const fn escapes(&self) -> &Escapes

Which locals escaped, for a caller that wants the fact on its own.

Source

pub const fn counts(&self) -> &Counts

What each layer has answered so far.

Source

pub fn reads(&self, inst: Inst) -> Option<Access>

The bytes this instruction reads, if it reads any.

Source

pub fn writes(&self, inst: Inst) -> Option<Access>

The bytes this instruction writes, if it writes any.

Source

pub fn query(&mut self, a: &Access, b: &Access) -> Answer

Whether these two references can touch the same byte.

Source

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.

Source

pub fn read_by(&mut self, reference: &Access, call: Inst) -> Answer

Whether this call can read them.

GCC’s ref_maybe_used_by_call_p_1, and the same argument as Alias::clobbered_by.

Trait Implementations§

Source§

impl<'a> Debug for Alias<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Alias<'a>

§

impl<'a> RefUnwindSafe for Alias<'a>

§

impl<'a> Send for Alias<'a>

§

impl<'a> Sync for Alias<'a>

§

impl<'a> Unpin for Alias<'a>

§

impl<'a> UnsafeUnpin for Alias<'a>

§

impl<'a> UnwindSafe for Alias<'a>

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> 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, 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.