Skip to content

Commit

Permalink
disable selftest if code contains symbolic registers
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Dec 14, 2024
1 parent 898c9a7 commit 05b2b64
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions slothy/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,17 @@ def selftest(self, log):
log.warning("Selftest not supported on target architecture")
return

tree = DFG(self._orig_code, log, DFGConfig(self.config, outputs=self.outputs))

if tree.has_symbolic_registers():
log.info("Skipping selftest as input contains symbolic registers.")
return

log.info(f"Running selftest ({self._config.selftest_iterations} iterations)...")

address_gprs = self._config.selftest_address_gprs
if address_gprs is None:
# Try to infer which registes need to be pointers
log_addresses = log.getChild("infer_address_gprs")
tree = DFG(self._orig_code, log_addresses, DFGConfig(self.config, outputs=self.outputs))
# Look for load/store instructions and remember addresses
addresses = set()
for t in tree.nodes:
Expand Down
12 changes: 12 additions & 0 deletions slothy/core/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,18 @@ def update_inputs(self):
for i,v in enumerate(t.src_in_out):
t.inst.args_in_out[i] = v.reduce().name()

def has_symbolic_registers(self):
rt = self.config._arch.RegisterType
for i in self.nodes:
instr = i.inst
for out, ty in zip(instr.args_out, instr.arg_types_out):
if out not in rt.list_registers(ty):
return True
for inout, ty in zip(instr.args_in_out, instr.arg_types_in_out):
if inout not in rt.list_registers(ty):
return True
return False

def ssa(self, filter_func=None):
"""Transform data flow graph into single static assignment (SSA) form."""
# Go through non-virtual instruction nodes and assign unique names to
Expand Down

0 comments on commit 05b2b64

Please sign in to comment.