Skip to content

DOC-70: Description of rd_range_domaint of reaching_definitions.h(cpp) module. #3399

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
Dec 3, 2018

Conversation

marek-trtik
Copy link
Contributor

No description provided.

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

This looks really great, and a huge improvement. A few minor comments, but otherwise very happy, thanks!

#### Struct `reaching_definitiont`

Identifies a GOTO instruction where a given variable is defined (i.e. it is set
a certain value). In consists of these data:
Copy link
Contributor

Choose a reason for hiding this comment

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

"a certain value" -> "to a certain value"


There is defined an order of instances of this structure. But its purpose is
only for to be able to use instances as keys in ordered containers, like
`std::map`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this paragraph might be better phrased as something like this?

In order to use instances of this structure as keys in ordered containers, such as std::map, an ordering is defined.

inserted `reaching_definitionst` instance. Internally, the class holds two data
members:

- `value_map` It is (an unordered) map from names of program variables to a set
Copy link
Contributor

Choose a reason for hiding this comment

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

'It is (an unordered) map' -> 'is an unordered map'

- `value_map` It is (an unordered) map from names of program variables to a set
of pairs (`reaching_definitiont`, `ID`). Formally, the map is defined as
`value_map: var_names -> (reaching_definitionst -> ID)`.
- `values` It is a map from an `ID` to the corresponding `reaching_definitiont`
Copy link
Contributor

Choose a reason for hiding this comment

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

'It is a map' -> 'is a map'


- `has_value` This (three value logic) flag determines, whether the instance
represents `top`, `bottom`, or any other element of the lattice, by values
`TRUE`, `FALSE`, and `UNKNOW` respectively. Initially it is set to `FALSE`.
Copy link
Contributor

Choose a reason for hiding this comment

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

UNKNOW -> UNKNOWN

all `rd_range_domaint` instances. NOTE: `reaching_definitions_analysist`
inherits from `sparse_bitvector_analysist<reaching_definitiont>` and so
`this` is passed to `set_bitvector_container` for all instances.
- `values` It is (an ordered) map from program variable names to `ID`s of
Copy link
Contributor

Choose a reason for hiding this comment

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

'It is (an ordered) map' -> 'is an ordered map'

`reaching_definitiont` instances stored in map pointed to by `bv_container`.
The map is not empty only if `has_value` is `UNKNOWN`. Variables in the map
are all those which are live at the associated instruction.
- `export_cache` It is a helper data structure. It consists of data already
Copy link
Contributor

Choose a reason for hiding this comment

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

'It is a helper' -> 'is a helper'

are all those which are live at the associated instruction.
- `export_cache` It is a helper data structure. It consists of data already
stored in `values` and `bv_container`. The purpose of this structure is to
provide a boost for certain operations (discussed below). It is basically
Copy link
Contributor

Choose a reason for hiding this comment

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

What type of boost? runtime improvement? memory usage improvement?

NOTE: The operation actually does not produce a new `join` element. The element
`a` is modified to become the `join` element.

NOTE: When union of `a.values[v]` and `b.values[v]` is computed, then `v` must
Copy link
Contributor

Choose a reason for hiding this comment

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

'then v must' -> 'then v must be'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed as well.

new reaching definition record, for a passed variable name, written in given
GOTO instruction (identified by an iterator), at same range of bits.

##### Method `polulate_cache`
Copy link
Contributor

Choose a reason for hiding this comment

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

'polulate_cache' -> 'populate_cache'

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

Identifies a GOTO instruction where a given variable is defined (i.e. it is set
a certain value). In consists of these data:
- `identifier` The name of the variable which was defined.
- `definition_at` The iterator to the GOTO instruction where the variable is
Copy link
Collaborator

Choose a reason for hiding this comment

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

where the variable has been written to

- `bit_begin` and `bit_end` These two integers define a range of bits (i.e. the
begin and end bit indices) which represent the value of the variable. Clearly,
`0 <= bit_begin < bit_end`. However, `bit_end` can also be set a special value
`-`, which means infinite/unknown index.
Copy link
Collaborator

Choose a reason for hiding this comment

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

-1, not just -

- `definition_at` The iterator to the GOTO instruction where the variable is
- `bit_begin` and `bit_end` These two integers define a range of bits (i.e. the
begin and end bit indices) which represent the value of the variable. Clearly,
`0 <= bit_begin < bit_end`. However, `bit_end` can also be set a special value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe talk about a half-open interval?

these classes there are more data structures necessary in the computation.
We discuss all of them in the following sub-sections.

