@@ -410,100 +410,101 @@ void goto_symext::phi_function(
410
410
const irep_idt l1_identifier = ssa.get_identifier ();
411
411
const irep_idt &obj_identifier = ssa.get_object_name ();
412
412
413
- if (obj_identifier==guard_identifier)
414
- return ; // just a guard, don't bother
413
+ if (obj_identifier==guard_identifier)
414
+ return ; // just a guard, don't bother
415
415
416
- if (goto_state.level2_current_count (l1_identifier)==
417
- dest_state.level2 .current_count (l1_identifier))
418
- return ; // not at all changed
416
+ if (goto_state.level2_current_count (l1_identifier)==
417
+ dest_state.level2 .current_count (l1_identifier))
418
+ return ; // not at all changed
419
419
420
- // changed!
420
+ // changed!
421
421
422
- // shared variables are renamed on every access anyway, we don't need to
423
- // merge anything
424
- const symbolt &symbol=ns.lookup (obj_identifier);
422
+ // shared variables are renamed on every access anyway, we don't need to
423
+ // merge anything
424
+ const symbolt &symbol=ns.lookup (obj_identifier);
425
425
426
- // shared?
427
- if (
428
- dest_state.atomic_section_id == 0 && dest_state.threads .size () >= 2 &&
429
- (symbol.is_shared () || (dest_state.dirty )(symbol.name )))
430
- return ; // no phi nodes for shared stuff
431
-
432
- // don't merge (thread-)locals across different threads, which
433
- // may have been introduced by symex_start_thread (and will
434
- // only later be removed from level2.current_names by pop_frame
435
- // once the thread is executed)
436
- if (
437
- !ssa.get_level_0 ().empty () &&
438
- ssa.get_level_0 () != std::to_string (dest_state.source .thread_nr ))
439
- return ;
426
+ // shared?
427
+ if (
428
+ dest_state.atomic_section_id == 0 && dest_state.threads .size () >= 2 &&
429
+ (symbol.is_shared () || (dest_state.dirty )(symbol.name )))
430
+ return ; // no phi nodes for shared stuff
440
431
441
- exprt goto_state_rhs = ssa, dest_state_rhs = ssa;
432
+ // don't merge (thread-)locals across different threads, which
433
+ // may have been introduced by symex_start_thread (and will
434
+ // only later be removed from level2.current_names by pop_frame
435
+ // once the thread is executed)
436
+ if (
437
+ !ssa.get_level_0 ().empty () &&
438
+ ssa.get_level_0 () != std::to_string (dest_state.source .thread_nr ))
439
+ return ;
442
440
443
- {
444
- const auto p_it = goto_state.propagation .find (l1_identifier);
441
+ exprt goto_state_rhs = ssa, dest_state_rhs = ssa;
445
442
446
- if (p_it != goto_state.propagation .end ())
447
- goto_state_rhs=p_it->second ;
448
- else
449
- to_ssa_expr (goto_state_rhs).set_level_2 (
450
- goto_state.level2_current_count (l1_identifier));
451
- }
443
+ {
444
+ const auto p_it = goto_state.propagation .find (l1_identifier);
452
445
453
- {
454
- const auto p_it = dest_state.propagation .find (l1_identifier);
446
+ if (p_it != goto_state.propagation .end ())
447
+ goto_state_rhs=p_it->second ;
448
+ else
449
+ to_ssa_expr (goto_state_rhs).set_level_2 (
450
+ goto_state.level2_current_count (l1_identifier));
451
+ }
455
452
456
- if (p_it != dest_state.propagation .end ())
457
- dest_state_rhs=p_it->second ;
453
+ {
454
+ const auto p_it = dest_state.propagation .find (l1_identifier);
455
+
456
+ if (p_it != dest_state.propagation .end ())
457
+ dest_state_rhs=p_it->second ;
458
+ else
459
+ to_ssa_expr (dest_state_rhs).set_level_2 (
460
+ dest_state.level2 .current_count (l1_identifier));
461
+ }
462
+
463
+ exprt rhs;
464
+
465
+ // Don't add a conditional to the assignment when:
466
+ // 1. Either guard is false, so we can't follow that branch.
467
+ // 2. Either identifier is of generation zero, and so hasn't been
468
+ // initialized and therefor an invalid target.
469
+ if (dest_state.guard .is_false ())
470
+ rhs=goto_state_rhs;
471
+ else if (goto_state.guard .is_false ())
472
+ rhs=dest_state_rhs;
473
+ else if (goto_state.level2_current_count (l1_identifier) == 0 )
474
+ {
475
+ rhs = dest_state_rhs;
476
+ }
477
+ else if (dest_state.level2 .current_count (l1_identifier) == 0 )
478
+ {
479
+ rhs = goto_state_rhs;
480
+ }
458
481
else
459
- to_ssa_expr (dest_state_rhs).set_level_2 (
460
- dest_state.level2 .current_count (l1_identifier));
461
- }
482
+ {
483
+ rhs=if_exprt (diff_guard.as_expr (), goto_state_rhs, dest_state_rhs);
484
+ do_simplify (rhs);
485
+ }
462
486
463
- exprt rhs;
464
-
465
- // Don't add a conditional to the assignment when:
466
- // 1. Either guard is false, so we can't follow that branch.
467
- // 2. Either identifier is of generation zero, and so hasn't been
468
- // initialized and therefor an invalid target.
469
- if (dest_state.guard .is_false ())
470
- rhs=goto_state_rhs;
471
- else if (goto_state.guard .is_false ())
472
- rhs=dest_state_rhs;
473
- else if (goto_state.level2_current_count (l1_identifier) == 0 )
474
- {
475
- rhs = dest_state_rhs;
476
- }
477
- else if (dest_state.level2 .current_count (l1_identifier) == 0 )
478
- {
479
- rhs = goto_state_rhs;
480
- }
481
- else
482
- {
483
- rhs=if_exprt (diff_guard.as_expr (), goto_state_rhs, dest_state_rhs);
484
- do_simplify (rhs);
485
- }
487
+ ssa_exprt new_lhs = ssa;
488
+ const bool record_events=dest_state.record_events ;
489
+ dest_state.record_events =false ;
490
+ dest_state.assignment (new_lhs, rhs, ns, true , true );
491
+ dest_state.record_events =record_events;
486
492
487
- ssa_exprt new_lhs = ssa;
488
- const bool record_events=dest_state.record_events ;
489
- dest_state.record_events =false ;
490
- dest_state.assignment (new_lhs, rhs, ns, true , true );
491
- dest_state.record_events =record_events;
492
-
493
- log.conditional_output (
494
- log.debug (),
495
- [this , &new_lhs](messaget::mstreamt &mstream) {
496
- mstream << " Assignment to " << new_lhs.get_identifier ()
497
- << " [" << pointer_offset_bits (new_lhs.type (), ns).value_or (0 ) << " bits]"
498
- << messaget::eom;
499
- });
500
-
501
- target.assignment (
502
- true_exprt (),
503
- new_lhs, new_lhs, new_lhs.get_original_expr (),
504
- rhs,
505
- dest_state.source ,
506
- symex_targett::assignment_typet::PHI);
493
+ log.conditional_output (
494
+ log.debug (),
495
+ [this , &new_lhs](messaget::mstreamt &mstream) {
496
+ mstream << " Assignment to " << new_lhs.get_identifier ()
497
+ << " [" << pointer_offset_bits (new_lhs.type (), ns).value_or (0 )
498
+ << " bits]"
499
+ << messaget::eom;
500
+ });
501
+
502
+ target.assignment (
503
+ true_exprt (),
504
+ new_lhs, new_lhs, new_lhs.get_original_expr (),
505
+ rhs,
506
+ dest_state.source ,
507
+ symex_targett::assignment_typet::PHI);
507
508
});
508
509
}
509
510
0 commit comments