-
Notifications
You must be signed in to change notification settings - Fork 275
Upstream slice functions #2758
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
Upstream slice functions #2758
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
void a() | ||
{ | ||
int e; | ||
} | ||
|
||
void b() | ||
{ | ||
double f; | ||
if(f == 0) | ||
a(); | ||
} | ||
|
||
void c() | ||
{ | ||
int d; | ||
} | ||
|
||
int main() | ||
{ | ||
int k; | ||
if(k == 0) | ||
{ | ||
int l; | ||
a(); | ||
c(); | ||
} | ||
else | ||
{ | ||
b(); | ||
} | ||
int n; | ||
a(); | ||
return n; | ||
} |
11 changes: 11 additions & 0 deletions
11
regression/goto-instrument/fp-reachability-slice1/test.desc
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CORE | ||
main.c | ||
--fp-reachability-slice c | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
1: ASSUME FALSE | ||
dead e; | ||
dead d; | ||
-- | ||
^warning: ignoring | ||
dead f; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
void a() | ||
{ | ||
int e; | ||
} | ||
|
||
void b() | ||
{ | ||
double f; | ||
if(f == 0) | ||
a(); | ||
} | ||
|
||
void c() | ||
{ | ||
int d; | ||
} | ||
|
||
int main() | ||
{ | ||
int k; | ||
if(k == 0) | ||
{ | ||
int l; | ||
a(); | ||
c(); | ||
} | ||
else | ||
{ | ||
b(); | ||
} | ||
int n; | ||
a(); | ||
return n; | ||
} |
10 changes: 10 additions & 0 deletions
10
regression/goto-instrument/fp-reachability-slice2/test.desc
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE | ||
main.c | ||
--fp-reachability-slice a,c | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
dead d; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (for comparison, this is better) |
||
dead e; | ||
-- | ||
^warning: ignoring | ||
dead f; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
void a() | ||
{ | ||
int e; | ||
} | ||
|
||
void b() | ||
{ | ||
double f; | ||
if(f == 0) | ||
a(); | ||
} | ||
|
||
void c() | ||
{ | ||
int d; | ||
} | ||
|
||
int main() | ||
{ | ||
int k; | ||
if(k == 0) | ||
{ | ||
int l; | ||
a(); | ||
c(); | ||
} | ||
else | ||
{ | ||
b(); | ||
} | ||
int n; | ||
a(); | ||
return n; | ||
} |
11 changes: 11 additions & 0 deletions
11
regression/goto-instrument/fp-reachability-slice3/test.desc
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CORE | ||
main.c | ||
--fp-reachability-slice b,c | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No meaningful positive conditions |
||
1 file main.c line 34 | ||
-- | ||
^warning: ignoring | ||
dead d; | ||
dead e; | ||
dead f; |
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
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 |
---|---|---|
|
@@ -71,6 +71,7 @@ Author: Daniel Kroening, [email protected] | |
"(show-struct-alignment)(interval-analysis)(show-intervals)" \ | ||
"(show-uninitialized)(show-locations)" \ | ||
"(full-slice)(reachability-slice)(slice-global-inits)" \ | ||
"(fp-reachability-slice):" \ | ||
"(inline)(partial-inline)(function-inline):(log):(no-caching)" \ | ||
OPT_REMOVE_CONST_FUNCTION_POINTERS \ | ||
"(print-internal-representation)" \ | ||
|
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 |
---|---|---|
|
@@ -17,9 +17,12 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <stack> | ||
|
||
#include <goto-programs/cfg.h> | ||
#include <goto-programs/remove_calls_no_body.h> | ||
#include <goto-programs/remove_skip.h> | ||
#include <goto-programs/remove_unreachable.h> | ||
#include <goto-programs/cfg.h> | ||
|
||
#include "util/message.h" | ||
|
||
#include "full_slicer_class.h" | ||
#include "reachability_slicer_class.h" | ||
|
@@ -91,8 +94,7 @@ void reachability_slicert::fixedpoint_to_assertions( | |
"all function return edges should point to the successor of a " | ||
"FUNCTION_CALL instruction"); | ||
stack.emplace_back(edge.first, true); | ||
stack.emplace_back( | ||
cfg.entry_map[std::prev(node.PC)], caller_is_known); | ||
stack.emplace_back(cfg.entry_map[std::prev(node.PC)], caller_is_known); | ||
} | ||
else if(pred_node.PC->is_function_call()) | ||
{ | ||
|
@@ -193,7 +195,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions) | |
{ | ||
Forall_goto_program_instructions(i_it, f_it->second.body) | ||
{ | ||
const cfgt::nodet &e=cfg[cfg.entry_map[i_it]]; | ||
cfgt::nodet &e = cfg[cfg.entry_map[i_it]]; | ||
if( | ||
!e.reaches_assertion && !e.reachable_from_assertion && | ||
!i_it->is_end_function()) | ||
|
@@ -240,6 +242,29 @@ void reachability_slicer( | |
s(goto_model.goto_functions, p, include_forward_reachability); | ||
} | ||
|
||
/// Perform reachability slicing on goto_model for selected functions. | ||
/// \param goto_model Goto program to slice | ||
/// \param functions_list The functions relevant for the slicing (i.e. starting | ||
/// point for the search in the CFG). Anything that is reachable in the CFG | ||
/// starting from these functions will be kept. | ||
void function_path_reachability_slicer( | ||
goto_modelt &goto_model, | ||
const std::list<std::string> &functions_list) | ||
{ | ||
for(const auto &function : functions_list) | ||
{ | ||
in_function_criteriont matching_criterion(function); | ||
reachability_slicert slicer; | ||
slicer(goto_model.goto_functions, matching_criterion, true); | ||
} | ||
|
||
remove_calls_no_bodyt remove_calls_no_body; | ||
remove_calls_no_body(goto_model.goto_functions); | ||
|
||
goto_model.goto_functions.update(); | ||
goto_model.goto_functions.compute_loop_numbers(); | ||
} | ||
|
||
/// Perform reachability slicing on goto_model, with respect to criterion | ||
/// comprising all properties. Only instructions from which the criterion | ||
/// is reachable will be kept. | ||
|
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
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
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.
This is a bit easy to pass at the moment, especially if the precise pretty-printing of "dead f" were to change. Suggest adding some positive requirements too, to make the test more robust.