From 07344cd10c5275ff28216b5d1946ac6372a18743 Mon Sep 17 00:00:00 2001 From: Fish Date: Sun, 24 Nov 2024 17:58:17 +0800 Subject: [PATCH] BlockWalker: Handle Store.guard. (#261) --- ailment/block_walker.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ailment/block_walker.py b/ailment/block_walker.py index 8c9e4a0..3aba9b5 100644 --- a/ailment/block_walker.py +++ b/ailment/block_walker.py @@ -116,6 +116,8 @@ def _handle_Call(self, stmt_idx: int, stmt: Call, block: Block | None): def _handle_Store(self, stmt_idx: int, stmt: Store, block: Block | None): self._handle_expr(0, stmt.addr, stmt_idx, stmt, block) self._handle_expr(1, stmt.data, stmt_idx, stmt, block) + if stmt.guard is not None: + self._handle_expr(2, stmt.guard, stmt_idx, stmt, block) def _handle_Jump(self, stmt_idx: int, stmt: Jump, block: Block | None): self._handle_expr(0, stmt.target, stmt_idx, stmt, block) @@ -349,6 +351,12 @@ def _handle_Store(self, stmt_idx: int, stmt: Store, block: Block | None): else: data = stmt.data + guard = None if stmt.guard is None else self._handle_expr(2, stmt.guard, stmt_idx, stmt, block) + if guard is not None and guard is not stmt.guard: + changed = True + else: + guard = stmt.guard + if changed: # update the statement directly in the block new_stmt = Store( @@ -357,7 +365,7 @@ def _handle_Store(self, stmt_idx: int, stmt: Store, block: Block | None): data, stmt.size, stmt.endness, - guard=stmt.guard, + guard=guard, variable=stmt.variable, offset=stmt.offset, **stmt.tags,