Skip to content

Create SSA-level 2 names for individual fields #4545

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
Apr 18, 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
14 changes: 14 additions & 0 deletions regression/cbmc/struct14/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
struct S
{
int x;
};

int main(int argc, char *argv[])
{
struct S s;

if(argc > 3)
s.x = 42;

__CPROVER_assert(s.x == 42, "should fail");
}
11 changes: 11 additions & 0 deletions regression/cbmc/struct14/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c

^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
^warning: ignoring
--
With field-sensitive SSA encoding we need to make sure that each struct member
is treated as non-deterministic unless initialised.
13 changes: 11 additions & 2 deletions src/goto-symex/symex_decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
}

// L2 renaming
std::size_t generation = state.increase_generation(l1_identifier, ssa);
CHECK_RETURN(generation == 1);
const exprt fields = state.field_sensitivity.get_fields(ns, state, ssa);
std::set<symbol_exprt> fields_set;
find_symbols(fields, fields_set);

for(const auto &l1_symbol : fields_set)
{
ssa_exprt field_ssa = to_ssa_expr(l1_symbol);
std::size_t field_generation =
state.increase_generation(l1_symbol.get_identifier(), field_ssa);
CHECK_RETURN(field_generation == 1);
}

const bool record_events=state.record_events;
state.record_events=false;
Expand Down