Skip to content

Commit 92ce472

Browse files
committed
works, slower
1 parent 5dffefe commit 92ce472

File tree

1 file changed

+15
-6
lines changed
  • kani-compiler/src/codegen_cprover_gotoc/overrides

1 file changed

+15
-6
lines changed

kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,22 @@ impl<'tcx> GotocHook<'tcx> for PtrRead {
387387
let p = assign_to.unwrap();
388388
let target = target.unwrap();
389389
let src = fargs.remove(0);
390+
391+
let dst_goto =
392+
unwrap_or_return_codegen_unimplemented_stmt!(tcx, tcx.codegen_place(&p)).goto_expr;
393+
let size_expr = dst_goto.typ().sizeof_expr(&tcx.symbol_table);
394+
let memcpy = BuiltinFn::Memcpy
395+
.call(
396+
vec![
397+
dst_goto.address_of().cast_to(Type::void_pointer()),
398+
src.cast_to(Type::void_pointer()),
399+
size_expr,
400+
],
401+
loc,
402+
)
403+
.as_stmt(loc);
390404
Stmt::block(
391-
vec![
392-
unwrap_or_return_codegen_unimplemented_stmt!(tcx, tcx.codegen_place(&p))
393-
.goto_expr
394-
.assign(src.dereference().with_location(loc.clone()), loc.clone()),
395-
Stmt::goto(tcx.current_fn().find_label(&target), loc.clone()),
396-
],
405+
vec![memcpy, Stmt::goto(tcx.current_fn().find_label(&target), loc.clone())],
397406
loc,
398407
)
399408
}

0 commit comments

Comments
 (0)