Skip to content

Commit e672e0d

Browse files
committed
Turn "label: goto label;" or "while(cond);" into assume
This pattern occurs in some SV-COMP benchmarks, but may also appear as busy-wait loops in realistic systems.
1 parent aa99900 commit e672e0d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/goto-symex/symex_goto.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ void goto_symext::symex_goto(statet &state)
6868

6969
if(!forward) // backwards?
7070
{
71+
// is it label: goto label; or while(cond); - popular in SV-COMP
72+
if(goto_target==state.source.pc ||
73+
(instruction.incoming_edges.size()==1 &&
74+
*instruction.incoming_edges.begin()==goto_target))
75+
{
76+
// generate assume(false) or a suitable negation if this
77+
// instruction is a conditional goto
78+
exprt negated_cond;
79+
80+
if(new_guard.is_true())
81+
negated_cond=false_exprt();
82+
else
83+
negated_cond=not_exprt(new_guard);
84+
85+
symex_assume(state, negated_cond);
86+
87+
// next instruction
88+
state.source.pc++;
89+
return;
90+
}
91+
7192
unsigned &unwind=
7293
frame.loop_iterations[goto_programt::loop_id(state.source.pc)].count;
7394
unwind++;

0 commit comments

Comments
 (0)