Skip to content

goto-instrument: function pointer removal with value_set_fi #5436

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
Aug 27, 2020

Conversation

polgreen
Copy link
Contributor

@polgreen polgreen commented Jul 29, 2020

This adds a new option to goto-instrument for removing function pointers.
The points-to analysis is done using flow-insensitive value sets, which is
more precise than using the signature of the function to identify the
points-to set.

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

@polgreen polgreen marked this pull request as draft July 29, 2020 18:46
@polgreen polgreen force-pushed the value_set_fi_fp_removal branch 5 times, most recently from 3bb4f5c to d09b28c Compare August 2, 2020 01:08
@polgreen polgreen force-pushed the value_set_fi_fp_removal branch 4 times, most recently from 1e4db2b to 100d938 Compare August 10, 2020 03:38
@polgreen polgreen marked this pull request as ready for review August 10, 2020 03:38
@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #5436 into develop will increase coverage by 0.05%.
The diff coverage is 87.95%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5436      +/-   ##
===========================================
+ Coverage    68.25%   68.30%   +0.05%     
===========================================
  Files         1180     1181       +1     
  Lines        97722    97814      +92     
===========================================
+ Hits         66698    66811     +113     
+ Misses       31024    31003      -21     
Flag Coverage Δ
#cproversmt2 42.81% <ø> (ø)
#regression 65.48% <87.95%> (+0.05%) ⬆️
#unit 32.23% <ø> (ø)

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

Impacted Files Coverage Δ
...rc/goto-instrument/goto_instrument_parse_options.h 100.00% <ø> (ø)
src/goto-instrument/value_set_fi_fp_removal.cpp 87.50% <87.50%> (ø)
.../goto-instrument/goto_instrument_parse_options.cpp 58.65% <100.00%> (+0.17%) ⬆️
src/goto-programs/goto_program.h 92.23% <0.00%> (+0.35%) ⬆️
src/pointer-analysis/value_set_fi.cpp 63.49% <0.00%> (+2.21%) ⬆️
src/analyses/flow_insensitive_analysis.h 59.09% <0.00%> (+9.09%) ⬆️
src/analyses/flow_insensitive_analysis.cpp 71.42% <0.00%> (+10.20%) ⬆️
src/pointer-analysis/value_set_domain_fi.h 28.57% <0.00%> (+14.28%) ⬆️
src/pointer-analysis/value_set_analysis_fi.h 100.00% <0.00%> (+72.72%) ⬆️

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 a6feed2...2960187. Read the comment docs.

@polgreen polgreen force-pushed the value_set_fi_fp_removal branch 5 times, most recently from e98cce3 to 443c0ea Compare August 10, 2020 23:21
@polgreen
Copy link
Contributor Author

I think this is now ready to merge, is anyone available to review it?

@polgreen polgreen force-pushed the value_set_fi_fp_removal branch 4 times, most recently from 8645143 to afdffc7 Compare August 14, 2020 02:29
@smowton
Copy link
Contributor

smowton commented Aug 14, 2020

I'll get to this this weekend

@polgreen
Copy link
Contributor Author

Is anyone free to review this please?

@martin-cs
Copy link
Collaborator

@polgreen sorry for the lag, will try to look tomorrow.

@polgreen polgreen force-pushed the value_set_fi_fp_removal branch from afdffc7 to f0d68fc Compare August 19, 2020 03:36
@polgreen polgreen force-pushed the value_set_fi_fp_removal branch 5 times, most recently from e379fbd to da91cea Compare August 19, 2020 18:58
@polgreen
Copy link
Contributor Author

I think all changes requested are now made

#include <util/std_code.h>
#include <util/union_find.h>

#ifdef USE_STD_STRING

Choose a reason for hiding this comment

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

Not quite sure what this is for?

Copy link
Contributor Author

@polgreen polgreen Aug 21, 2020

Choose a reason for hiding this comment

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

Needed for one of the CI tests, which compiles with this flag and needs this include to compile


void value_set_fi_fp_removal(goto_modelt &goto_model)
{
std::cout << "Doing FI value set analysis\n";

Choose a reason for hiding this comment

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

Should take a messaget and use that instead I’d think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's outdated, it's changed in the latest commit

new_code.destructive_append(final_skip);

// set locations
Forall_goto_program_instructions(it, new_code)

Choose a reason for hiding this comment

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

This could be done without macros:

for(auto const &instruction : new_code.instructions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would need to drop the const in that.

Are the macros now deprecated? Because couldn't everything that is written using the macro also be written without?

Copy link
Collaborator

Choose a reason for hiding this comment

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

They have been deprecated for some time now in favour of the new-style for loops. As to why...

@martin-cs
Copy link
Collaborator

@polgreen I will review next.

^SIGNAL=0$
^ function: f$
--
^ function: g$
Copy link
Collaborator

Choose a reason for hiding this comment

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

Negative as well as positive tests are good.

@polgreen polgreen requested a review from smowton August 21, 2020 15:46
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.

I have Opinions on how function pointer removal should be done but I will spare you those. I think this is a step in the right direction. Thank you especially for the detailed test cases.

int main(void)
{
fp_t fp;
fp();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, anything that happens after this seems a bit dubious to me.

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've flipped the order of the delcarations now

new_code.destructive_append(final_skip);

// set locations
Forall_goto_program_instructions(it, new_code)
Copy link
Collaborator

Choose a reason for hiding this comment

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

They have been deprecated for some time now in favour of the new-style for loops. As to why...

code_assignt(old_lhs, typecast_exprt(tmp_symbol_expr, old_lhs.type()))));
}

void remove_function_pointer(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is good to see this bit of functionality broken out.

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 the macros are deprecated, perhaps they should be marked as deprecated in the goto_program.h?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There was a move to simply replace them all in one go which would have basically caused a number of forks, I think the compromise was the linter would flag them in new code and they would be deprecated 'at some point'. I guess the linter doesn't so... yeah, yeah it would be a good idea.

@@ -1197,6 +1197,9 @@ void value_set_fit::assign_rec(
{
const typet &type = to_index_expr(lhs).array().type();

if(type.id() != ID_array)
Copy link
Member

Choose a reason for hiding this comment

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

❓ This makes the second part of the condition in the data invariant below unreachable.

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've removed this from the PR

@polgreen polgreen force-pushed the value_set_fi_fp_removal branch from da91cea to 7486abb Compare August 24, 2020 23:56
@polgreen polgreen force-pushed the value_set_fi_fp_removal branch from 7486abb to 1c31179 Compare August 25, 2020 15:22
This adds a new option to goto-instrument for removing function pointers.
The points-to analysis is done using flow-insensitive value sets, which is
more precise than using the signature of the function to identify the
points-to set.

Co-authored-by: Elizabeth Polgreen [email protected]
@polgreen polgreen force-pushed the value_set_fi_fp_removal branch from 1c31179 to 2960187 Compare August 25, 2020 15:37
@polgreen
Copy link
Contributor Author

I've now addressed all of the comments in the reviews

@martin-cs
Copy link
Collaborator

Thanks @polgreen ! @peterschrammel and @hannes-steffenhagen-diffblue do you have further comments or can this be merged as it is?

@martin-cs martin-cs merged commit 0740ac2 into diffblue:develop Aug 27, 2020
@polgreen polgreen deleted the value_set_fi_fp_removal branch August 27, 2020 21:08
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.

5 participants