-
Notifications
You must be signed in to change notification settings - Fork 273
Invoke goto_functions.update() after inlining #6493
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backedges are a necessary but not sufficient test for loops so may_have_loops
is good.
I have a vague recollection of a previous "Call update()
after inline" issue / PR.
goto_function_inline( | ||
goto_functions, function_name, ns, log.get_message_handler()); | ||
goto_functions.update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If one should always call them together, wouldn't be safer to add a proper API with both calls? It'd certainly help us to avoid these mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. The problem is the cost of these calls. If you're making multiple modifications to goto programs and don't depend on unique instruction numbers, loop numbering in between, then you should not need to invoke it. There are, in fact, a lot more places in the contracts instrumentation code where such updates need to be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we at least mention in the goto_inline.h
doc that it breaks the internal consistency of the goto model / function and that a call to goto_functionst::update
is needed to restore it? Or maybe in the preconditions of natural_loops
?
What type of modifications require calls to update
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I am wondering where to best document (or implement!) this. Any operations that add or remove instructions for a goto program require calls to update
. I realise that goto_programt::validate
does not actually check for these properties (as documented with the location_number
and loop_number
members of goto_programt::instructiont
).
7a3f2e6
to
62f4b81
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6493 +/- ##
===========================================
- Coverage 76.06% 76.06% -0.01%
===========================================
Files 1546 1546
Lines 165584 165618 +34
===========================================
+ Hits 125951 125975 +24
- Misses 39633 39643 +10
Continue to review full report at Codecov.
|
2a96d8c
to
2d691ea
Compare
Inlining will alter location (instruction) numbers, which need to be updated to once again be globally unique. With this change, invar_check_large requires an assigns clause for the loop as the local may alias analysis returns "UNKNOWN." The previous result was actually unsound, because the automatically computed assigns set did not include arr0, arr1, arr2, arr3, arr4. This also demonstrated that the implementation in the test was incorrect: it would not terminate when: *(arr[h]) == pivot && *(arr[l]) == pivot && h != r && l != r.
2d691ea
to
3af4718
Compare
Inlining will alter location (instruction) numbers, which need to be
updated to once again be globally unique.
This is a follow-up to #6473.