Skip to content

Commit

Permalink
Fix codegen of skipped functions (rust-lang#1382)
Browse files Browse the repository at this point in the history
We currently skip code generation of a few functions like
ArgumentV1::as_usize(). We generate an unsuppported check instead.
However, we still need to declare the parameters otherwise we end up
with invalid symbol tables where the parameters are missing.

Fixes rust-lang#1379
  • Loading branch information
celinval authored Jul 15, 2022
1 parent 913e273 commit 248fdb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ impl<'tcx> GotocCtx<'tcx> {
tracing::info!("Double codegen of {:?}", old_sym);
} else if self.should_skip_current_fn() {
debug!("Skipping function {}", self.current_fn().readable_name());
self.codegen_function_prelude();
self.codegen_declare_variables();
let body = self.codegen_fatal_error(
PropertyClass::UnsupportedConstruct,
&GotocCtx::unsupported_msg(
Expand Down
8 changes: 8 additions & 0 deletions scripts/std-lib-regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ export RUSTC_LOG=error
export KANIFLAGS="--goto-c --ignore-global-asm"
export RUSTFLAGS="--kani-flags"
export RUSTC="$KANI_DIR/target/debug/kani-compiler"
# Compile rust to iRep
$WRAPPER cargo build --verbose -Z build-std --lib --target $TARGET

# Generate goto-program. This will make sure the representation is well formed.
cd target/${TARGET}/debug/deps
for symtab in *.symtab.json; do
echo "======== File: $symtab"
symtab2gb ${symtab} --out ${symtab}.out
done

echo
echo "Finished Kani codegen for the Rust standard library successfully..."
echo

0 comments on commit 248fdb8

Please sign in to comment.