#### Struct `reaching_definitiont`
Copy link
Member

Choose a reason for hiding this comment

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

🚫I think this detailed documentation should be moved to the source and header files. Only a conceptual overview with refs to the code should be given here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could certainly do that. Perhaps in the next doc day?

Copy link
Member

Choose a reason for hiding this comment

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

It's probably half an hour work to copy the text into the right places. I'd prefer it to be done now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@marek-trtik
Copy link
Contributor Author

Requested updates are available.

#### Class `sparse_bitvector_analysist`

An instance of this class provides an assignment of unique numeric `ID` to each
inserted `reaching_definitionst` instance. Internally, the class holds two data
Copy link
Contributor

Choose a reason for hiding this comment

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

reaching_definitionst -> reaching_definitiont


- `value_map` is an unordered map from names of program variables to a set
of pairs (`reaching_definitiont`, `ID`). Formally, the map is defined as
`value_map: var_names -> (reaching_definitionst -> ID)`.
Copy link
Contributor

Choose a reason for hiding this comment

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

reaching_definitionst -> reaching_definitiont

- `values` is a map from an `ID` to the corresponding `reaching_definitiont`
instance inside the map `value_map`. Namely, the map is implemented as an
`std::vector` of iterators to elements of the map `value_map`. An index to
`values` vector is the `ID` of the related `reaching_definitionst` instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

reaching_definitionst -> reaching_definitiont

`reaching_definitiont` instances stored in map pointed to by `bv_container`.
The map is not empty only if `has_value` is `UNKNOWN`. Variables in the map
are all those which are live at the associated instruction.
- `export_cache` is a helper data structure. It consists of data already
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I've seen the export cache is only populated when rd_range_domaint::output() is called (output() calls get() which in turn calls populate_cache()). Thus, initially when the analysis is run the export cache is always empty. I think the code could be refactored to remove the modifications of the export cache in methods merge(), kill(), etc.

I would recommend not documenting the export cache in detail and only say that it is used when printing output and open an issue for refactoring the use of the export cache instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed too.

@marek-trtik
Copy link
Contributor Author

Requested updates are available.

Copy link
Contributor

@danpoe danpoe left a comment

Choose a reason for hiding this comment

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

LGTM

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

@marek-trtik
Copy link
Contributor Author

marek-trtik commented Nov 30, 2018

@peterschrammel Requested updates are available.

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 fine except a complaint by cpp-lint (see below) and one by Doxygen that I cannot really make sense of as the parameters do seem to be documented.

@@ -35,6 +35,14 @@ reaching_definitions_analysist::reaching_definitions_analysist(

reaching_definitions_analysist::~reaching_definitions_analysist()=default;

/// Given the passed variable name `identifier` it collects data from
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Given the passed variable name `identifier` it collects data from
/// Given \p identifier, collect data from

@@ -35,6 +35,14 @@ reaching_definitions_analysist::reaching_definitions_analysist(

reaching_definitions_analysist::~reaching_definitions_analysist()=default;

/// Given the passed variable name `identifier` it collects data from
/// `bv_container` for each `ID` in `values[identifier]` and stores them into
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// `bv_container` for each `ID` in `values[identifier]` and stores them into
/// `bv_container` for each `ID` in `values[identifier]` and store them into

irep_idt identifier;
/// The iterator to the GOTO instruction where the variable has been written to.
Copy link
Collaborator

Choose a reason for hiding this comment

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

cpp-lint complains: line is too long

/// Computes an instance obtained from the instance `*this` by transformation
/// over a GOTO instruction referenced by `from`. The method implements a
/// switch according to a type of the instruction and then calls a dedicated
/// transform_*` method for the recognised instruction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Doxygen is getting confused because of a missing backtick at the beginning of line 154. Adding the backtick should fix the warnings. (@marek-trtik It's easy to see this problem by looking at the documentation produced by Doxygen. I suggest reviewing what the generated documentation looks like in doc/html.)

Suggested change
/// transform_*` method for the recognised instruction.
/// `transform_*` method for the recognised instruction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Fixed.

@peterschrammel
Copy link
Member

@marek-trtik, please squash the commits.

Updates requested in the review: Bug-fixes, typos, rephrasing.

Updates requested in the review: Typos, and `export_cache` issue.

Updates requested in the review: Moving comments from doc file to code.

Bugfixes: to long line; missing backtick
@marek-trtik
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: 9254419).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93344342
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: 1fe3b1a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93352239

@tautschnig tautschnig merged commit f0b08e5 into diffblue:develop Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants