Skip to content

Commit

Permalink
Merge branch 'main' into smir-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Dec 9, 2023
2 parents e7793cc + 2475dc6 commit 330aa71
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
arguments: --all-features --workspace
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
echo "NEW_REF=${{ github.event.pull_request.head.sha }}" | tee -a "$GITHUB_ENV"
- name: Check out Kani (old variant)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ./old
ref: ${{ env.OLD_REF }}
fetch-depth: 2

- name: Check out Kani (new variant)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ./new
ref: ${{ env.NEW_REF }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cbmc-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
- name: Checkout Kani under "kani"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: kani

Expand All @@ -37,7 +37,7 @@ jobs:
run: cargo build-dev

- name: Checkout CBMC under "cbmc"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: diffblue/cbmc
path: cbmc
Expand All @@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani under "kani"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: kani

Expand All @@ -73,7 +73,7 @@ jobs:
run: cargo build-dev -- --release

- name: Checkout CBMC under "cbmc"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: diffblue/cbmc
path: cbmc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cbmc-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/extra_jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Label PR
id: labeler
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Execute copyright check
run: ./scripts/ci/run-copyright-check.sh
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kani-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: macos-13-xlarge
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/kani.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand All @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand All @@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install benchcomp dependencies
run: |
Expand All @@ -81,7 +81,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand All @@ -102,7 +102,7 @@ jobs:
contents: write
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
crate_version: ${{ steps.bundle.outputs.crate_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
cargo kani setup --use-local-bundle ./${{ matrix.prev_job.bundle }}
- name: Checkout tests
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run tests
# TODO: Customize compiletest to run custom kani. For now, just run a few cargo kani tests.
Expand All @@ -160,7 +160,7 @@ jobs:
KANI_SRC: ./kani_src
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.KANI_SRC }}

Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get version
run: |
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:

- name: Create release
id: create_release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.13.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -258,7 +258,7 @@ jobs:
target: x86_64-unknown-linux-gnu
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand All @@ -271,7 +271,7 @@ jobs:
cargo package -p kani-verifier
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slow-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/toolchain-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Kani
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Kani Dependencies
uses: ./.github/actions/setup
Expand Down
6 changes: 4 additions & 2 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ impl<'tcx> GotocCtx<'tcx> {
}
(Scalar::Ptr(ptr, _size), _) => {
let res_t = self.codegen_ty(ty);
let (alloc_id, offset) = ptr.into_parts();
let (prov, offset) = ptr.into_parts();
let alloc_id = prov.alloc_id();
self.codegen_alloc_pointer(res_t, alloc_id, offset, span)
}
_ => unimplemented!(),
Expand Down Expand Up @@ -650,7 +651,8 @@ impl<'tcx> GotocCtx<'tcx> {
Size::from_bytes(self.symbol_table.machine_model().pointer_width_in_bytes());

let mut next_offset = Size::ZERO;
for &(offset, alloc_id) in alloc.provenance().ptrs().iter() {
for &(offset, prov) in alloc.provenance().ptrs().iter() {
let alloc_id = prov.alloc_id();
if offset > next_offset {
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(
next_offset.bytes_usize()..offset.bytes_usize(),
Expand Down
36 changes: 6 additions & 30 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::kani_middle::coercion::{
};
use crate::unwrap_or_return_codegen_unimplemented;
use cbmc::goto_program::{
arithmetic_overflow_result_type, BinaryOperator, Expr, Location, Stmt, Symbol, Type,
arithmetic_overflow_result_type, BinaryOperator, Expr, Location, Stmt, Type,
ARITH_OVERFLOW_OVERFLOWED_FIELD, ARITH_OVERFLOW_RESULT_FIELD,
};
use cbmc::MachineModel;
Expand Down Expand Up @@ -1165,7 +1165,7 @@ impl<'tcx> GotocCtx<'tcx> {
idx: usize,
) -> Expr {
debug!(?instance, typ=?t, %idx, "codegen_vtable_method_field");
let vtable_field_name = self.vtable_field_name(instance.def_id(), idx);
let vtable_field_name = self.vtable_field_name(idx);
let vtable_type = Type::struct_tag(self.vtable_name(t));
let field_type =
vtable_type.lookup_field_type(vtable_field_name, &self.symbol_table).unwrap();
Expand Down Expand Up @@ -1228,34 +1228,10 @@ impl<'tcx> GotocCtx<'tcx> {
.address_of()
.cast_to(trait_fn_ty)
} else {
// We skip an entire submodule of the standard library, so drop is missing
// for it. Build and insert a function that just calls an unimplemented block
// to maintain soundness.
let drop_sym_name = format!("drop_unimplemented_{}", self.symbol_name(drop_instance));
let pretty_name =
format!("drop_unimplemented<{}>", self.readable_instance_name(drop_instance));
let drop_sym = self.ensure(&drop_sym_name, |ctx, name| {
// Function body
let unimplemented = ctx.codegen_unimplemented_stmt(
format!("drop_in_place for {drop_instance}").as_str(),
Location::none(),
"https://github.com/model-checking/kani/issues/281",
);

// Declare symbol for the single, self parameter
let param_typ = ctx.codegen_ty(trait_ty).to_pointer();
let param_sym = ctx.gen_function_parameter(0, &drop_sym_name, param_typ);

// Build and insert the function itself
Symbol::function(
name,
Type::code(vec![param_sym.to_function_parameter()], Type::empty()),
Some(Stmt::block(vec![unimplemented], Location::none())),
pretty_name,
Location::none(),
)
});
drop_sym.to_expr().address_of().cast_to(trait_fn_ty)
unreachable!(
"Missing drop implementation for {}",
self.readable_instance_name(drop_instance)
);
}
}

Expand Down
15 changes: 3 additions & 12 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use super::PropertyClass;
use crate::codegen_cprover_gotoc::{GotocCtx, VtableCtx};
use crate::unwrap_or_return_codegen_unimplemented_stmt;
use cbmc::goto_program::{Expr, Location, Stmt, Type};
use rustc_hir::def_id::DefId;
use rustc_middle::mir;
use rustc_middle::mir::{
AssertKind, BasicBlock, NonDivergingIntrinsic, Operand, Place, Statement, StatementKind,
Expand Down Expand Up @@ -552,16 +551,9 @@ impl<'tcx> GotocCtx<'tcx> {
return Stmt::goto(self.current_fn().find_label(&target.unwrap()), loc);
}
// Handle a virtual function call via a vtable lookup
InstanceDef::Virtual(def_id, idx) => {
InstanceDef::Virtual(_, idx) => {
let self_ty = self.operand_ty(&args[0]);
self.codegen_virtual_funcall(
self_ty,
def_id,
idx,
destination,
&mut fargs,
loc,
)
self.codegen_virtual_funcall(self_ty, idx, destination, &mut fargs, loc)
}
// Normal, non-virtual function calls
InstanceDef::Item(..)
Expand Down Expand Up @@ -634,13 +626,12 @@ impl<'tcx> GotocCtx<'tcx> {
fn codegen_virtual_funcall(
&mut self,
self_ty: Ty<'tcx>,
def_id: DefId,
idx: usize,
place: &Place<'tcx>,
fargs: &mut [Expr],
loc: Location,
) -> Vec<Stmt> {
let vtable_field_name = self.vtable_field_name(def_id, idx);
let vtable_field_name = self.vtable_field_name(idx);
trace!(?self_ty, ?place, ?vtable_field_name, "codegen_virtual_funcall");
debug!(?fargs, "codegen_virtual_funcall");

Expand Down
11 changes: 5 additions & 6 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ impl<'tcx> GotocCtx<'tcx> {
ty: Ty<'tcx>,
args: ty::GenericArgsRef<'tcx>,
) -> ty::PolyFnSig<'tcx> {
let sig = args.as_coroutine().poly_sig();
let sig = args.as_coroutine().sig();

let bound_vars = self.tcx.mk_bound_variable_kinds_from_iter(
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
);
let bound_vars = self.tcx.mk_bound_variable_kinds_from_iter(iter::once(
ty::BoundVariableKind::Region(ty::BrEnv),
));
let br = ty::BoundRegion {
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BoundRegionKind::BrEnv,
Expand All @@ -349,7 +349,6 @@ impl<'tcx> GotocCtx<'tcx> {
let pin_args = self.tcx.mk_args(&[env_ty.into()]);
let env_ty = Ty::new_adt(self.tcx, pin_adt_ref, pin_args);

let sig = sig.skip_binder();
// The `FnSig` and the `ret_ty` here is for a coroutines main
// `coroutine::resume(...) -> CoroutineState` function in case we
// have an ordinary coroutine, or the `Future::poll(...) -> Poll`
Expand Down Expand Up @@ -482,7 +481,7 @@ impl<'tcx> GotocCtx<'tcx> {
let fn_ptr = fn_ty.to_pointer();

// vtable field name, i.e., 3_vol (idx_method)
let vtable_field_name = self.vtable_field_name(instance.def_id(), idx);
let vtable_field_name = self.vtable_field_name(idx);

DatatypeComponent::field(vtable_field_name, fn_ptr)
}
Expand Down
5 changes: 0 additions & 5 deletions kani-compiler/src/codegen_cprover_gotoc/context/goto_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ impl<'tcx> GotocCtx<'tcx> {
self.gen_stack_variable(c, fname, "var", t, Location::none(), false)
}

// Generate a Symbol Expression representing a function parameter from the MIR
pub fn gen_function_parameter(&mut self, c: u64, fname: &str, t: Type) -> Symbol {
self.gen_stack_variable(c, fname, "var", t, Location::none(), true)
}

/// Given a counter `c` a function name `fname, and a prefix `prefix`, generates a new function local variable
/// It is an error to reuse an existing `c`, `fname` `prefix` tuple.
fn gen_stack_variable(
Expand Down
Loading

0 comments on commit 330aa71

Please sign in to comment.