pub fn get_referred_symbols(
context: &Context<'_>,
val: Value,
) -> ReferredSymbols
Expand description
Get Symbols, both Symbol::Locals and Symbol::Args, reachable
from the val
via chain of InstOp::GetElemPtr (GEP) instructions
or via InstOp::IntToPtr and InstOp::PtrToInt instruction patterns
specific to references, both referencing (&
) and dereferencing (*
),
and raw pointers, via __addr_of
.
A val
can, via these instructions, refer indirectly to none, or one
or more symbols.
Note that this function does not perform any escape analysis. E.g., if a
local symbol gets passed by raw_ptr
or &T
to a function and returned
back from the function via the same raw_ptr
or &T
the value returned
from the function will not be tracked back to the original symbol and the
symbol will not be collected as referred.
This means that, even if the result contains Symbols, it might be that
there are still other Symbols in scope related to the val
. E.g., in case
of branching, where the first branch directly returns & local_var_a
and the second branch, indirectly over a function call as explained above,
& local_var_b
, only the local_var_a
will be returned as a result.
Therefore, the function returns the ReferredSymbols enum to denote if the returned set of symbols is guaranteed to be complete, or if it is incomplete.
If the val
is not a pointer, an empty set is returned and marked as
ReferredSymbols::Complete.