Skip to content

Commit dc6df01

Browse files
committed
goto-instrument: Remove inline asm before doing various operations
If mutations such as expanding function pointers have been performed, then removing inline asm is reasonable as well.
1 parent e6a9127 commit dc6df01

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,11 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal(
845845
remove_exceptions(goto_model);
846846
status() << "Java instanceof removal" << eom;
847847
remove_instanceof(goto_model);
848+
status() << "Cleaning inline assembler statements" << eom;
849+
remove_asm(goto_model);
850+
851+
goto_model.goto_functions.update();
852+
goto_model.goto_functions.compute_loop_numbers();
848853
}
849854

850855
/// Remove function pointers that can be resolved by analysing const variables
@@ -1220,12 +1225,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
12201225

12211226
if(cmdline.isset("mm"))
12221227
{
1223-
// TODO: move to wmm/weak_mem, and copy goto_functions AFTER some of the
1224-
// modifications. Do the analysis on the copy, after remove_asm, and
1225-
// instrument the original (without remove_asm)
1226-
remove_asm(goto_model);
1227-
goto_model.goto_functions.update();
1228-
12291228
std::string mm=cmdline.get_value("mm");
12301229
memory_modelt model;
12311230

src/goto-programs/remove_asm.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Date: December 2014
2222

2323
#include <assembler/assembler_parser.h>
2424

25+
#include "remove_skip.h"
26+
2527
class remove_asmt
2628
{
2729
public:
@@ -281,20 +283,29 @@ void remove_asmt::process_instruction(
281283
void remove_asmt::process_function(
282284
goto_functionst::goto_functiont &goto_function)
283285
{
286+
bool did_something=false;
287+
284288
Forall_goto_program_instructions(it, goto_function.body)
285289
{
286290
if(it->is_other() && it->code.get_statement()==ID_asm)
287291
{
288292
goto_programt tmp_dest;
289293
process_instruction(*it, tmp_dest);
290294
it->make_skip();
295+
did_something=true;
291296

292297
goto_programt::targett next=it;
293298
next++;
294299

295300
goto_function.body.destructive_insert(next, tmp_dest);
296301
}
297302
}
303+
304+
if(did_something)
305+
{
306+
remove_skip(goto_function.body);
307+
goto_function.body.update();
308+
}
298309
}
299310

300311
/// removes assembler

0 commit comments

Comments
 (0)