29
29
30
30
static void get_l1_name (exprt &expr);
31
31
32
- goto_symex_statet::goto_symex_statet (const symex_targett::sourcet &_source)
33
- : goto_statet(_source), symex_target(nullptr ), record_events(true ), dirty()
32
+ goto_symex_statet::goto_symex_statet (
33
+ const symex_targett::sourcet &_source,
34
+ global_name_mapt &global_map)
35
+ : goto_statet(_source),
36
+ symex_target(nullptr ),
37
+ record_events(true ),
38
+ dirty(),
39
+ global_name_map(global_map)
34
40
{
35
41
threads.resize (1 );
36
42
new_frame ();
@@ -183,9 +189,7 @@ void goto_symex_statet::assignment(
183
189
#endif
184
190
185
191
// do the l2 renaming
186
- const auto level2_it =
187
- level2.current_names .emplace (l1_identifier, std::make_pair (lhs, 0 )).first ;
188
- symex_renaming_levelt::increase_counter (level2_it);
192
+ increase_generation (l1_identifier, lhs);
189
193
set_l2_indices (lhs, ns);
190
194
191
195
// in case we happen to be multi-threaded, record the memory access
@@ -442,10 +446,7 @@ bool goto_symex_statet::l2_thread_read_encoding(
442
446
443
447
if (a_s_read.second .empty ())
444
448
{
445
- auto level2_it =
446
- level2.current_names .emplace (l1_identifier, std::make_pair (ssa_l1, 0 ))
447
- .first ;
448
- symex_renaming_levelt::increase_counter (level2_it);
449
+ increase_generation (l1_identifier, ssa_l1);
449
450
a_s_read.first =level2.current_count (l1_identifier);
450
451
}
451
452
@@ -481,10 +482,6 @@ bool goto_symex_statet::l2_thread_read_encoding(
481
482
return true ;
482
483
}
483
484
484
- const auto level2_it =
485
- level2.current_names .emplace (l1_identifier, std::make_pair (ssa_l1, 0 ))
486
- .first ;
487
-
488
485
// No event and no fresh index, but avoid constant propagation
489
486
if (!record_events)
490
487
{
@@ -494,7 +491,8 @@ bool goto_symex_statet::l2_thread_read_encoding(
494
491
}
495
492
496
493
// produce a fresh L2 name
497
- symex_renaming_levelt::increase_counter (level2_it);
494
+ increase_generation (l1_identifier, ssa_l1);
495
+
498
496
set_l2_indices (ssa_l1, ns);
499
497
expr=ssa_l1;
500
498
@@ -506,6 +504,43 @@ bool goto_symex_statet::l2_thread_read_encoding(
506
504
return true ;
507
505
}
508
506
507
+ // / Allocates a fresh L2 name for the given L1 identifier, and makes it the
508
+ // / latest generation on this path.
509
+ void goto_symex_statet::increase_generation (
510
+ const irep_idt l1_identifier,
511
+ const ssa_exprt &lhs)
512
+ {
513
+ auto current_emplace_res =
514
+ level2.current_names .emplace (l1_identifier, std::make_pair (lhs, 0 ));
515
+ auto global_emplace_res =
516
+ global_name_map.emplace (l1_identifier, std::make_pair (lhs, 0 ));
517
+
518
+ global_emplace_res.first ->second .second ++;
519
+ current_emplace_res.first ->second .second =
520
+ global_emplace_res.first ->second .second ;
521
+ }
522
+
523
+ // / Allocates a fresh L2 name for the given L1 identifier, and makes it the
524
+ // / latest generation on this path. Does nothing if there isn't an expression
525
+ // / keyed by the l1 identifier.
526
+ void goto_symex_statet::increase_generation_if_exists (const irep_idt identifier)
527
+ {
528
+ // If we can't find the name in the local scope, don't increase the global
529
+ // even if it exists there.
530
+ auto current_names_iter = level2.current_names .find (identifier);
531
+ if (current_names_iter == level2.current_names .end ())
532
+ return ;
533
+
534
+ // If we have a global store, increment its generation count, then assign
535
+ // that new value to our local scope.
536
+ auto global_names_iter = global_name_map.find (identifier);
537
+ if (global_names_iter != global_name_map.end ())
538
+ {
539
+ global_names_iter->second .second ++;
540
+ current_names_iter->second .second = global_names_iter->second .second ;
541
+ }
542
+ }
543
+
509
544
// / thread encoding
510
545
bool goto_symex_statet::l2_thread_write_encoding (
511
546
const ssa_exprt &expr,
0 commit comments