-
Notifications
You must be signed in to change notification settings - Fork 276
Goto function inlining #262
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
danpoe
commented
Oct 21, 2016
- enhanced goto_inlinet to support inlining at the granularity of function calls, specifying whether inlining should be done transitively or non-transitively, and whether to put skip or leave function call on recursion
- new option --function-inline for goto-instrument to transitively inline all calls a given function makes
May I ask for some reasonable squashing of commits, please? |
3204cf1
to
70a0ae3
Compare
Ok, done. |
3f66250
to
983c080
Compare
May I have a rebase, please? |
69fa5d1
to
9ddfb85
Compare
Ok, I've rebased it. |
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.
I won't claim to have done a thorough review of the key implementation parts, but do have concerns about the merge that has happened in goto_instrument_parse_options.cpp. Could you please review this?
@@ -51,7 +51,7 @@ Author: Daniel Kroening, [email protected] | |||
"(show-struct-alignment)(interval-analysis)(show-intervals)" \ | |||
"(show-uninitialized)(show-locations)" \ | |||
"(full-slice)(reachability-slice)" \ | |||
"(inline)(remove-function-pointers)" \ | |||
"(inline)(partial-inline)(function-inline):(log):" \ |
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.
The rebase seems to have introduced a bug here: the "remove-function-pointers" option should not go away!
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.
Yes, that's a bug.
|
||
status() << "Inlining calls of function `" << function << "'" << eom; | ||
|
||
if(!cmdline.isset("log")) |
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.
The log option is not documented in the help output
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.
For my own record: done.
} | ||
else | ||
{ | ||
std::cout << result << std::endl; |
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.
Shouldn't that be status() instead of std::cout?
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.
result
is a json object and it should be printed no matter the log level.
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.
Ok, thanks for clarifying!
|
||
goto_functions.update(); | ||
goto_functions.compute_loop_numbers(); | ||
} |
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.
Should this be replaced by a call to do_partial_inlining() ?
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.
The inliner has an option adjust_function
which indicates whether the function
field of the inlined instructions should be updated to the value of the function they are being inlined into. The behavior of the previous inliner was to not change the function field. do_partial_inlining()
still follows this old behavior, whereas here we do adjust the function
field.
The reason why the function
field has previously not been updated seems to have to do with how loop ids are formed. I would vote to always update the function
field and make loop ids independent of that (as suggested in #295). What's your opinion on this?
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.
I'll add my comments in #295; thanks for clarifying why do_partial_inlining wouldn't do the job here.
|
||
status() << "Performing full inlining" << eom; | ||
goto_inline(goto_functions, ns, ui_message_handler, true); | ||
} |
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.
I am surprised this code is marked as new, I thought we had had it before already?
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.
Yes that's strange. Only line 1064 is new.
@@ -6,6 +6,7 @@ Author: Daniel Kroening, [email protected] | |||
|
|||
\*******************************************************************/ | |||
|
|||
#include <iostream> |
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.
Is that really being used here?
9ddfb85
to
3095608
Compare
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.
See my earlier comments for changes that had been requested. I remain a bit confused by what genuinely is new code vs. what github thinks is new.
Thanks for your help in getting this merged. I checked the diffs and they're mostly reasonable. Code that is marked as new and is based on existing code concerns the following functions:
Those functions are based on previously existing code which I separated out into these functions (with some changes). |
catch(const char *e) | ||
{ | ||
goto_inline.error() << e << messaget::eom; | ||
throw 0; |
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.
Applies above as well: calling error() here makes it impossible to include/report a source location. Couldn't you invoke error() at place where an exception is thrown at present, and then throw 0;
in those places?
|
||
goto_inline.smallfunc_limit=_smallfunc_limit; | ||
goto_functionst::function_mapt::iterator f_it | ||
=goto_functions.function_map.find(function); |
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.
assignment operator on preceding line
|
||
//#define DEBUG | ||
|
||
#include <iostream> |
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.
Should not be necessary
for(code_typet::parameterst::const_iterator | ||
it2=parameter_types.begin(); | ||
it2!=parameter_types.end(); | ||
it2++) |
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.
My understanding is that this is existing code. In future, this should be moved to a ranged for.
3095608
to
a5faba6
Compare
|
||
status() << "Inlining calls of function `" << function << "'" << eom; | ||
|
||
if(!cmdline.isset("log")) |
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.
For my own record: done.
b162e12
to
d83ca14
Compare
Ok, the linter issues are also fixed now. |
d83ca14
to
5150c62
Compare
@kroening, this looks mergeable now. |
5150c62
to
05f19bf
Compare
…avis_config Update Travis config to reflect upstream changes
Include GOTO guard expressions in variable sensitivity data dependencies