angr.analyses.decompiler.optimization_passes.code_motion¶
- class angr.analyses.decompiler.optimization_passes.code_motion.CodeMotionOptimization¶
Bases:
OptimizationPassMoves common statements out of blocks that share the same predecessors or the same successors. This is done to reduce the number of statements in a block and to make the blocks more similar to each other.
As an example:
if (x) { b = 2; a = 1; c = 3; } else { b = 2; c = 3; }
Will be turned into:
if (x) { a = 1; } b = 2; c = 3;
Current limitations (for very conservative operations):
moving statements above conditional jumps is not supported
only immediate children and parents are considered for moving statements
when moving statements down, a block is only considered if already has a matching statement at the end
- ARCHES = None¶
- PLATFORMS = None¶
- NAME = 'Merge common statements in sub-scopes'¶
- STAGE: OptimizationPassStage = 6¶
- DESCRIPTION = '\n Moves common statements out of blocks that share the same predecessors or the same\n successors. This is done to reduce the number of statements in a block and to make the\n blocks more similar to each other.\n\n As an example::\n\n if (x) {\n b = 2;\n a = 1;\n c = 3;\n } else {\n b = 2;\n c = 3;\n }\n\n Will be turned into::\n\n if (x) {\n a = 1;\n }\n b = 2;\n c = 3;\n\n Current limitations (for very conservative operations):\n\n - moving statements above conditional jumps is not supported\n - only immediate children and parents are considered for moving statements\n - when moving statements down, a block is only considered if already has a matching statement at the end\n '¶
- static update_graph_with_super_edits(original_graph, super_graph, updated_blocks)¶
This function updates an graph when doing block edits on a supergraph version of that same graph. The updated blocks must be provided as a dictionary where the keys are original block in the supergraph and the values are the new blocks that should replace them.
The supergraph MUST be generated using the to_ail_supergraph function, since it stores the original nodes each super node represents. This is necessary to update the original graph with the new super nodes.