Skip to content

Perform remove_returns pass before constant_propagator #7105

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 3 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>
int ab, bc;
int f(int x)
{
ab = 1 + 1 + 1 + 1;
bc = ab + x;
return ab + bc;
}
int main()
{
int a;
a = -4;
int b;
b = nondet();
a = f(a);
assert(!(0 <= a && a < 5 && 0 <= b && b < 5));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CORE
main.c
--constant-propagator
^EXIT=10$
^SIGNAL=0$
Removing returns
VERIFICATION FAILED
ASSIGN main\:\:1\:\:a \:\= 4
ASSERT ¬\(main::1::b ≥ 0\) ∨ main::1::b ≥ 5
--
^warning: ignoring
ASSERT true
--
This tests that constants are propagated through function calls, correctly
taking into account the return value. Constant propagation should result in
simplifying away the conditions in the assertion on `a` but not the conditions
on `b`.
1 change: 1 addition & 0 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
if(cmdline.isset("constant-propagator"))
{
do_indirect_call_and_rtti_removal();
do_remove_returns();

log.status() << "Propagating Constants" << messaget::eom;

Expand Down