-
Notifications
You must be signed in to change notification settings - Fork 277
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
Conversation
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 looks really great, and a huge improvement. A few minor comments, but otherwise very happy, thanks!
src/analyses/README.md
Outdated
#### 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: |
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.
"a certain value" -> "to a certain value"
src/analyses/README.md
Outdated
|
||
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`. |
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.
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.
src/analyses/README.md
Outdated
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 |
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.
'It is (an unordered) map' -> 'is an unordered map'
src/analyses/README.md
Outdated
- `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` |
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.
'It is a map' -> 'is a map'
src/analyses/README.md
Outdated
|
||
- `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`. |
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.
UNKNOW -> UNKNOWN
src/analyses/README.md
Outdated
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 |
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.
'It is (an ordered) map' -> 'is an ordered map'
src/analyses/README.md
Outdated
`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 |
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.
'It is a helper' -> 'is a helper'
src/analyses/README.md
Outdated
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 |
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 type of boost? runtime improvement? memory usage improvement?
src/analyses/README.md
Outdated
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 |
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.
'then v
must' -> 'then v
must be'
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.
fixed as well.
src/analyses/README.md
Outdated
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` |
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.
'polulate_cache' -> 'populate_cache'
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: ff41c1c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91249455
src/analyses/README.md
Outdated
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 |
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.
where the variable has been written to
src/analyses/README.md
Outdated
- `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. |
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.
-1
, not just -
src/analyses/README.md
Outdated
- `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 |
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.
Maybe talk about a half-open interval?
src/analyses/README.md
Outdated
these classes there are more data structures necessary in the computation. | ||
We discuss all of them in the following sub-sections. | ||
|
||
#### Struct `reaching_definitiont` |
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.
🚫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.
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.
I could certainly do that. Perhaps in the next doc day?
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.
It's probably half an hour work to copy the text into the right places. I'd prefer it to be done now.
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.
Done.
Requested updates are available. |
src/analyses/README.md
Outdated
#### 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 |
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.
reaching_definitionst
-> reaching_definitiont
src/analyses/README.md
Outdated
|
||
- `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)`. |
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.
reaching_definitionst
-> reaching_definitiont
src/analyses/README.md
Outdated
- `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. |
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.
reaching_definitionst
-> reaching_definitiont
src/analyses/README.md
Outdated
`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 |
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.
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.
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.
fixed too.
Requested updates are available. |
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.
LGTM
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 2752f0b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91571606
2752f0b
to
41a1446
Compare
@peterschrammel Requested updates are available. |
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.
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 |
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.
/// 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 |
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.
/// `bv_container` for each `ID` in `values[identifier]` and stores them into | |
/// `bv_container` for each `ID` in `values[identifier]` and store them into |
src/analyses/reaching_definitions.h
Outdated
irep_idt identifier; | ||
/// The iterator to the GOTO instruction where the variable has been written to. |
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.
cpp-lint complains: line is too long
src/analyses/reaching_definitions.h
Outdated
/// 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. |
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.
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
.)
/// transform_*` method for the recognised instruction. | |
/// `transform_*` method for the recognised instruction. |
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.
Thanks! Fixed.
41a1446
to
9254419
Compare
@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
9254419
to
1fe3b1a
Compare
@peterschrammel Done. |
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 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.
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 1fe3b1a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93352239
No description provided.