-
Notifications
You must be signed in to change notification settings - Fork 2
Make branch extraction more intelligent #652
Changes from 3 commits
d259f23
51d7729
2863769
2826395
6de4680
07574aa
229ed7a
9967e07
21b44fa
c142928
08aa799
848713c
3658a3c
849773d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.439 | ||
0.1.440 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "pyk" | ||
version = "0.1.439" | ||
version = "0.1.440" | ||
description = "" | ||
authors = [ | ||
"Runtime Verification, Inc. <[email protected]>", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,14 +377,24 @@ def extend( | |
if self._check_abstract(node, kcfg): | ||
return | ||
|
||
if not kcfg.splits(target_id=node.id): | ||
branches = self.kcfg_semantics.extract_branches(node.cterm) | ||
if branches: | ||
kcfg.split_on_constraints(node.id, branches) | ||
_LOGGER.info( | ||
f'Found {len(branches)} branches using heuristic for node {node.id}: {shorten_hashes(node.id)}: {[self.kprint.pretty_print(bc) for bc in branches]}' | ||
) | ||
return | ||
branches = self.kcfg_semantics.extract_branches(node.cterm) | ||
|
||
branch_conditions = [] | ||
branch_cterms = [] | ||
|
||
for constraint in branches: | ||
cterm = node.cterm.add_constraint(constraint) | ||
nwatson22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cterm, _ = self.cterm_simplify(cterm) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and here use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and maybe put the constraint back into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the argument is performance. Have we checked on KEVM that it solves the problems we had there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't myself know if it makes an appreciable difference to performance, but if it doesn't make any difference to have the configuration in there, it's just simpler. |
||
if not cterm.is_bottom: | ||
branch_conditions.append(constraint) | ||
branch_cterms.append(cterm) | ||
|
||
if len(branch_cterms) > 1 and branches: | ||
nwatson22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kcfg.branch(node.id, zip(branch_cterms, branch_conditions, strict=True)) | ||
_LOGGER.info( | ||
f'Found {len(branches)} branches using heuristic for node {node.id}: {shorten_hashes(node.id)}: {[self.kprint.pretty_print(bc) for bc in branches]}' | ||
) | ||
return | ||
|
||
ehildenb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_LOGGER.info(f'Extending KCFG from node {self.id}: {shorten_hashes(node.id)}') | ||
_is_vacuous, depth, cterm, next_cterms, next_node_logs = self.cterm_execute( | ||
|
@@ -437,7 +447,9 @@ def extend( | |
|
||
# Split on branch patterns | ||
if any(branch_pattern.match(branch_and) for branch_pattern in branch_patterns): | ||
kcfg.split_on_constraints(node.id, branches) | ||
branch_cterms = [node.cterm.add_constraint(branch) for branch in branches] | ||
|
||
kcfg.branch(node.id, zip(branch_cterms, branches, strict=True)) | ||
_LOGGER.info( | ||
f'Found {len(branches)} branches for node {self.id}: {shorten_hashes(node.id)}: {[self.kprint.pretty_print(bc) for bc in branches]}' | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is no longer relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as I understand, it was the check preventing us from branching over and over again. But by simplifying before branching when it tries to branch a second time without having made an execution step, one of the branches will now simplify to bottom and it won't branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by 'over and over again', when can that happen? As part of looping code?