Skip to content

Commit

Permalink
Merge branch 'main' into docs-safety-const-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Aug 2, 2024
2 parents 19514e9 + 4a92557 commit 07ea1c8
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
name: Cargo Audit
on:
pull_request:
merge_group:
push:
# Run on changes to branches but not tags.
branches:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: Kani Format Check
on:
pull_request:
merge_group:
push:
# Not just any push, as that includes tags.
# We don't want to re-trigger this workflow when tagging an existing commit.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kani.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: Kani CI
on:
pull_request:
merge_group:
push:
# Not just any push, as that includes tags.
# We don't want to re-trigger this workflow when tagging an existing commit.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
name: Release Bundle
on:
pull_request:
merge_group:
push:
branches:
- 'main'
Expand Down
12 changes: 6 additions & 6 deletions docs/src/rust-feature-support/intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ fdiv_fast | Partial | [#809](https://github.com/model-checking/kani/issues/809)
float_to_int_unchecked | No | |
floorf32 | Yes | |
floorf64 | Yes | |
fmaf32 | No | |
fmaf64 | No | |
fmaf32 | Partial | Results are overapproximated |
fmaf64 | Partial | Results are overapproximated |
fmul_fast | Partial | [#809](https://github.com/model-checking/kani/issues/809) |
forget | Yes | |
frem_fast | No | |
Expand All @@ -187,8 +187,8 @@ nontemporal_store | No | |
offset | Partial | Doesn't check [all UB conditions](https://doc.rust-lang.org/std/primitive.pointer.html#safety-2) |
powf32 | Partial | Results are overapproximated |
powf64 | Partial | Results are overapproximated |
powif32 | No | |
powif64 | No | |
powif32 | Partial | Results are overapproximated |
powif64 | Partial | Results are overapproximated |
pref_align_of | Yes | |
prefetch_read_data | No | |
prefetch_read_instruction | No | |
Expand All @@ -211,8 +211,8 @@ sinf32 | Partial | Results are overapproximated; [this test](https://github.com/
sinf64 | Partial | Results are overapproximated; [this test](https://github.com/model-checking/kani/blob/main/tests/kani/Intrinsics/Math/Trigonometry/sinf64.rs) explains how |
size_of | Yes | |
size_of_val | Yes | |
sqrtf32 | No | |
sqrtf64 | No | |
sqrtf32 | Partial | Results are overapproximated |
sqrtf64 | Partial | Results are overapproximated |
sub_with_overflow | Yes | |
transmute | Partial | Doesn't check [all UB conditions](https://doc.rust-lang.org/nomicon/transmutes.html) |
truncf32 | Yes | |
Expand Down
12 changes: 6 additions & 6 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ impl<'tcx> GotocCtx<'tcx> {
}
"floorf32" => codegen_simple_intrinsic!(Floorf),
"floorf64" => codegen_simple_intrinsic!(Floor),
"fmaf32" => unstable_codegen!(codegen_simple_intrinsic!(Fmaf)),
"fmaf64" => unstable_codegen!(codegen_simple_intrinsic!(Fma)),
"fmaf32" => codegen_simple_intrinsic!(Fmaf),
"fmaf64" => codegen_simple_intrinsic!(Fma),
"fmul_fast" => {
let fargs_clone = fargs.clone();
let binop_stmt = codegen_intrinsic_binop!(mul);
Expand Down Expand Up @@ -490,8 +490,8 @@ impl<'tcx> GotocCtx<'tcx> {
),
"powf32" => codegen_simple_intrinsic!(Powf),
"powf64" => codegen_simple_intrinsic!(Pow),
"powif32" => unstable_codegen!(codegen_simple_intrinsic!(Powif)),
"powif64" => unstable_codegen!(codegen_simple_intrinsic!(Powi)),
"powif32" => codegen_simple_intrinsic!(Powif),
"powif64" => codegen_simple_intrinsic!(Powi),
"pref_align_of" => codegen_intrinsic_const!(),
"ptr_guaranteed_cmp" => self.codegen_ptr_guaranteed_cmp(fargs, place, loc),
"ptr_offset_from" => self.codegen_ptr_offset_from(fargs, place, loc),
Expand Down Expand Up @@ -570,8 +570,8 @@ impl<'tcx> GotocCtx<'tcx> {
"simd_xor" => codegen_intrinsic_binop!(bitxor),
"size_of" => unreachable!(),
"size_of_val" => codegen_size_align!(size),
"sqrtf32" => unstable_codegen!(codegen_simple_intrinsic!(Sqrtf)),
"sqrtf64" => unstable_codegen!(codegen_simple_intrinsic!(Sqrt)),
"sqrtf32" => codegen_simple_intrinsic!(Sqrtf),
"sqrtf64" => codegen_simple_intrinsic!(Sqrt),
"sub_with_overflow" => self.codegen_op_with_overflow(
BinaryOperator::OverflowResultMinus,
fargs,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[toolchain]
channel = "nightly-2024-08-01"
channel = "nightly-2024-08-02"
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

// https://github.com/model-checking/kani/issues/555
// kani-flags: --no-undefined-function-checks

// This regression test is in response to issue #135.
// The type of the second parameter to powi is a `CInteger`, but
// the type of `2` here is a `u32`. This test ensures that
Expand Down
24 changes: 0 additions & 24 deletions tests/kani/Cast/cast_abstract_args_to_concrete_fixme.rs

This file was deleted.

26 changes: 26 additions & 0 deletions tests/kani/Intrinsics/Math/Arith/fma.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[kani::proof]
fn verify_fma_32() {
let m = 10.0_f32;
let x = 4.0_f32;
let b = 60.0_f32;

// 100.0
let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();

assert!(abs_difference <= f32::EPSILON);
}

#[kani::proof]
fn verify_fma_64() {
let m = 10.0_f64;
let x = 4.0_f64;
let b = 60.0_f64;

// 100.0
let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();

assert!(abs_difference < 1e-10);
}
22 changes: 22 additions & 0 deletions tests/kani/Intrinsics/Math/Arith/powi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[kani::proof]
fn verify_powi32() {
let x: f32 = kani::any();
kani::assume(x.is_normal());
kani::assume(x >= 1e-19 || x <= -1e-19);
kani::assume(x <= 1.84e19 && x >= -1.84e19);
let x2 = x.powi(2);
assert!(x2 >= 0.0);
}

#[kani::proof]
fn verify_powi64() {
let x: f64 = kani::any();
kani::assume(x.is_normal());
kani::assume(x >= 1e-153 || x <= -1e-153);
kani::assume(x <= 1.34e154 && x >= -1.34e154);
let x2 = x.powi(2);
assert!(x2 >= 0.0);
}
24 changes: 24 additions & 0 deletions tests/kani/Intrinsics/Math/Arith/sqrt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[kani::proof]
fn verify_sqrt32() {
let positive = 4.0_f32;
let negative_zero = -0.0_f32;

let abs_difference = (positive.sqrt() - 2.0).abs();

assert!(abs_difference <= f32::EPSILON);
assert!(negative_zero.sqrt() == negative_zero);
}

#[kani::proof]
fn verify_sqrt64() {
let positive = 4.0_f64;
let negative_zero = -0.0_f64;

let abs_difference = (positive.sqrt() - 2.0).abs();

assert!(abs_difference <= 1e-10);
assert!(negative_zero.sqrt() == negative_zero);
}

0 comments on commit 07ea1c8

Please sign in to comment.