Skip to content

introduce instructiont::dead_symbol() #5862

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
Feb 24, 2021
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
3 changes: 1 addition & 2 deletions src/analyses/constant_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ void constant_propagator_domaint::transform(
}
else if(from->is_dead())
{
const auto &code_dead = from->get_dead();
values.set_to_top(code_dead.symbol());
values.set_to_top(from->dead_symbol());
}
else if(from->is_function_call())
{
Expand Down
11 changes: 4 additions & 7 deletions src/analyses/custom_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,11 @@ void custom_bitvector_domaint::transform(
break;

case DEAD:
{
const code_deadt &code_dead=to_code_dead(instruction.code);
assign_lhs(code_dead.symbol(), vectorst());
assign_lhs(instruction.dead_symbol(), vectorst());

// is it a pointer?
if(code_dead.symbol().type().id()==ID_pointer)
assign_lhs(dereference_exprt(code_dead.symbol()), vectorst());
}
// is it a pointer?
if(instruction.dead_symbol().type().id() == ID_pointer)
assign_lhs(dereference_exprt(instruction.dead_symbol()), vectorst());
break;

case FUNCTION_CALL:
Expand Down
27 changes: 7 additions & 20 deletions src/analyses/escape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,8 @@ void escape_domaint::transform(
break;

case DEAD:
{
const code_deadt &code_dead=to_code_dead(instruction.code);
aliases.isolate(code_dead.get_identifier());
assign_lhs_cleanup(code_dead.symbol(), std::set<irep_idt>());
}
aliases.isolate(instruction.dead_symbol().get_identifier());
assign_lhs_cleanup(instruction.dead_symbol(), std::set<irep_idt>());
break;

case FUNCTION_CALL:
Expand Down Expand Up @@ -487,14 +484,14 @@ void escape_analysist::instrument(
}
else if(instruction.type == DEAD)
{
const code_deadt &code_dead = to_code_dead(instruction.code);
const auto &dead_symbol = instruction.dead_symbol();

std::set<irep_idt> cleanup_functions1;

const escape_domaint &d = operator[](i_it);

const escape_domaint::cleanup_mapt::const_iterator m_it =
d.cleanup_map.find("&" + id2string(code_dead.get_identifier()));
d.cleanup_map.find("&" + id2string(dead_symbol.get_identifier()));

// does it have a cleanup function for the object?
if(m_it != d.cleanup_map.end())
Expand All @@ -506,22 +503,12 @@ void escape_analysist::instrument(

std::set<irep_idt> cleanup_functions2;

d.check_lhs(code_dead.symbol(), cleanup_functions2);
d.check_lhs(dead_symbol, cleanup_functions2);

insert_cleanup(
gf_entry.second,
i_it,
code_dead.symbol(),
cleanup_functions1,
true,
ns);
gf_entry.second, i_it, dead_symbol, cleanup_functions1, true, ns);
insert_cleanup(
gf_entry.second,
i_it,
code_dead.symbol(),
cleanup_functions2,
false,
ns);
gf_entry.second, i_it, dead_symbol, cleanup_functions2, false, ns);

for(const auto &c : cleanup_functions1)
{
Expand Down
5 changes: 1 addition & 4 deletions src/analyses/global_may_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,8 @@ void global_may_alias_domaint::transform(
}

case DEAD:
{
const code_deadt &code_dead = to_code_dead(instruction.code);
aliases.isolate(code_dead.get_identifier());
aliases.isolate(instruction.dead_symbol().get_identifier());
break;
}

case FUNCTION_CALL: // Probably safe
case GOTO: // Ignoring the guard is a valid over-approximation
Expand Down
5 changes: 1 addition & 4 deletions src/analyses/goto_rw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,7 @@ void goto_rw(

case DEAD:
rw_set.get_objects_rec(
function,
target,
rw_range_sett::get_modet::LHS_W,
to_code_dead(target->code).symbol());
function, target, rw_range_sett::get_modet::LHS_W, target->dead_symbol());
break;

case DECL:
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/interval_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void interval_domaint::transform(
break;

case DEAD:
havoc_rec(to_code_dead(instruction.code).symbol());
havoc_rec(instruction.dead_symbol());
break;

case ASSIGN:
Expand Down
5 changes: 1 addition & 4 deletions src/analyses/local_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,12 @@ void local_bitvector_analysist::build()
}

case DEAD:
{
const code_deadt &code_dead = to_code_dead(instruction.code);
assign_lhs(
code_dead.symbol(),
instruction.dead_symbol(),
exprt(ID_uninitialized),
loc_info_src,
loc_info_dest);
break;
}

case FUNCTION_CALL:
{
Expand Down
6 changes: 2 additions & 4 deletions src/analyses/local_may_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,9 @@ void local_may_aliast::build(const goto_functiont &goto_function)
}

case DEAD:
{
const code_deadt &code_dead = to_code_dead(instruction.code);
assign_lhs(code_dead.symbol(), nil_exprt(), loc_info_src, loc_info_dest);
assign_lhs(
instruction.dead_symbol(), nil_exprt(), loc_info_src, loc_info_dest);
break;
}

case FUNCTION_CALL:
{
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/reaching_definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void rd_range_domaint::transform_dead(
const namespacet &,
locationt from)
{
const irep_idt &identifier = to_code_dead(from->code).get_identifier();
const irep_idt &identifier = from->dead_symbol().get_identifier();

valuest::iterator entry=values.find(identifier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,10 @@ void variable_sensitivity_domaint::transform(
break;

case DEAD:
{
// Remove symbol from map, the only time this occurs now (keep TOP.)
// It should be the case that DEAD only provides symbols for deletion.
const exprt &expr = to_code_dead(instruction.code).symbol();
if(expr.id() == ID_symbol)
{
abstract_state.erase(to_symbol_expr(expr));
}
}
break;
abstract_state.erase(instruction.dead_symbol());
break;

case ASSIGN:
{
Expand Down
2 changes: 1 addition & 1 deletion src/goto-diff/change_impact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void full_slicert::operator()(
}
else if(instruction->is_dead())
{
const auto &s=to_code_dead(instruction->code).symbol();
const auto &s=instruction->dead_symbol();
decl_dead[s.get_identifier()].push(instruction_node_index);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/full_slicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void full_slicert::operator()(
}
else if(instruction->is_dead())
{
const auto &s = to_code_dead(instruction->code).symbol();
const auto &s = instruction->dead_symbol();
decl_dead[s.get_identifier()].push(instruction_node_index);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/goto_program2code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void goto_program2codet::build_dead_map()
{
if(instruction.is_dead())
{
dead_map[instruction.get_dead().get_identifier()] =
dead_map[instruction.dead_symbol().get_identifier()] =
instruction.location_number;
}
}
Expand Down
14 changes: 5 additions & 9 deletions src/goto-programs/goto_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,9 @@ void goto_programt::instructiont::validate(
source_location);
DATA_CHECK_WITH_DIAGNOSTICS(
vm,
!ns.lookup(get_dead().get_identifier(), table_symbol),
!ns.lookup(dead_symbol().get_identifier(), table_symbol),
"removed symbols should be known",
id2string(get_dead().get_identifier()),
id2string(dead_symbol().get_identifier()),
source_location);
break;
case FUNCTION_CALL:
Expand Down Expand Up @@ -966,13 +966,9 @@ void goto_programt::instructiont::transform(

case DEAD:
{
auto new_symbol = f(get_dead().symbol());
auto new_symbol = f(dead_symbol());
if(new_symbol.has_value())
{
auto new_dead = get_dead();
new_dead.symbol() = to_symbol_expr(*new_symbol);
set_dead(new_dead);
}
dead_symbol() = to_symbol_expr(*new_symbol);
}
break;

Expand Down Expand Up @@ -1050,7 +1046,7 @@ void goto_programt::instructiont::apply(
break;

case DEAD:
f(get_dead().symbol());
f(dead_symbol());
break;

case FUNCTION_CALL:
Expand Down
17 changes: 17 additions & 0 deletions src/goto-programs/goto_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
#include <sstream>
#include <string>

#include <util/deprecate.h>
#include <util/invariant.h>
#include <util/namespace.h>
#include <util/source_location.h>
Expand Down Expand Up @@ -218,13 +219,29 @@ class goto_programt
}

/// Get the dead statement for DEAD
DEPRECATED(SINCE(2021, 2, 24, "Use dead_symbol instead"))
const code_deadt &get_dead() const
{
PRECONDITION(is_dead());
return to_code_dead(code);
}

/// Get the symbol for DEAD
const symbol_exprt &dead_symbol() const
{
PRECONDITION(is_dead());
return to_code_dead(code).symbol();
}

/// Get the symbol for DEAD
symbol_exprt &dead_symbol()
{
PRECONDITION(is_dead());
return to_code_dead(code).symbol();
}

/// Set the dead statement for DEAD
DEPRECATED(SINCE(2021, 2, 24, "Use dead_symbol instead"))
void set_dead(code_deadt c)
{
PRECONDITION(is_dead());
Expand Down
4 changes: 1 addition & 3 deletions src/goto-symex/symex_dead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ Author: Daniel Kroening, [email protected]
void goto_symext::symex_dead(statet &state)
{
const goto_programt::instructiont &instruction=*state.source.pc;

const code_deadt &code = instruction.get_dead();
symex_dead(state, code.symbol());
symex_dead(state, instruction.dead_symbol());
}

void goto_symext::symex_dead(statet &state, const symbol_exprt &symbol_expr)
Expand Down