angr.analyses.decompiler.known_patterns.block_split

Utilities for splitting an AIL block into consecutive blocks within a graph.

The Outliner analysis operates at whole-block granularity, while KnownPattern matches are usually (sub-)statement-level; splitting the anchor block so the matched span becomes its own block bridges the two.

angr.analyses.decompiler.known_patterns.block_split.rewrite_phi_sources(block, old_src, new_src, idx_alloc)

Rewrite phi statements at the top of block so that entries sourced from old_src are sourced from new_src instead. Mutates the block’s statement list in place.

idx_alloc supplies AIL indices for the rebuilt statements: an object built with idx=None lands at index 0, and the decompiler’s VariableMap is keyed by index, so all of them would share one entry.

Return type:

None

Parameters:
angr.analyses.decompiler.known_patterns.block_split.split_ail_block(graph, block, pre_stmts, mid_stmts, post_stmts, block_addr_alloc, idx_alloc)

Replace block in graph with up to three consecutive blocks holding pre_stmts, mid_stmts, and post_stmts.

The first non-empty part keeps the original block identity (addr, idx) so that predecessor jump targets (and the at-most-one-block-per-address assumption at the function entry) remain valid; each following part is placed at a fresh synthetic address obtained from block_addr_alloc. When the last part’s identity differs from the original, phi statements in the successors are rewritten to source from the new last block. Edge data is preserved.

Returns (b_pre, b_mid, b_post) where b_pre/b_post are None when their statement list is empty. mid_stmts must be non-empty.

Return type:

tuple[Block | None, Block, Block | None]

Parameters: