Skip to content

Move exprt::bounded_size to complexity_limitert #5988

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
Apr 29, 2021

Conversation

tautschnig
Copy link
Collaborator

complexity_limitert is really the only user of this method, and may be
fine with its implementation details (cf. discussion in #5914). For
other potential users such assumptions might not be safe.

  • 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.
  • 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.

Copy link
Contributor

@TGWDB TGWDB left a comment

Choose a reason for hiding this comment

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

Minor tweaks on text matching new names noted.

Outside of this, there were many experiments with CSE (some info #5964) that used the expression size and these showed that this could be a useful parameter to manipulate. I note this because if we want to have a bounded size for expressions later this would involve a refactor to return this to expr and not be in complexity_limiter.

#include <goto-symex/complexity_limiter.h>

TEST_CASE(
"Bounded size is computed correctly",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Bounded size" -> "Bounded expr[ession] size"

}

TEST_CASE(
"Bounded size versus pathological example",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Bounded size" -> "Bounded expr[ession] size"

exprt pathology = plus_exprt(from_integer(1, type), from_integer(1, type));
// Create an infinite exprt by self reference!
pathology.add_to_operands(pathology);
// If bounded size is not checking the bound this will never terminate.
Copy link
Contributor

Choose a reason for hiding this comment

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

"Bounded size" -> "Bounded expr[ession] size"

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.

This is an improvement. I'd rather we didn't have the for/recurse without caching but this is an improvement.

{
return count;
}
count = bounded_expr_size(op, count, limit);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we aren't going to fix this, can we at least have a comment saying this is potentially risky?

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 now added to the public member function.

@tautschnig tautschnig force-pushed the bounded-size-cleanup branch 2 times, most recently from a1dd075 to bad8e11 Compare March 31, 2021 16:28
@tautschnig
Copy link
Collaborator Author

tautschnig commented Mar 31, 2021

Minor tweaks on text matching new names noted.

Outside of this, there were many experiments with CSE (some info #5964) that used the expression size and these showed that this could be a useful parameter to manipulate. I note this because if we want to have a bounded size for expressions later this would involve a refactor to return this to expr and not be in complexity_limiter.

Thanks a lot for the comments, text changes implemented.

As far as re-use is concerned: if it turns out to be useful, then we could certainly consider moving this elsewhere. If we do, however, then IMHO it should be somewhere around irept as there isn't anything exprt specific happening here: operands() is the same as sub(), and this code really counts the number of unnamed subs.

complexity_limitert is really the only user of this method, and may be
fine with its implementation details (cf. discussion in diffblue#5914). For
other potential users such assumptions might not be safe.
@codecov
Copy link

codecov bot commented Mar 31, 2021

Codecov Report

Merging #5988 (8f61a22) into develop (e76d811) will increase coverage by 0.01%.
The diff coverage is 93.10%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5988      +/-   ##
===========================================
+ Coverage    75.12%   75.13%   +0.01%     
===========================================
  Files         1435     1445      +10     
  Lines       156301   157261     +960     
===========================================
+ Hits        117416   118165     +749     
- Misses       38885    39096     +211     
Impacted Files Coverage Δ
src/goto-symex/complexity_limiter.h 100.00% <ø> (ø)
src/util/expr.cpp 73.80% <ø> (-1.93%) ⬇️
src/util/expr.h 97.84% <ø> (ø)
unit/util/expr.cpp 100.00% <ø> (ø)
src/memory-analyzer/gdb_api.cpp 86.89% <50.00%> (ø)
unit/memory-analyzer/gdb_api.cpp 86.46% <94.73%> (ø)
src/goto-symex/complexity_limiter.cpp 96.73% <100.00%> (+0.39%) ⬆️
unit/goto-symex/complexity_limiter.cpp 100.00% <100.00%> (ø)
src/util/std_expr.h 92.62% <0.00%> (-0.53%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11149ef...8f61a22. Read the comment docs.

@kroening kroening merged commit 06de9f4 into diffblue:develop Apr 29, 2021
@tautschnig tautschnig deleted the bounded-size-cleanup branch April 29, 2021 13:20
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.

4 participants