[−][src]Struct ssa::dfg::DataFlowGraph
Data flow graph
It takes edges and vertices from the cfg to find assignments and build data flow
Methods
impl<'a> DataFlowGraph<'a>
[src]
pub fn new(state: &'a State) -> Self
[src]
Create new flow graph by importing State
from cfg
pub fn find_links(&self) -> HashSet<DataLink>
[src]
Find data dependency links
Start at stop point and go bottom up. Whenever a node is visited:
- If the node is a function call (Mdiamond, DoubleCircle) then we find all parameters of the function
- If the node is a comparison then we find all variables in the comparison
- If the node is an assignment then we find all variables in the assignment
It should be noted that we ignore nested functions because each nested function takes a node in CFG. For example:
this.add(this.add(x, 1), this.add(y, 1));
The CFG of the function call above should be: this.add(y, 1) => this.add(x, 1) => this.add(this.add(x, 1), this.add(y, 1))
For each node, we build a sequence of USING(X)
or KILL(Y)
where X, Y are variable. For
example:
uint x = y + 10; // (1)
x += 20; // (2)
(1) has the sequence: USE(Y), KILL(X)
and (2) has the sequence: USE(X), KILL(X)
Whenever a node is visited, we try to generate the sequence for current node and merge with
the sequence of previous nodes. If the pattern USE(X),...,KILL(X)
is discovered then
all uses of variable X USE(X)
depend on KILL(X)
, one data dependency link is created.
All elements in that pattern will be removed from the sequence.
The loop will stop if no sequence changes happen
Auto Trait Implementations
impl<'a> Send for DataFlowGraph<'a>
impl<'a> Sync for DataFlowGraph<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,