Skip to content

Expression transform #5568

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 4 commits into from
Nov 12, 2020
Merged

Conversation

jezhiggins
Copy link
Contributor

@jezhiggins jezhiggins commented Nov 12, 2020

This PR picks out Hannes' expression transform code from #5429 so we can apply to the mainline.

I've reinstated the -Werror flag in CMakeLists.txt and applied clang-format fixes, but otherwise the code is as it comes.

@martin-cs
Copy link
Collaborator

Paging @hannes-steffenhagen-diffblue : hopefully you don't mind us picking up this PR?

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.

Looks reasonable. If you could squash the reverted change to the CMake file back into the relevant commit so that it doesn't touch the file at all that would be nice, otherwise this is OK.

For other reviewers : one of @jezhiggins 's next tasks is refactoring the handling of command-line arguments for VSD so it will be 'connected up' by a later PR.

@jezhiggins
Copy link
Contributor Author

@martin-cs No problem. I'll do the same for the clang-format fixes.

@jezhiggins jezhiggins force-pushed the expression-transform branch 2 times, most recently from 61c23f6 to bd33802 Compare November 12, 2020 11:25
@hannes-steffenhagen-diffblue
Copy link
Contributor

Hang on a minute this is just far enough in the past for me to give this a fair review I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

For other reviewers : one of @jezhiggins 's next tasks is refactoring the handling of command-line arguments for VSD so it will be 'connected up' by a later PR.

Yeah, this is probably necessary. But clearly doesn’t need to happen here.

@@ -83,6 +84,8 @@ struct vsd_configt
options.get_bool_option("interval");
config.advanced_sensitivities.value_set =
options.get_bool_option("value-set");
config.advanced_sensitivities.new_value_set =
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Nov 12, 2020

Choose a reason for hiding this comment

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

This new_value_set shenanigans probably requires an explanation. The reason here basically is we had an initial implementation of value_set_abstract_objectt that just contained a set of abstract_object_pointert – and that looked like it worked for a couple of example programs, unfortunately that just gave us set semantics over pointers rather than the actual values in them. It also didn’t have a separate class for pointers/arrays which may require different handling.

At the time we thought it’d be bad to just throw all these changes at once in there (especially for reviewers), so we essentially came up with this approach to add a flag to turn on the new behaviour instead and just rename that to "regular value set" once we’d be done implementing it. Unfortunately we didn’t get done with it before other priorities became more pressing.

@@ -57,6 +58,7 @@ class ContainsAllOf
{
oss << ", ";
}
first = false;

Choose a reason for hiding this comment

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

That was just a bug in the original implementation, ouch

@@ -359,3 +361,117 @@ TEST_CASE(

REQUIRE(value_set.to_constant() == value);
}

static abstract_environmentt get_value_set_abstract_environment()
{

Choose a reason for hiding this comment

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

One thing I really like about variable sensitivity that at least in principle most things here are much easier to test in isolation than other parts of the codebase.

expr.type(),
value_set_abstract_valuet::valuest{
expr_with_evaluated_operands_filled_in}),
out_modifications);
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Nov 12, 2020

Choose a reason for hiding this comment

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

For very large expressions there might be some value in exiting early here when value sets get too large and just become TOP. Not super necessary right now I don’t think, but may be worth keeping in mind if it ever turns out we’re spending a ton of time here.

auto eval_result = environment.eval(three_plus_five, ns);
REQUIRE(eval_result != nullptr);
REQUIRE(!eval_result->is_top());
REQUIRE(!eval_result->is_bottom());

Choose a reason for hiding this comment

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

This is failing apparently? Strange, I could swear I remember this working.

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'm investigate this now. Back soon :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They pass on your original branch. I'm trying to investigate further ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change in the abstract_environment default constructor

This branch has
abstract_environmentt::abstract_environmentt() : bottom(true) { }
while the branch this change was originally targetting has
abstract_environmentt::abstract_environmentt() : bottom(false) { }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comes from this commit d9cc8ac

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I patch the abstract_value.cpp unit test so instead of the default environment, it explicitly makes it top

  auto environment = abstract_environmentt{};
  environment.make_top();
  return environment;

then the unit tests pass. @hannes-steffenhagen-diffblue Is this ok with you? If so, I'll fixup that last commit, and we should be good.

Choose a reason for hiding this comment

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

Sounds reasonable to me.

@codecov
Copy link

codecov bot commented Nov 12, 2020

Codecov Report

Merging #5568 (16300bd) into develop (df544aa) will increase coverage by 0.01%.
The diff coverage is 94.28%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5568      +/-   ##
===========================================
+ Coverage    69.28%   69.29%   +0.01%     
===========================================
  Files         1241     1241              
  Lines       100436   100471      +35     
===========================================
+ Hits         69589    69625      +36     
+ Misses       30847    30846       -1     
Flag Coverage Δ
cproversmt2 43.05% <ø> (ø)
regression 66.19% <14.28%> (-0.05%) ⬇️
unit 32.25% <90.90%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...es/variable-sensitivity/value_set_abstract_value.h 100.00% <ø> (ø)
.../variable-sensitivity/value_set_abstract_value.cpp 95.65% <93.10%> (+5.65%) ⬆️
...ensitivity/variable_sensitivity_object_factory.cpp 93.10% <100.00%> (+0.51%) ⬆️
...-sensitivity/variable_sensitivity_object_factory.h 97.56% <100.00%> (+0.12%) ⬆️

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 df544aa...16300bd. Read the comment docs.

@martin-cs martin-cs merged commit aa069d3 into diffblue:develop Nov 12, 2020
@jezhiggins jezhiggins deleted the expression-transform branch November 12, 2020 16:53
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.

3 participants