Skip to content

Additional goto-symex documentation #3975

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

Merged
merged 1 commit into from
Feb 2, 2019

Conversation

JohnDumbell
Copy link
Contributor

Added some comments around areas in symex where it wasn't immediately obvious from a relative newcomer to the code about what precisely they did and why it was important (I was the newcomer in this situation). The field rename touches quite a bit of code, but there's nothing in there beside the rename and required clang-format changes.

Feel free to mention if there's another important area that I should try and document, as I mostly focused on areas that would've been useful to me when I originally started looking around.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Looks good except for the "loop id" part. It may also be worth linking to the documentation that @johanneskloos has put together about symbolic execution, where the SSA renaming is already being explained (doc/architectural/background-concepts.md).

guardt guard{true_exprt{}};
symex_targett::sourcet source;
symex_target_equationt *symex_target;

// we remember all L1 renamings
std::set<irep_idt> l1_history;

// Objects which hold the separate renaming logic for each level that a
// symex variable can be on. L0 relates to thread ID, L1 relates to loop ID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

No, L1 is the frame id (the number of times a function has been called).

// symex variable can be on. L0 relates to thread ID, L1 relates to loop ID,
// and L2 relates to generation ID.
//
// If looking at the VCC they are shown as !{threadID}@{loopID}#{generationID}
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/loopID/frameID/

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.

Patch 1, the comment changes, are good and I would support. Patch 2, s/pc/program_counter/ TBH I'm not sure it is worth the churn. Would a comment / description where it is declared suffice? I'm not sure that there are many people who know what a program counter is but don't know that it is often abbreviated to PC.

@JohnDumbell
Copy link
Contributor Author

JohnDumbell commented Jan 28, 2019

It helps in reading the code if you don't know the terminology but are relatively comfortable with how code like this should work. Just reading 'pc' as you scan a method gives very little information, but 'program_counter' combined with it being an iterator gives a few solid guesses about what it's doing without going any deeper.

This may be a niche situation though, and once you know the abbreviation you're all good anyway. I have no strong opinions either way - I just felt it helped clarity.

@@ -20,6 +20,10 @@ Date: March 2013
#include <util/invariant.h>
#include <goto-programs/goto_functions.h>

/// Dirty variables are ones which have their address taken so we can't
/// reliably work out where they may be assigned. All variables of this sort
/// escape their local scope and are also considered shared state in the
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: usually "escape" would mean live longer than the scope, which isn't true here -- they just might be accessed indirectly and/or by callees

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.

Some nitpickery otherwise lgtm

/// executes. As we walk over each instruction, state will be updated reflecting
/// their effects until a branch occurs (such as an if), where parts of the
/// state will be copied into a \ref goto_statet, stored in a map for later
/// reference and then merged again once it reaches a control-flow graph
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention the name of the merge function

// Map L1 names to (L2) constants
// Map L1 names to (L2) constants. Values will be evicted from this map
// when they become non-constant. This is used to propagate values that have
// been worked out to only have one viable value.
Copy link
Contributor

Choose a reason for hiding this comment

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

viable -> possible

//
// "constants" can include symbols, but only in the context of an address-of
// op (i.e. &x can be propagated), and an address-taken thing should only be
// L1. Actual integer literals (for example) aren't symbols, and so aren't
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd drop the mention of integer literals, it adds more confusion than it removes imo

/// guards, dynamic objects and anything not considered thread-local)
/// L1. Applies a suffix giving the current loop iteration or recursive
/// function invocation.
/// L2. Applies a suffix giving the latest generation of this variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

strike "latest" (writes are always to the latest / fresh generation, but reads can be from past generations, especially in phi nodes)

@@ -115,6 +156,10 @@ class goto_symex_statet final
// do dereferencing
value_sett value_set;

/// Container for data that varies per program point, e.g. the constant
/// propagator state, when state needs to branch. This is copied out of
/// goto_symex_statet at a control-flow fork and then back into it (at some
Copy link
Contributor

Choose a reason for hiding this comment

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

back into it at a control-flow merge

Strike "and not the other way around," since we've just said state goes into it and out of it

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: a16bf20).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98846560
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.

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: 956d240).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98858825
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.

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Please separate the pc renaming into another PR - that's a breaking change.

@JohnDumbell
Copy link
Contributor Author

@peterschrammel Done.

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: c352c90).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98957513
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.

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: 663f6e3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98983334
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.

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: dd518a9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99143224

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: 20a84fb).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99462351

@tautschnig tautschnig merged commit d7bb1d4 into diffblue:develop Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants