Skip to content

Commit 23330c3

Browse files
committed
Move snapshots after modifications
1 parent 8e37a61 commit 23330c3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

verify/vir/src/sst_to_air.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,6 @@ fn stm_to_stmts(ctx: &Ctx, state: &mut State, stm: &Stm) -> Vec<Stmt> {
297297
}
298298
}
299299
Some(Dest { var, mutable }) => {
300-
if ctx.debug {
301-
// Add a snapshot before we modify the destination
302-
let name = format!("{}_{:?}", var.clone(), stm.span.raw_span); // TODO: Use line number?
303-
let snapshot = Rc::new(StmtX::Snapshot(Rc::new(name)));
304-
stmts.push(snapshot);
305-
}
306300
let x = suffix_local_id(&var.clone());
307301
let mut overwrite = false;
308302
for arg in args.iter() {
@@ -326,6 +320,12 @@ fn stm_to_stmts(ctx: &Ctx, state: &mut State, stm: &Stm) -> Vec<Stmt> {
326320
let havoc = StmtX::Havoc(x.clone());
327321
stmts.push(Rc::new(havoc));
328322
}
323+
if ctx.debug {
324+
// Add a snapshot after we modify the destination
325+
let name = format!("{}_{:?}", var.clone(), stm.span.raw_span); // TODO: Use line number?
326+
let snapshot = Rc::new(StmtX::Snapshot(Rc::new(name)));
327+
stmts.push(snapshot);
328+
}
329329
}
330330
}
331331
if func.x.ensure.len() > 0 {
@@ -355,8 +355,9 @@ fn stm_to_stmts(ctx: &Ctx, state: &mut State, stm: &Stm) -> Vec<Stmt> {
355355
ExpX::Var(ident) => ident,
356356
_ => panic!("unexpected lhs {:?} in assign", lhs),
357357
};
358+
stmts.push(Rc::new(StmtX::Assign(suffix_local_id(&ident), exp_to_expr(ctx, rhs))));
358359
if ctx.debug {
359-
// Add a snapshot before we modify the destination
360+
// Add a snapshot after we modify the destination
360361
// TODO: Factor out the span reasoning, so we don't pull rustc into this part of
361362
// the code base?
362363
let span: &rustc_span::Span = (*stm.span.raw_span)
@@ -367,7 +368,6 @@ fn stm_to_stmts(ctx: &Ctx, state: &mut State, stm: &Stm) -> Vec<Stmt> {
367368
let snapshot = Rc::new(StmtX::Snapshot(Rc::new(name)));
368369
stmts.push(snapshot);
369370
}
370-
stmts.push(Rc::new(StmtX::Assign(suffix_local_id(&ident), exp_to_expr(ctx, rhs))));
371371
stmts
372372
}
373373
StmX::If(cond, lhs, rhs) => {

0 commit comments

Comments
 (0)