-
Notifications
You must be signed in to change notification settings - Fork 273
Reimplement remove-static-init-loops to avoid need to inspect GOTO program #1815
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
smowton
merged 1 commit into
diffblue:develop
from
smowton:smowton/feature/replace-clinit-unwinder
Feb 14, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/remove_asm.h> | ||
#include <goto-programs/remove_unused_functions.h> | ||
#include <goto-programs/remove_skip.h> | ||
#include <goto-programs/remove_static_init_loops.h> | ||
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/show_goto_functions.h> | ||
#include <goto-programs/show_symbol_table.h> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected] | |
#define CPROVER_CBMC_SYMEX_BMC_H | ||
|
||
#include <util/message.h> | ||
#include <util/threeval.h> | ||
|
||
#include <goto-symex/goto_symex.h> | ||
|
||
|
@@ -53,6 +54,43 @@ class symex_bmct: public goto_symext | |
loop_limits[id]=limit; | ||
} | ||
|
||
/// Loop unwind handlers take the function ID and loop number, the unwind | ||
/// count so far, and an out-parameter specifying an advisory maximum, which | ||
/// they may set. If set the advisory maximum is set it is *only* used to | ||
/// print useful information for the user (e.g. "unwinding iteration N, max | ||
/// M"), and is not enforced. They return true to halt unwinding, false to | ||
/// authorise unwinding, or Unknown to indicate they have no opinion. | ||
typedef | ||
std::function<tvt(const irep_idt &, unsigned, unsigned, unsigned &)> | ||
loop_unwind_handlert; | ||
|
||
/// Recursion unwind handlers take the function ID, the unwind count so far, | ||
/// and an out-parameter specifying an advisory maximum, which they may set. | ||
/// If set the advisory maximum is set it is *only* used to print useful | ||
/// information for the user (e.g. "unwinding iteration N, max M"), | ||
/// and is not enforced. They return true to halt unwinding, false to | ||
/// authorise unwinding, or Unknown to indicate they have no opinion. | ||
typedef std::function<tvt(const irep_idt &, unsigned, unsigned &)> | ||
recursion_unwind_handlert; | ||
|
||
/// Add a callback function that will be called to determine whether to unwind | ||
/// loops. The first function added will get the first chance to answer, and | ||
/// the first authoratitive (true or false) answer is final. | ||
/// \param handler: new callback | ||
void add_loop_unwind_handler(loop_unwind_handlert handler) | ||
{ | ||
loop_unwind_handlers.push_back(handler); | ||
} | ||
|
||
/// Add a callback function that will be called to determine whether to unwind | ||
/// recursion. The first function added will get the first chance to answer, | ||
/// and the first authoratitive (true or false) answer is final. | ||
/// \param handler: new callback | ||
void add_recursion_unwind_handler(recursion_unwind_handlert handler) | ||
{ | ||
recursion_unwind_handlers.push_back(handler); | ||
} | ||
|
||
bool output_coverage_report( | ||
const goto_functionst &goto_functions, | ||
const std::string &path) const | ||
|
@@ -67,6 +105,8 @@ class symex_bmct: public goto_symext | |
// 1) a global limit (max_unwind) | ||
// 2) a limit per loop, all threads | ||
// 3) a limit for a particular thread. | ||
// 4) zero or more handler functions that can special-case particular | ||
// functions or loops | ||
// We use the most specific of the above. | ||
|
||
unsigned max_unwind; | ||
|
@@ -78,6 +118,12 @@ class symex_bmct: public goto_symext | |
typedef std::map<unsigned, loop_limitst> thread_loop_limitst; | ||
thread_loop_limitst thread_loop_limits; | ||
|
||
/// Callbacks that may provide an unwind/do-not-unwind decision for a loop | ||
std::vector<loop_unwind_handlert> loop_unwind_handlers; | ||
/// Callbacks that may provide an unwind/do-not-unwind decision for a | ||
/// recursive call | ||
std::vector<recursion_unwind_handlert> recursion_unwind_handlers; | ||
|
||
// | ||
// overloaded from goto_symext | ||
// | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be possible to do, as first commit, a full revert of the commit that introduced
remove_static_init_loops
? Too much might have changed since, though.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.
On inspection, I don't think I will, as b49a7fc introduces
remove_static_init_loops
, but also introduces the command-line option and propagation and the Java enumeration parsing and annotation, both of which I do still want, and does some re-linting in touched files, which again it is undesirable to revert. Add that the code has been touched in the intervening time and it's more trouble than it's worth.A lesson in splitting independent changes into different commits to be had here...