Skip to content

Constant propagation of nondet-symbol [blocks: #35] #3619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

tautschnig
Copy link
Collaborator

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig
Copy link
Collaborator Author

@smowton I'd be curious whether this can do some of what otherwise might only be achievable via field sensitivity for Java.

@tautschnig tautschnig changed the title Constant propagation of nondet-symbol Constant propagation of nondet-symbol [blocks: #35] Dec 21, 2018
@smowton
Copy link
Contributor

smowton commented Dec 21, 2018

Propagating a nondet symbol? I don't see how, could you elaborate what you think it might do?

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 3714d25).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95553013

@tautschnig
Copy link
Collaborator Author

Propagating a nondet symbol? I don't see how, could you elaborate what you think it might do?

A nondet symbol is a constant, we just don't know its value. The gain is that it does not interfere with structs that are otherwise constants (those of the kind that we know their value), see also the regression test that's included.

@kroening
Copy link
Member

We should probably rename is_constantt to something like "forward_substitution".

@kroening
Copy link
Member

Specifically on Java: in principle, Java objects should get zero initialised -- this should enable the propagation without this PR. It may be worth checking whether that actually works.

@smowton
Copy link
Contributor

smowton commented Dec 27, 2018

@kroening they do get zero-init'd; this would catch a case such as otherwise_const_thing->field = nondet_value;. Because various arithmetic operations on constants are themselves considered constants quite a lot would get propagated -- I think the objects would only stop getting propagated once there's a phi node, as if_exprt does not inherit constant-ness from its arguments.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: f241b8b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98502213
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@smowton
Copy link
Contributor

smowton commented Jan 26, 2019

My inclination is this is a bad thing (propagating not just nondet_symbol#1 but also a big ball of non-constant arithmetic containing nondet_symbol#1) and will be rendered redundant by field sensitivity

@tautschnig
Copy link
Collaborator Author

tautschnig commented Jan 26, 2019

[...] and will be rendered redundant by field sensitivity

I would have liked to believe this, but in fact these are very much complementary. On one of our verification tasks field sensitivity works as expected, but in order to handle a call to memset we also need a pointer offset to propagate (neither the changes from this PR alone nor field sensitivity alone suffice), which is computed from a sequence of pointer arithmetic. The simplifier is then able to figure out that all the nondets do not matter for the pointer offset, and yields a much-needed constant.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, this is easy to revert if it has bad side-effects, so let's try it

else if(expr.id() == ID_if)
{
const if_exprt &if_expr = to_if_expr(expr);
if(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems oddly specific, add a comment saying why this particular restriction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added.

return true;
else if(expr.id() == ID_symbol)
{
const irep_idt &obj_identifier = to_ssa_expr(expr).get_object_name();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly could use a comment: why this policy for guards only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to take the guard prefix from a single place of definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added and a refactoring commit added that makes all users use a single definition.

@tautschnig tautschnig changed the title Constant propagation of nondet-symbol [blocks: #35] Constant propagation of nondet-symbol [depends-on: #4374, blocks: #35] Mar 25, 2019
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 69012b3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105668394

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: ef4b9bb).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105797178

@tautschnig tautschnig changed the title Constant propagation of nondet-symbol [depends-on: #4374, blocks: #35] Constant propagation of nondet-symbol [blocks: #35] Mar 26, 2019
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 5caef74).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105812275

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 90c4a75).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105987217
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@tautschnig tautschnig removed their assignment Mar 30, 2019
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: bcb894d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107052342

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 77f93e9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107328775
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 0c848d6).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107800556

1) Within goto-symex, propagation of nondet_symbol_exprt is actually safe, as
they are instantiations of side_effect_expr_nondett and the value of these
instantiations cannot change.
2) This highlights that we also need to consider further expressions as possibly
being constant in is_constantt which we would otherwise simplify away when they
are constant (but cannot any longer do so when nondet_symbol_exprt are contained
in there).
3) Constant propagation now yields different right-hand sides in a test, and
makes another test trivial.
4) goto-symex applies filters on what is considered "constant" to keep the size
of expressions contained as (repeated) simplification of large expressions is
expensive. We may revisit this in future as we improve the simplifier.
In order to generate a trace value for an unbounded LHS we may need to
look at its RHS as (string) refinement may have constructed values for
the RHS.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 85c963c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/108226898

@TGWDB
Copy link
Contributor

TGWDB commented Aug 1, 2022

Closing due to age. If you believe this is erroneous please reopen and update the PR.

@TGWDB TGWDB closed this Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Needs TG approval 🦉 Only merge with explicit approval from test-gen maintainers Symbolic Execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants