Skip to content

Update after remove returns #4151

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 2 commits into from
Mar 2, 2019
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
13 changes: 0 additions & 13 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ int goto_instrument_parse_optionst::doit()
if(cmdline.isset("check-call-sequence"))
{
do_remove_returns();

// recalculate numbers, etc.
goto_model.goto_functions.update();

check_call_sequence(goto_model);
return CPROVER_EXIT_SUCCESS;
}
Expand Down Expand Up @@ -1456,9 +1452,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
{
do_indirect_call_and_rtti_removal();

// recalculate numbers, etc.
goto_model.goto_functions.update();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually still needed, seeing as this follows from do_indirect_call_and_rtti_removal, not do_return_removal ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this commit just reverts that earlier change, I don't think it ever was needed.


status() << "Performing a reachability slice" << eom;
if(cmdline.isset("property"))
reachability_slicer(goto_model, cmdline.get_values("property"));
Expand All @@ -1470,9 +1463,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
{
do_indirect_call_and_rtti_removal();

// recalculate numbers, etc.
goto_model.goto_functions.update();

status() << "Performing a function pointer reachability slice" << eom;
function_path_reachability_slicer(
goto_model, cmdline.get_comma_separated_values("fp-reachability-slice"));
Expand All @@ -1484,9 +1474,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
do_indirect_call_and_rtti_removal();
do_remove_returns();

// recalculate numbers, etc.
goto_model.goto_functions.update();

status() << "Performing a full slice" << eom;
if(cmdline.isset("property"))
property_slicer(goto_model, cmdline.get_values("property"));
Expand Down
18 changes: 14 additions & 4 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class remove_returnst
const irep_idt &function_id,
goto_functionst::goto_functiont &function);

void do_function_calls(
bool do_function_calls(
function_is_stubt function_is_stub,
goto_programt &goto_program);

Expand Down Expand Up @@ -142,10 +142,14 @@ void remove_returnst::replace_returns(
/// \param function_is_stub: function (irep_idt -> bool) that determines whether
/// a given function ID is a stub
/// \param goto_program: program to transform
void remove_returnst::do_function_calls(
/// \return True if, and only if, instructions have been inserted. In that case
/// the caller must invoke an appropriate method to update location numbers.
bool remove_returnst::do_function_calls(
function_is_stubt function_is_stub,
goto_programt &goto_program)
{
bool requires_update = false;

Forall_goto_program_instructions(i_it, goto_program)
{
if(i_it->is_function_call())
Expand Down Expand Up @@ -221,13 +225,17 @@ void remove_returnst::do_function_calls(
t_a,
goto_programt::make_dead(*return_value, i_it->source_location));
}

requires_update = true;
}

// update the call
i_it->set_function_call(function_call);
}
}
}

return requires_update;
}

void remove_returnst::operator()(goto_functionst &goto_functions)
Expand All @@ -244,7 +252,8 @@ void remove_returnst::operator()(goto_functionst &goto_functions)
};

replace_returns(it->first, it->second);
do_function_calls(function_is_stub, it->second.body);
if(do_function_calls(function_is_stub, it->second.body))
goto_functions.compute_location_numbers(it->second.body);
}
}

Expand All @@ -261,7 +270,8 @@ void remove_returnst::operator()(
return;

replace_returns(model_function.get_function_id(), goto_function);
do_function_calls(function_is_stub, goto_function.body);
if(do_function_calls(function_is_stub, goto_function.body))
model_function.compute_location_numbers();
}

/// removes returns
Expand Down