Skip to content

Value set: lift offset from numeric constants to expressions #8647

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 4 commits into from
Jun 24, 2025
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
1 change: 1 addition & 0 deletions regression/cbmc/trace-values/unbounded_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ int main(int argc, char *argv[])
unsigned long size;
__CPROVER_assume(size < 100 && size > 10);
int *array = malloc(size * sizeof(int));
__CPROVER_assume(array);
array[size - 1] = 42;
int fixed_array[] = {1, 2};
__CPROVER_array_replace(array, fixed_array);
Expand Down
28 changes: 1 addition & 27 deletions src/goto-symex/goto_symex_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ Author: Daniel Kroening, [email protected]
#include "simplify_expr_with_value_set.h"
#include "symex_target_equation.h"

static void get_l1_name(exprt &expr);

goto_symex_statet::goto_symex_statet(
const symex_targett::sourcet &_source,
std::size_t max_field_sensitive_array_size,
Expand Down Expand Up @@ -129,20 +127,7 @@ renamedt<ssa_exprt, L2> goto_symex_statet::assignment(
else
propagation.erase_if_exists(l1_identifier);

{
// update value sets
exprt l1_rhs(rhs);
get_l1_name(l1_rhs);

const ssa_exprt l1_lhs = remove_level_2(lhs);
if(run_validation_checks)
{
DATA_INVARIANT(!check_renaming_l1(l1_lhs), "lhs renaming failed on l1");
DATA_INVARIANT(!check_renaming_l1(l1_rhs), "rhs renaming failed on l1");
}

value_set.assign(l1_lhs, l1_rhs, ns, rhs_is_simplified, is_shared);
}
value_set.assign(lhs, rhs, ns, rhs_is_simplified, is_shared);

#ifdef DEBUG
std::cout << "Assigning " << l1_identifier << '\n';
Expand Down Expand Up @@ -789,17 +774,6 @@ void goto_symex_statet::rename(
l1_type_entry.first->second=type;
}

static void get_l1_name(exprt &expr)
{
// do not reset the type !

if(is_ssa_expr(expr))
to_ssa_expr(expr).remove_level_2();
else
Forall_operands(it, expr)
get_l1_name(*it);
}

/// Dumps the current state of symex, printing the function name and location
/// number for each stack frame in the currently active thread.
/// This is for use from the debugger or in debug code; please don't delete it
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/shadow_memory_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ normalize(const object_descriptor_exprt &expr, const namespacet &ns)
{
return expr;
}
if(expr.offset().id() == ID_unknown)
if(!expr.offset().is_constant())
Copy link
Collaborator

@remi-delmas-3000 remi-delmas-3000 Jun 18, 2025

Choose a reason for hiding this comment

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

Can we get a high level description of what is the normal form we're trying to reach ?

Copy link
Member

Choose a reason for hiding this comment

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

To root object + constant offset, as object can be an arbitrary access path into the object. Pointer equality checks become trivial then - maybe simplify_expr has become good enough in the meanwhile.
Anyways, this seems orthogonal to this PR.

{
return expr;
}
Expand Down
Loading
Loading