angr.analyses.decompiler.peephole_optimizations.base

class angr.analyses.decompiler.peephole_optimizations.base.PeepholeOptimizationStmtBase

Bases: object

The base class for all peephole optimizations that are applied on AIL statements.

fixpoint_reached is an output parameter; it tells the caller whether this optimizer should run on this statement again (e.g., when statements prior to the current statement are optimized and changed). The caller sets fixpoint_reached to True before every optimize() call; the optimizer optionally sets it to False if it wants to be invoked again on the same statement.

So, fixpoint_reached should be set to (or kept) True if (a) the optimizer has optimized the statement and does not expect to optimize it ever again, or (b) the optimizer cannot ever optimize the statement.

NAME = 'Peephole Optimization - Statement'
DESCRIPTION = 'Peephole Optimization - Statement'
stmt_classes = None
__init__(project, kb, ail_manager, func_addr=None, preserve_vvar_ids=None, type_hints=None)
Parameters:
project: Project | None
kb: KnowledgeBase | None
manager
func_addr: int | None
preserve_vvar_ids: set[int]
type_hints: list[tuple[VirtualVariable | MemoryLocation, str]]
fixpoint_reached: bool
optimize(stmt, stmt_idx=None, block=None, **kwargs)
Parameters:

stmt_idx (int | None)

class angr.analyses.decompiler.peephole_optimizations.base.PeepholeOptimizationMultiStmtBase

Bases: object

The base class for all peephole optimizations that are applied on multiple AIL statements at once.

fixpoint_reached exists for uniformity but is unused. Multi-statement optimizers always run regardless of whether the statements have reached fixed points or not.

NAME = 'Peephole Optimization - Multi-statement'
DESCRIPTION = 'Peephole Optimization - Multi-statement'
stmt_classes = None
__init__(project, kb, ail_manager, func_addr=None, preserve_vvar_ids=None, type_hints=None)
Parameters:
project: Project | None
kb: KnowledgeBase | None
manager
func_addr: int | None
preserve_vvar_ids: set[int]
type_hints: list[tuple[VirtualVariable | MemoryLocation, str]]
fixpoint_reached: bool
optimize(stmts, stmt_idx=None, block=None, **kwargs)
Parameters:
class angr.analyses.decompiler.peephole_optimizations.base.PeepholeOptimizationExprBase

Bases: object

The base class for all peephole optimizations that are applied on AIL expressions. Please refer to PeepholeOptimizationStmtBase for the fixpoint_reached contract.

NAME = 'Peephole Optimization - Expression'
DESCRIPTION = 'Peephole Optimization - Expression'
expr_classes = None
__init__(project, kb, ail_manager, func_addr=None, preserve_vvar_ids=None, type_hints=None)
Parameters:
project: Project | None
kb: KnowledgeBase | None
manager
func_addr: int | None
preserve_vvar_ids: set[int]
type_hints: list[tuple[VirtualVariable | MemoryLocation, str]]
fixpoint_reached: bool
optimize(expr, *, stmt_idx=None, block=None, **kwargs)
Return type:

Expression | None

Parameters:

stmt_idx (int | None)

static find_definition(ail_expr, stmt_idx, block)
Return type:

None

Parameters:
static is_bool_expr(ail_expr)