Skip to content

Commit ee11014

Browse files
authored
Merge pull request #4151 from tautschnig/update-after-remove-returns
Update after remove returns
2 parents d1d0bc2 + cdab267 commit ee11014

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,6 @@ int goto_instrument_parse_optionst::doit()
448448
if(cmdline.isset("check-call-sequence"))
449449
{
450450
do_remove_returns();
451-
452-
// recalculate numbers, etc.
453-
goto_model.goto_functions.update();
454-
455451
check_call_sequence(goto_model);
456452
return CPROVER_EXIT_SUCCESS;
457453
}
@@ -1456,9 +1452,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14561452
{
14571453
do_indirect_call_and_rtti_removal();
14581454

1459-
// recalculate numbers, etc.
1460-
goto_model.goto_functions.update();
1461-
14621455
status() << "Performing a reachability slice" << eom;
14631456
if(cmdline.isset("property"))
14641457
reachability_slicer(goto_model, cmdline.get_values("property"));
@@ -1470,9 +1463,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14701463
{
14711464
do_indirect_call_and_rtti_removal();
14721465

1473-
// recalculate numbers, etc.
1474-
goto_model.goto_functions.update();
1475-
14761466
status() << "Performing a function pointer reachability slice" << eom;
14771467
function_path_reachability_slicer(
14781468
goto_model, cmdline.get_comma_separated_values("fp-reachability-slice"));
@@ -1484,9 +1474,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14841474
do_indirect_call_and_rtti_removal();
14851475
do_remove_returns();
14861476

1487-
// recalculate numbers, etc.
1488-
goto_model.goto_functions.update();
1489-
14901477
status() << "Performing a full slice" << eom;
14911478
if(cmdline.isset("property"))
14921479
property_slicer(goto_model, cmdline.get_values("property"));

src/goto-programs/remove_returns.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class remove_returnst
4444
const irep_idt &function_id,
4545
goto_functionst::goto_functiont &function);
4646

47-
void do_function_calls(
47+
bool do_function_calls(
4848
function_is_stubt function_is_stub,
4949
goto_programt &goto_program);
5050

@@ -142,10 +142,14 @@ void remove_returnst::replace_returns(
142142
/// \param function_is_stub: function (irep_idt -> bool) that determines whether
143143
/// a given function ID is a stub
144144
/// \param goto_program: program to transform
145-
void remove_returnst::do_function_calls(
145+
/// \return True if, and only if, instructions have been inserted. In that case
146+
/// the caller must invoke an appropriate method to update location numbers.
147+
bool remove_returnst::do_function_calls(
146148
function_is_stubt function_is_stub,
147149
goto_programt &goto_program)
148150
{
151+
bool requires_update = false;
152+
149153
Forall_goto_program_instructions(i_it, goto_program)
150154
{
151155
if(i_it->is_function_call())
@@ -221,13 +225,17 @@ void remove_returnst::do_function_calls(
221225
t_a,
222226
goto_programt::make_dead(*return_value, i_it->source_location));
223227
}
228+
229+
requires_update = true;
224230
}
225231

226232
// update the call
227233
i_it->set_function_call(function_call);
228234
}
229235
}
230236
}
237+
238+
return requires_update;
231239
}
232240

233241
void remove_returnst::operator()(goto_functionst &goto_functions)
@@ -244,7 +252,8 @@ void remove_returnst::operator()(goto_functionst &goto_functions)
244252
};
245253

246254
replace_returns(it->first, it->second);
247-
do_function_calls(function_is_stub, it->second.body);
255+
if(do_function_calls(function_is_stub, it->second.body))
256+
goto_functions.compute_location_numbers(it->second.body);
248257
}
249258
}
250259

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

263272
replace_returns(model_function.get_function_id(), goto_function);
264-
do_function_calls(function_is_stub, goto_function.body);
273+
if(do_function_calls(function_is_stub, goto_function.body))
274+
model_function.compute_location_numbers();
265275
}
266276

267277
/// removes returns

0 commit comments

Comments
 (0)