@@ -419,8 +419,6 @@ void goto_convertt::convert(
419
419
const codet &code,
420
420
goto_programt &dest)
421
421
{
422
- std::size_t old_tmp_symbols_size=tmp_symbols.size ();
423
-
424
422
const irep_idt &statement=code.get_statement ();
425
423
426
424
if (statement==ID_block)
@@ -542,19 +540,6 @@ void goto_convertt::convert(
542
540
else
543
541
copy (code, OTHER, dest);
544
542
545
- // We only need to kill the temporaries if control
546
- // can get to the end of the block.
547
- #if 0
548
- if(!dest.empty() &&
549
- dest.instructions.back().is_goto() &&
550
- dest.instructions.back().guard.is_true())
551
- tmp_symbols.resize(old_tmp_symbols_size);
552
- else
553
- kill_tmp_symbols(old_tmp_symbols_size, dest);
554
- #else
555
- kill_tmp_symbols (old_tmp_symbols_size, dest);
556
- #endif
557
-
558
543
// make sure dest is never empty
559
544
if (dest.instructions .empty ())
560
545
{
@@ -566,31 +551,6 @@ void goto_convertt::convert(
566
551
567
552
/* ******************************************************************\
568
553
569
- Function: goto_convertt::kill_tmp_symbols
570
-
571
- Inputs:
572
-
573
- Outputs:
574
-
575
- Purpose:
576
-
577
- \*******************************************************************/
578
-
579
- void goto_convertt::kill_tmp_symbols (
580
- std::size_t final_size,
581
- goto_programt &dest)
582
- {
583
- while (tmp_symbols.size ()>final_size)
584
- {
585
- symbol_exprt symbol=tmp_symbols.back ();
586
- tmp_symbols.pop_back ();
587
- dest.add_instruction (DEAD);
588
- dest.instructions .back ().code =code_deadt (symbol);
589
- }
590
- }
591
-
592
- /* ******************************************************************\
593
-
594
554
Function: goto_convertt::convert_block
595
555
596
556
Inputs:
@@ -617,7 +577,8 @@ void goto_convertt::convert_block(
617
577
convert (b_code, dest);
618
578
}
619
579
620
- // see if we need to do any destructors
580
+ // see if we need to do any destructors -- may have been processed
581
+ // in a prior break/continue/return already, don't create dead code
621
582
if (!dest.empty () &&
622
583
dest.instructions .back ().is_goto () &&
623
584
dest.instructions .back ().guard .is_true ())
@@ -2564,11 +2525,10 @@ symbolt &goto_convertt::new_tmp_symbol(
2564
2525
new_symbol.location =source_location;
2565
2526
} while (symbol_table.move (new_symbol, symbol_ptr));
2566
2527
2567
- tmp_symbols.push_back (symbol_ptr->symbol_expr ());
2568
-
2569
- goto_programt::targett t=dest.add_instruction (DECL);
2570
- t->code =code_declt (symbol_ptr->symbol_expr ());
2571
- t->source_location =source_location;
2528
+ code_declt decl;
2529
+ decl.symbol ()=symbol_ptr->symbol_expr ();
2530
+ decl.add_source_location ()=source_location;
2531
+ convert_decl (decl, dest);
2572
2532
2573
2533
return *symbol_ptr;
2574
2534
}
0 commit comments