Skip to content

remove_asm now guarantees that functions called exist #2642

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 1 commit into from
Aug 11, 2018
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
35 changes: 20 additions & 15 deletions src/goto-programs/remove_asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ Date: December 2014
class remove_asmt
{
public:
explicit remove_asmt(symbol_tablet &_symbol_table)
: symbol_table(_symbol_table)
remove_asmt(symbol_tablet &_symbol_table, goto_functionst &_goto_functions)
: symbol_table(_symbol_table), goto_functions(_goto_functions)
{
}

void process_function(goto_functionst::goto_functiont &);
void operator()()
{
for(auto &f : goto_functions.function_map)
process_function(f.second);
}

protected:
symbol_tablet &symbol_table;
goto_functionst &goto_functions;

void process_function(goto_functionst::goto_functiont &);

void process_instruction(
goto_programt::instructiont &instruction,
Expand Down Expand Up @@ -102,6 +109,14 @@ void remove_asmt::gcc_asm_function_call(

symbol_table.add(symbol);
}

if(
goto_functions.function_map.find(function_identifier) ==
goto_functions.function_map.end())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit picking: I'd still like to see using .insert or .emplace here instead of the redundancy of doing .find plus .operator[].

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, sorry, I hadn't seen #2642 (comment). In response to that: I believe insert will always do find + insert-with-hint, which ought to be faster. But indeed it's very minor.

{
auto &f = goto_functions.function_map[function_identifier];
f.type = fkt_type;
}
}

/// removes assembler
Expand Down Expand Up @@ -303,21 +318,11 @@ void remove_asmt::process_function(
remove_skip(goto_function.body);
}

/// removes assembler
void remove_asm(
goto_functionst::goto_functiont &goto_function,
symbol_tablet &symbol_table)
{
remove_asmt rem(symbol_table);
rem.process_function(goto_function);
}

/// removes assembler
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table)
{
remove_asmt rem(symbol_table);
for(auto &f : goto_functions.function_map)
rem.process_function(f.second);
remove_asmt rem(symbol_table, goto_functions);
rem();
}

/// removes assembler
Expand Down
8 changes: 2 additions & 6 deletions src/goto-programs/remove_asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ Date: December 2014
class goto_modelt;
class symbol_tablet;

void remove_asm(
goto_functionst::goto_functiont &goto_function,
symbol_tablet &symbol_table);
void remove_asm(goto_functionst &, symbol_tablet &);

void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table);

void remove_asm(goto_modelt &goto_model);
void remove_asm(goto_modelt &);

#endif // CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H