Skip to content

Update after remove returns #4151

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 2 commits into from
Mar 2, 2019

Conversation

tautschnig
Copy link
Collaborator

This reverts #4147 and instead introduces a local update. This yields a much simpler protocol, as the size of the change also shows.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a 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

@allredj allredj left a 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: 66e0b75).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100406202
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.

Copy link
Contributor

@allredj allredj left a 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: e362c86).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100411075

@@ -1447,9 +1443,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
{
do_indirect_call_and_rtti_removal();

// recalculate numbers, etc.
goto_model.goto_functions.update();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this actually still needed, seeing as this follows from do_indirect_call_and_rtti_removal, not do_return_removal ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, this commit just reverts that earlier change, I don't think it ever was needed.

@kroening
Copy link
Member

Note that the location numbers are global, not local to a function. The global update is too expensive to be performed after every transformation.

What needs to be done here is to clean up goto_instrument to have a concept of 'steps', which can then imply a next step or require a previous step.

@tautschnig
Copy link
Collaborator Author

Note that the location numbers are global, not local to a function. The global update is too expensive to be performed after every transformation.

The proposed change here only does a single-function update, not the global one. It will not ensure globally unique numbers, but will ensure we have increasing numbers per function. We could instead use the facility from goto_functionst that does permit incremental numbering.

What needs to be done here is to clean up goto_instrument to have a concept of 'steps', which can then imply a next step or require a previous step.

That might work for goto-instrument, but would then still leave any other users of remove_returns at risk to be broken. Can we please please please avoid those implicit obligations and instead make things usable as building blocks where requirements are preferably guaranteed or at bare minimum documented?

@kroening
Copy link
Member

I agree on the pain point entirely.
I think the right thing to do is to get rid of the location number altogether. I'll look into it.

@kroening
Copy link
Member

The (relatively) easy thing to appears to be to change the location number to be locally unique, not globally.

@smowton
Copy link
Contributor

smowton commented Feb 11, 2019

Could I suggest passing goto_model_functiont to the pass instead of goto_programt? That wraps a goto_programt but also provides a back-pointer to its enclosing model for numbering purposes: https://github.com/diffblue/cbmc/blob/develop/src/goto-programs/goto_model.h#L165

@tautschnig tautschnig force-pushed the update-after-remove-returns branch from e362c86 to 989ffad Compare February 24, 2019 23:40
@tautschnig
Copy link
Collaborator Author

As removal of location numbers is a larger task that may not be completed in the near future I have followed @smowton's suggestion, which did not require many changes at all.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Looks good except I think you should remove every occurrence of ! from the PR ;)

@@ -142,10 +142,14 @@ void remove_returnst::replace_returns(
/// \param function_is_stub: function (irep_idt -> bool) that determines whether
/// a given function ID is a stub
/// \param goto_program: program to transform
void remove_returnst::do_function_calls(
/// \return False if, and only if, instructions have been inserted. In that case
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely returning true if something has been done would be more intuitive? I appreciate there are various cbmc functions using the unix shell "zero = success" pattern, but I don't think this is a success/failure return.

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 couldn't decide... - so I'll happily take the guidance that you and @thk123 provided and will amend this.

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

I note the original PR didn't have any tests, so it'd be great if possible to add one here?

I also strongly support @smowton's suggestion to return true if something happened. This is consistent with STL things where returning true indicates that something was inserted in to the set, for example. If also removes all the ! you have to put in at the callsite

@tautschnig
Copy link
Collaborator Author

I note the original PR didn't have any tests, so it'd be great if possible to add one here?

To be honest, I have no idea how to create a regression test for this (a unit test would seem possible, of course): In #4147 @kroening claimed that #4001 (which has since been merged) would fail without the fix, but even when using just the revert without the fix I cannot make any test fail. All of the code paths in goto-instrument take care of updating location numbers before any output is generated.

@tautschnig tautschnig force-pushed the update-after-remove-returns branch from 989ffad to 845d60d Compare February 25, 2019 12:56
Copy link
Contributor

@allredj allredj left a 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: 845d60d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102161974
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.

@kroening
Copy link
Member

@tautschnig The failure was on Windows only, which made it really hard to diagnose.

@kroening
Copy link
Member

The problem with this PR is still that it kills the global uniqueness of the location numbers?
If this is what we want, it needs a bigger audit.

@tautschnig
Copy link
Collaborator Author

@tautschnig The failure was on Windows only, which made it really hard to diagnose.

I'll try to reproduce it. Marking this PR work-in-progress for the moment.

The problem with this PR is still that it kills the global uniqueness of the location numbers?

No, goto_functionst maintains a counter and will only ever assign previously unused numbers. As a result there may be gaps, but numbers will be globally unique, and strictly monotone and contiguous per-function.

Copy link
Contributor

@allredj allredj left a 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: db63e03).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102299143

This reverts commit abbb389.

In diffblue#2089 a broad cleanup of redundant calls to .update() was done. Let's stay in
this spirit and call .update() when necessary, and not "just to be safe."
remove_returnst::do_function_calls may introduce new instructions. Doing so
requires a call to compute_location_numbers to ensure instruction numbers are
assigned. To avoid recomputing location numbers across all goto functions, the
facility from goto_functionst is used, which will ensure globally unique
location numbers (though they might not be globally contiguous).
@tautschnig tautschnig force-pushed the update-after-remove-returns branch from db63e03 to cdab267 Compare February 26, 2019 11:28
@tautschnig
Copy link
Collaborator Author

I'll try to reproduce it. Marking this PR work-in-progress for the moment.

It seems that removing the bug fix does not actually make any tests fail. I'll refrain from doing more debugging as certainly there is a possible problem, but we seemingly have a number of mitigations in place.

Putting this PR back in ready-for-review.

Copy link
Contributor

@allredj allredj left a 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: cdab267).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102315448

@tautschnig tautschnig merged commit ee11014 into diffblue:develop Mar 2, 2019
@tautschnig tautschnig deleted the update-after-remove-returns branch March 2, 2019 06:19
@tautschnig tautschnig restored the update-after-remove-returns branch December 27, 2020 06:43
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.

7 participants