-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2081 from hannes-steffenhagen-diffblue/floating_p…
…oint_simplificiation Floating point simplification for goto-analyzer constants domain
- Loading branch information
Showing
19 changed files
with
188 additions
and
35 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
regression/goto-analyzer/constant_propagation_floating_point_div/main.c
This file contains 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,9 @@ | ||
#include <assert.h> | ||
|
||
#define ROUND_F(x) ((int)((x) + 0.5f)) | ||
int eight = ROUND_F(100.0f / 12.0f); | ||
|
||
int main() | ||
{ | ||
assert(eight == 8); | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-analyzer/constant_propagation_floating_point_div/test.desc
This file contains 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,8 @@ | ||
CORE | ||
main.c | ||
--constants --verify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] file main.c line 8 function main, assertion eight == 8: Success$ | ||
-- | ||
^warning: ignoring |
27 changes: 27 additions & 0 deletions
27
regression/goto-analyzer/constant_propagation_nondet_rounding_mode/main.c
This file contains 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,27 @@ | ||
#include <assert.h> | ||
#include <fenv.h> | ||
#include <stdio.h> | ||
|
||
int nondet_rounding_mode(void); | ||
|
||
int main(void) | ||
{ | ||
// slightly bigger than 0.1 | ||
float f = 1.0f / 10.0f; | ||
|
||
// now we don't know what rounding mode we're in | ||
__CPROVER_rounding_mode = nondet_rounding_mode(); | ||
// depending on rounding mode 1.0f/10.0f could | ||
// be greater or smaller than 0.1 | ||
|
||
// definitely not smaller than -0.1 | ||
assert((1.0f / 10.0f) - f < -0.1f); | ||
// might be smaller than 0 | ||
assert((1.0f / 10.0f) - f < 0.0f); | ||
// definitely smaller or equal to 0 | ||
assert((1.0f / 10.0f) - f <= 0.0f); | ||
// might be greater or equal to 0 | ||
assert((1.0f / 10.0f) - f >= 0.0f); | ||
// definitely not greater than 0 | ||
assert((1.0f / 10.0f) - f > 0.0f); | ||
} |
13 changes: 13 additions & 0 deletions
13
regression/goto-analyzer/constant_propagation_nondet_rounding_mode/test.desc
This file contains 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,13 @@ | ||
CORE | ||
main.c | ||
--constants --verify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] file main.c line 18 function main, assertion \(1.0f / 10.0f\) - f < -0.1f: Failure \(if reachable\) | ||
\[main.assertion.2\] file main.c line 20 function main, assertion \(1.0f / 10.0f\) - f < 0.0f: Unknown | ||
\[main.assertion.3\] file main.c line 22 function main, assertion \(1.0f / 10.0f\) - f <= 0.0f: Success | ||
\[main.assertion.4\] file main.c line 24 function main, assertion \(1.0f / 10.0f\) - f >= 0.0f: Unknown | ||
\[main.assertion.5\] file main.c line 26 function main, assertion \(1.0f / 10.0f\) - f > 0.0f: Failure \(if reachable\) | ||
|
||
-- | ||
^warning: ignoring |
12 changes: 12 additions & 0 deletions
12
regression/goto-analyzer/constant_propagation_rounding_mode/main.c
This file contains 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,12 @@ | ||
#include <assert.h> | ||
|
||
int main(void) | ||
{ | ||
__CPROVER_rounding_mode = 0; | ||
float rounded_up = 1.0f / 10.0f; | ||
__CPROVER_rounding_mode = 1; | ||
float rounded_down = 1.0f / 10.0f; | ||
assert(rounded_up - 0.1f >= 0); | ||
assert(rounded_down - 0.1f < 0); | ||
return 0; | ||
} |
9 changes: 9 additions & 0 deletions
9
regression/goto-analyzer/constant_propagation_rounding_mode/test.desc
This file contains 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,9 @@ | ||
CORE | ||
main.c | ||
--constants --verify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] file main.c line 9 function main, assertion rounded_up - 0.1f >= 0: Success | ||
^\[main.assertion.2\] file main.c line 10 function main, assertion rounded_down - 0.1f < 0: Success | ||
-- | ||
^warning: ignoring |
This file contains 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 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 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 |
---|---|---|
|
@@ -26,6 +26,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <ansi-c/c_preprocess.h> | ||
|
||
#include <goto-programs/adjust_float_expressions.h> | ||
#include <goto-programs/initialize_goto_model.h> | ||
#include <goto-programs/instrument_preconditions.h> | ||
#include <goto-programs/goto_convert_functions.h> | ||
|
@@ -49,7 +50,6 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/string_instrumentation.h> | ||
|
||
#include <goto-symex/rewrite_union.h> | ||
#include <goto-symex/adjust_float_expressions.h> | ||
|
||
#include <goto-instrument/reachability_slicer.h> | ||
#include <goto-instrument/full_slicer.h> | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -56,6 +56,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/exit_codes.h> | ||
|
||
#include <cbmc/version.h> | ||
#include <goto-programs/adjust_float_expressions.h> | ||
|
||
#include "taint_analysis.h" | ||
#include "unreachable_instructions.h" | ||
|
@@ -477,6 +478,7 @@ int goto_analyzer_parse_optionst::doit() | |
/// Depending on the command line mode, run one of the analysis tasks | ||
int goto_analyzer_parse_optionst::perform_analysis(const optionst &options) | ||
{ | ||
adjust_float_expressions(goto_model); | ||
if(options.get_bool_option("taint")) | ||
{ | ||
std::string taint_file=cmdline.get_value("taint"); | ||
|
This file contains 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 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 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 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/ieee_float.h> | ||
#include <util/arith_tools.h> | ||
|
||
#include <goto-programs/goto_model.h> | ||
#include "goto_model.h" | ||
|
||
static bool have_to_adjust_float_expressions( | ||
const exprt &expr, | ||
|
This file contains 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 |
---|---|---|
|
@@ -9,8 +9,8 @@ Author: Daniel Kroening, [email protected] | |
/// \file | ||
/// Symbolic Execution | ||
|
||
#ifndef CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H | ||
#define CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H | ||
#ifndef CPROVER_GOTO_PROGRAMS_ADJUST_FLOAT_EXPRESSIONS_H | ||
#define CPROVER_GOTO_PROGRAMS_ADJUST_FLOAT_EXPRESSIONS_H | ||
|
||
#include <goto-programs/goto_functions.h> | ||
|
||
|
@@ -31,4 +31,4 @@ void adjust_float_expressions( | |
const namespacet &ns); | ||
void adjust_float_expressions(goto_modelt &goto_model); | ||
|
||
#endif // CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H | ||
#endif // CPROVER_GOTO_PROGRAMS_ADJUST_FLOAT_EXPRESSIONS_H |
This file contains 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
Oops, something went wrong.