angr.rust.optimization_passes.pre_pattern_match_simplifier

class angr.rust.optimization_passes.pre_pattern_match_simplifier.PrePatternMatchSimplifier

Bases: OptimizationPass, ReturnDuplicatorBase, DFAMixin

Duplicate return blocks for identified pattern matches to form if-else structures. For example the following code:

if (...){
    ...
} else {
    v6 = std::fs::File::open(a1, a2);
    if !v6 as i32 {
        ...
    }
}
return Err(struct8 {
    field_0: v11
});

should be converted to:

v6 = std::fs::File::open(a1, a2);
if v6 as i32 {
    return Err(struct8 {
        field_0: v11
    });
} else {
    ...
}

for recovering pattern match constructs in later stage

ARCHES = None
PLATFORMS = None
STAGE: OptimizationPassStage = 7
NAME = 'Duplicate return blocks to prepare for pattern match simplification'
DESCRIPTION = '\n    Duplicate return blocks for identified pattern matches to form if-else structures.\n    For example the following code::\n\n        if (...){\n            ...\n        } else {\n            v6 = std::fs::File::open(a1, a2);\n            if !v6 as i32 {\n                ...\n            }\n        }\n        return Err(struct8 {\n            field_0: v11\n        });\n\n    should be converted to::\n\n        v6 = std::fs::File::open(a1, a2);\n        if v6 as i32 {\n            return Err(struct8 {\n                field_0: v11\n            });\n        } else {\n            ...\n        }\n\n    for recovering pattern match constructs in later stage\n    '
STRUCTURING: list[str] | None = ['sailr', 'dream']
__init__(func, manager, *, vvar_id_start, max_calls_in_regions=2, minimize_copies_for_regions=True, scratch=None, **kwargs)
Parameters:
  • vvar_id_start (int)

  • max_calls_in_regions (int)

  • minimize_copies_for_regions (bool)

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

static extract_scrutinee_and_discriminant(condition)
static inverse_variant(enum_type, discriminant)
Return type:

EnumVariant | None