sway_ir::analysis

Module memory_utils

Source
Expand description

An analysis to compute symbols that escape out from a function. This could be into another function, or via ptr_to_int etc. Any transformations involving such symbols are unsafe.

Enums§

EscapedSymbols
ReferredSymbols
Provides Symbols, both Symbol::Locals and Symbol::Args, reachable from a certain Value 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.
Symbol

Constants§

ESCAPED_SYMBOLS_NAME

Functions§

combine_indices
Combine a series of GEPs into one.
compute_escaped_symbols
compute_escaped_symbols_pass
create_escaped_symbols_pass
get_gep_referred_symbols
Get Symbols, both Symbol::Locals and Symbol::Args, reachable from the val via chain of InstOp::GetElemPtr (GEP) instructions. A val can, via GEP instructions, refer indirectly to none, or one or more symbols.
get_gep_symbol
get_loaded_ptr_values
Pointers that may possibly be loaded from the instruction inst.
get_loaded_symbols
Symbols that may possibly, directly or indirectly, be loaded from the instruction inst.
get_memory_offsets
Given a memory pointer instruction, compute the offset of indexed element, for each symbol that it may alias to. If for any symbol we can’t compute it, return None.
get_referred_symbol
Return Symbol referred by val if there is exactly one symbol referred, or None if there are no Symbols referred or if there is more then one referred.
get_referred_symbols
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.
get_stored_ptr_values
Pointers that may possibly be stored to the instruction inst.
get_stored_symbols
Symbols that may possibly, directly or indirectly, be stored to the instruction inst.
may_alias
Can memory ranges [val1, val1+len1] and [val2, val2+len2] overlap? Conservatively returns true if cannot statically determine.
must_alias
Are memory ranges [val1, val1+len1] and [val2, val2+len2] exactly the same? Conservatively returns false if cannot statically determine.
pointee_size
For a pointer argument ptr_val, what’s the size of its pointee.