File tree 3 files changed +39
-6
lines changed
3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,17 @@ class external_value_set_exprt:public exprt
295
295
}
296
296
}
297
297
298
+ bool can_make_strong_write_to_precise_external_value_set () const
299
+ {
300
+ PRECONDITION (
301
+ get_external_value_set_type () == external_value_set_typet::PRECISE);
302
+ for (const auto &entry : access_path_entries ())
303
+ if (entry.label () == " []" )
304
+ return false ;
305
+
306
+ return true ;
307
+ }
308
+
298
309
static const typet &get_precise_evs_irep_id ()
299
310
{
300
311
static typet precise_evs (" precise_evs" );
Original file line number Diff line number Diff line change @@ -625,7 +625,23 @@ void local_value_sett::assign_rec(
625
625
626
626
auto &lhs_entry=insert_result.first ->second ;
627
627
628
- make_union (lhs_entry.object_map , values_rhs);
628
+ const bool weak_write =
629
+ add_to_sets ||
630
+ !new_ext_set.can_make_strong_write_to_precise_external_value_set ();
631
+
632
+ if (weak_write)
633
+ {
634
+ // / If we are doing a weak write, but this precise EVS did not
635
+ // / already exist in the domain, we also put a copy of the precise
636
+ // / EVS with is_initializer set to true in its value-set to
637
+ // / represent that it might have its original value
638
+ if (insert_result.second )
639
+ insert (lhs_entry.object_map , new_ext_set.as_initializer ());
640
+
641
+ make_union (lhs_entry.object_map , values_rhs);
642
+ }
643
+ else
644
+ lhs_entry.object_map = values_rhs;
629
645
}
630
646
}
631
647
}
Original file line number Diff line number Diff line change @@ -445,10 +445,10 @@ void local_value_set_analysist::transform_function_stub(
445
445
}
446
446
else if (has_prefix (lhs_fieldname.base_name , precise_evs_prefix))
447
447
{
448
+ const external_value_set_exprt &precise_evs =
449
+ to_external_value_set (lhs_fieldname.structured_lhs );
448
450
const external_value_set_exprt::access_path_entriest
449
- &access_path_entries =
450
- to_external_value_set (lhs_fieldname.structured_lhs )
451
- .access_path_entries ();
451
+ &access_path_entries = precise_evs.access_path_entries ();
452
452
const exprt precise_access_path_expr = get_expr_from_root_object (
453
453
lhs_fieldname.base_name .substr (precise_evs_prefix.size ()),
454
454
access_path_entries,
@@ -457,8 +457,14 @@ void local_value_set_analysist::transform_function_stub(
457
457
ns,
458
458
*this );
459
459
460
- // / Weak write - can we do strong writes?
461
- bool add_to_sets=true ;
460
+ std::string objkey = lhs_fieldname.base_name + lhs_fieldname.field_name ;
461
+ auto it = valuesets.values .find (objkey);
462
+ const bool singular = it == valuesets.values .end () ||
463
+ it->second .object_map .read ().size () == 1 ;
464
+ bool add_to_sets =
465
+ !singular ||
466
+ !precise_evs.can_make_strong_write_to_precise_external_value_set ();
467
+
462
468
auto demoted_rhs_values=pre_call_rhs_value_sets.at (assignment.second );
463
469
valuesets.demote_initializers (demoted_rhs_values);
464
470
valuesets.assign_valueset (
You can’t perform that action at this time.
0 commit comments