Skip to content
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

Port the last user of static_analysist #6482

Merged

Conversation

martin-cs
Copy link
Collaborator

This ports value_set_analysis, which was the last user of deprecated static_analysist to use ait. Note that this is not the value set analysis code used by cbmc; this one is only used by goto-instrument (see #6469 ). There are a few supporting changes to the ait infrastructure which are necessary but technically independent. It is best to review commit by commit. Note that the test case is added before the porting and works both before and after so most of the output is preserved (the afterwards, ait output has slightly more as it also outputs the instructions).

@martin-cs
Copy link
Collaborator Author

At this stage I haven't removed static_analysist as I don't know if there are out-of-tree users but @tautschnig ported the other users 8 years ago (

#error Deprecated, use ai.h instead
) so maybe it is time to get rid of it?

@peterschrammel
Copy link
Member

maybe it is time to get rid of it?

no objections

@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch 2 times, most recently from b8180db to 06e0910 Compare November 27, 2021 17:06
@martin-cs
Copy link
Collaborator Author

I am seeing unit test failures in https://github.com/diffblue/cbmc/blame/develop/jbmc/unit/pointer-analysis/custom_value_set_analysis.cpp which I think are because ait lazily initializes domains while static_analysist would initialize everything up front. This should be fixable but the existence and way the test is written makes me wonder if this is checking an interface that Diffblue code is using, any thoughts @smowton @chrisr-diffblue @peterschrammel @NlightNFotis ?

src/pointer-analysis/value_set_domain.h Show resolved Hide resolved
Comment on lines +98 to +101
exprt get_return_lhs(locationt to) const
{
// get predecessor of "to"
to--;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering whether get_return_lhs should have a different interface: decrementing to is an unchecked operation, and would be undefined when to already is the beginning of a container.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes; it is a risky bit of code and far from an ideal design. It is moved over because I was trying to preserve functionality and structure where I could. I should refactor this though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have had a look at this and when doing a "return" edge from END_FUNCTION, decrementing to really is the best way of getting the function call instruction. That is probably a wider API failure. However the only case in which this is actually needed is to handle the return value. So if we are happy return removal has always been done first then it is fine to just remove all of this code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am mildly concerned that some of the more obscure users might not ensure this so I think I will just simplify but preserve the functionality.

Comment on lines +103 to +104
if(to->is_end_function())
return static_cast<const exprt &>(get_nil_irep());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that really a possible scenario, i.e., can decrementing to result in reaching an END_FUNCTION instruction? If so, is passing a one-past-the-end iterator to get_return_lhs a realistic scenario?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I really don't think it should be. I think this bit of code is only used in END_FUNCTION where to is the instruction after the call.

src/pointer-analysis/value_set_domain.h Show resolved Hide resolved
@smowton
Copy link
Contributor

smowton commented Nov 30, 2021

Memories of this far too foggy to be authoritative, but I think this was added so the security project (RIP) could do value-set-analysis-with-tweaks.

@peterschrammel
Copy link
Member

@martin-cs, please adapt the test for use with ait instead of static_analysist. Any custom value set analysis using this will need to upgrade to ait anyway.

@martin-cs
Copy link
Collaborator Author

@chrisr-diffblue thanks, that does ring a bell... I will assume that changes to this are not going to be high-risk for Diffblue.

@peterschrammel Will do, I think the changes should be very minimal.

@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from 06e0910 to d07e6a5 Compare June 15, 2022 12:44
@martin-cs martin-cs requested a review from chris-ryder as a code owner June 15, 2022 12:44
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from d07e6a5 to 867dd02 Compare July 22, 2022 12:44
@NlightNFotis
Copy link
Contributor

A couple of jobs failed because the reference to file has not been removed from the `makefiles.

@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch 3 times, most recently from f4d7037 to 07d63a5 Compare July 27, 2022 15:02
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from 07d63a5 to b5666ba Compare August 11, 2022 17:24
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from b5666ba to b517a56 Compare November 18, 2022 18:38
@martin-cs martin-cs requested a review from kroening as a code owner November 18, 2022 18:38
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from b517a56 to b6ed850 Compare September 1, 2023 12:12
martin added 4 commits September 9, 2023 19:08
The corresponding text function has been public for a long time and there
is not reason why the JSON and XML ones can't be as they are const and are
called from other public methods.
This is used by the majority of domains and if you don't want to / can't
implement make_top() then you probably want a custom make_entry() anyway.
This is a net saving of code!
Previously there were no direct checks for this functionality, only for
users such as the memory model functionality.
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from b6ed850 to a1ee415 Compare September 9, 2023 18:45
@martin-cs
Copy link
Collaborator Author

@peterschrammel @tautschnig : you both reviewed and approved this back in the distant past. I am trying to get it moving again. The PR is essentially identical but with the fix for the issue with the custom value set analysis and removal of static_analysist. These were the outstanding issues from the reviews. If you want another look then do shout, otherwise I will merge it when I can get CI to pass!

martin and others added 3 commits September 9, 2023 19:51
This removes the last in-tree use of static_analysis.{h,cpp}.
It also gives the option of using value_set_domain with the history
options to perform per-path value-set analysis.
shared_ptr's are returned rather than references as it allows the abstract
interpreter to synthesise domains at query time, either for unexplored
locations or merging multiple traces.
This has been deprecated for many many years and only had one user
which was a more obscure feature of goto-instrument.  ait is better
in almost every direction.
@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from a1ee415 to e0e9bde Compare September 9, 2023 18:51
@codecov
Copy link

codecov bot commented Sep 9, 2023

Codecov Report

Patch coverage: 61.42% and project coverage change: +0.72% 🎉

Comparison is base (92581d1) 78.27% compared to head (168901f) 78.99%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6482      +/-   ##
===========================================
+ Coverage    78.27%   78.99%   +0.72%     
===========================================
  Files         1699     1696       -3     
  Lines       195410   195105     -305     
===========================================
+ Hits        152953   154123    +1170     
+ Misses       42457    40982    -1475     
Files Changed Coverage Δ
src/analyses/ai.h 64.28% <ø> (ø)
src/analyses/constant_propagator.h 83.33% <ø> (+0.98%) ⬆️
src/analyses/custom_bitvector_analysis.h 55.26% <ø> (-3.28%) ⬇️
src/analyses/escape_analysis.h 60.00% <ø> (-5.22%) ⬇️
src/analyses/global_may_alias.h 0.00% <ø> (ø)
src/analyses/interval_domain.h 100.00% <ø> (ø)
src/analyses/reaching_definitions.h 86.95% <ø> (-0.55%) ⬇️
src/analyses/uninitialized_domain.h 53.33% <ø> (-2.23%) ⬇️
...ensitivity/variable_sensitivity_dependence_graph.h 78.68% <ø> (-1.00%) ⬇️
...riable-sensitivity/variable_sensitivity_domain.cpp 89.94% <ø> (-0.16%) ⬇️
... and 9 more

... and 58 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martin-cs martin-cs force-pushed the refactor/remove-static-analysis branch from bffd94f to 168901f Compare September 10, 2023 11:35
@martin-cs
Copy link
Collaborator Author

I'm going to ignore the patch coverage metric because of the increase of project coverage.

@tautschnig tautschnig merged commit 460032c into diffblue:develop Sep 11, 2023
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.

6 participants