Skip to content

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

Merged
merged 1 commit into from
Jan 17, 2017
Merged

Conversation

danpoe
Copy link
Contributor

@danpoe 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

@kroening
Copy link
Member

May I ask for some reasonable squashing of commits, please?

@kroening kroening self-assigned this Oct 30, 2016
@danpoe danpoe force-pushed the goto-function-inlining branch from 3204cf1 to 70a0ae3 Compare October 31, 2016 11:06
@danpoe
Copy link
Contributor Author

danpoe commented Oct 31, 2016

Ok, done.

@danpoe danpoe force-pushed the goto-function-inlining branch from 3f66250 to 983c080 Compare November 17, 2016 16:50
@kroening
Copy link
Member

kroening commented Dec 6, 2016

May I have a rebase, please?

@danpoe danpoe force-pushed the goto-function-inlining branch 2 times, most recently from 69fa5d1 to 9ddfb85 Compare December 13, 2016 15:47
@danpoe
Copy link
Contributor Author

danpoe commented Dec 13, 2016

Ok, I've rebased it.

Copy link
Collaborator

@tautschnig tautschnig left a 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):" \
Copy link
Collaborator

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!

Copy link
Contributor Author

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"))
Copy link
Collaborator

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

Copy link
Collaborator

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;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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();
}
Copy link
Collaborator

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() ?

Copy link
Contributor Author

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?

Copy link
Collaborator

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);
}
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 surprised this code is marked as new, I thought we had had it before already?

Copy link
Contributor Author

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>
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 being used here?

@tautschnig tautschnig assigned danpoe and unassigned kroening Dec 13, 2016
@danpoe danpoe force-pushed the goto-function-inlining branch from 9ddfb85 to 3095608 Compare December 19, 2016 22:24
Copy link
Collaborator

@tautschnig tautschnig left a 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.

@danpoe
Copy link
Contributor Author

danpoe commented Jan 11, 2017

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:

  • parameter_assignments()
  • parameter_destruction()
  • replace_return()
  • replace_location()
  • insert_function_body()
  • insert_function_nobody()

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;
Copy link
Collaborator

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);
Copy link
Collaborator

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>
Copy link
Collaborator

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++)
Copy link
Collaborator

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.

@danpoe danpoe force-pushed the goto-function-inlining branch from 3095608 to a5faba6 Compare January 11, 2017 15:50

status() << "Inlining calls of function `" << function << "'" << eom;

if(!cmdline.isset("log"))
Copy link
Collaborator

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.

@martin-cs
Copy link
Collaborator

@danpoe There are a page or so of linter errors; please could you fix ASAP.

@kroening Merging this will help speed up work on the Toyota project. Michael has signed it off; please can you merge it?

@danpoe danpoe force-pushed the goto-function-inlining branch 3 times, most recently from b162e12 to d83ca14 Compare January 13, 2017 11:02
@danpoe
Copy link
Contributor Author

danpoe commented Jan 13, 2017

Ok, the linter issues are also fixed now.

@danpoe danpoe force-pushed the goto-function-inlining branch from d83ca14 to 5150c62 Compare January 17, 2017 12:12
@peterschrammel
Copy link
Member

@kroening, this looks mergeable now.

@danpoe danpoe force-pushed the goto-function-inlining branch from 5150c62 to 05f19bf Compare January 17, 2017 14:03
@kroening kroening merged commit c655301 into diffblue:master Jan 17, 2017
@danpoe danpoe deleted the goto-function-inlining branch January 17, 2017 17:46
smowton added a commit to smowton/cbmc that referenced this pull request May 9, 2018
…avis_config

Update Travis config to reflect upstream changes
chrisr-diffblue added a commit to chrisr-diffblue/cbmc that referenced this pull request Aug 24, 2018
Include GOTO guard expressions in variable sensitivity data dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants