angr.analyses.decompiler.optimization_passes.return_duplicator_low

class angr.analyses.decompiler.optimization_passes.return_duplicator_low.ReturnDuplicatorLow

Bases: StructuringOptimizationPass, ReturnDuplicatorBase

An optimization pass that reverts a subset of Irreducible Statement Condensing (ISC) optimizations, as described in the USENIX 2024 paper SAILR. This is the heavy/goto version of the ReturnDuplicator optimization pass.

Some compilers, including GCC, Clang, and MSVC, apply various optimizations to reduce the number of statements in code. These optimizations will take equivalent statements, or a subset of them, and replace them with a single copy that is jumped to by gotos – optimizing for space and sometimes speed.

This optimization pass will revert those gotos by re-duplicating the condensed blocks. Since Return statements are the most common, we use this optimization pass to revert only gotos to return statements. Additionally, we perform some additional readability fixups, like not re-duplicating returns to shared components.

Parameters:
  • func – The function to optimize.

  • node_idx_start – The index to start at when creating new nodes. This is used by Clinic to ensure that node indices are unique across multiple passes.

  • max_opt_iters (int) – The maximum number of optimization iterations to perform.

  • max_calls_in_regions (int) – The maximum number of calls that can be in a region. This is used to prevent duplicating too much code.

  • prevent_new_gotos (bool) – If True, this optimization pass will prevent new gotos from being created.

  • minimize_copies_for_regions (bool) – If True, this optimization pass will minimize the number of copies by doing only a single copy for connected in_edges that form a region.

ARCHES = None
PLATFORMS = None
NAME = 'Duplicate returns connect with gotos (low)'
DESCRIPTION = 'An optimization pass that reverts a subset of Irreducible Statement Condensing (ISC) optimizations, as described\nin the USENIX 2024 paper SAILR. This is the heavy/goto version of the ReturnDuplicator optimization pass.\n\nSome compilers, including GCC, Clang, and MSVC, apply various optimizations to reduce the number of statements in\ncode. These optimizations will take equivalent statements, or a subset of them, and replace them with a single\ncopy that is jumped to by gotos -- optimizing for space and sometimes speed.\n\nThis optimization pass will revert those gotos by re-duplicating the condensed blocks. Since Return statements\nare the most common, we use this optimization pass to revert only gotos to return statements. Additionally, we\nperform some additional readability fixups, like not re-duplicating returns to shared components.'
__init__(*args, max_opt_iters=4, max_calls_in_regions=2, prevent_new_gotos=True, minimize_copies_for_regions=True, region_identifier=None, vvar_id_start=0, scratch=None, max_func_blocks=500, **kwargs)
Parameters:
  • max_opt_iters (int)

  • max_calls_in_regions (int)

  • prevent_new_gotos (bool)

  • minimize_copies_for_regions (bool)

  • vvar_id_start (int)

  • scratch (dict[str, Any] | None)

  • max_func_blocks (int)