Skip to content

Commit c05f711

Browse files
adpaco-awstedinski
authored andcommitted
Complete count intrinsics codegen and testing (rust-lang#155)
1 parent 4debde2 commit c05f711

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

compiler/rustc_codegen_llvm/src/gotoc/cbmc/irep/to_irep.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ impl ToIrep for ExprValue {
278278
sub: vec![e.to_irep(mm)],
279279
named_sub: btree_map![(
280280
IrepId::CBoundsCheck,
281-
if *allow_zero { Irep::one() } else { Irep::zero() }
281+
if *allow_zero { Irep::zero() } else { Irep::one() }
282282
)],
283283
},
284284
ExprValue::UnOp { op: UnaryOperand::CountTrailingZeros { allow_zero }, e } => Irep {
285285
id: IrepId::CountTrailingZeros,
286286
sub: vec![e.to_irep(mm)],
287287
named_sub: btree_map![(
288288
IrepId::CBoundsCheck,
289-
if *allow_zero { Irep::one() } else { Irep::zero() }
289+
if *allow_zero { Irep::zero() } else { Irep::one() }
290290
)],
291291
},
292292
ExprValue::UnOp { op, e } => {

rust-tests/cbmc-reg/Count/Unstable/Ctlz/fixme_main_fail.rs rust-tests/cbmc-reg/Count/Unstable/Ctlz/bounds_fail.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(core_intrinsics)]
44
use std::intrinsics::ctlz_nonzero;
55

6+
/// rmc bounds_fail.rs -- --bounds-check
67
fn main() {
78
let uv8: u8 = 0;
89
let uv16: u16 = 0;

rust-tests/cbmc-reg/Count/Unstable/Cttz/fixme_main_fail.rs rust-tests/cbmc-reg/Count/Unstable/Cttz/bounds_fail.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(core_intrinsics)]
44
use std::intrinsics::cttz_nonzero;
55

6+
/// rmc bounds_fail.rs -- --bounds-check
67
fn main() {
78
let uv8: u8 = 0;
89
let uv16: u16 = 0;

rust-tests/run.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ for f in `find $TEST_DIR -name '*.rs'`; do
2323
continue
2424
fi
2525

26-
rmc $f -- --object-bits 11 --unwind $UNWIND > .sandbox/"$NAME".output
26+
EXTRA_ARGS=""
27+
if [[ "$f" == *bounds* ]]; then
28+
EXTRA_ARGS+="--bounds-check"
29+
fi
30+
31+
rmc $f -- --object-bits 11 --unwind $UNWIND $EXTRA_ARGS > .sandbox/"$NAME".output
2732

2833
CODE=$?
2934
if [[ $CODE == 0 ]]; then

scripts/setup/ubuntu-20.04/install_cbmc.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set -eux
66

7-
# Install CBMC 5.27 for Ubuntu 20.04
8-
wget https://github.com/diffblue/cbmc/releases/download/cbmc-5.27.0/ubuntu-20.04-cbmc-5.27.0-Linux.deb \
9-
&& sudo dpkg -i ubuntu-20.04-cbmc-5.27.0-Linux.deb \
7+
# Install CBMC 5.30.1 for Ubuntu 20.04
8+
wget https://github.com/diffblue/cbmc/releases/download/cbmc-5.30.1/ubuntu-20.04-cbmc-5.30.1-Linux.deb \
9+
&& sudo dpkg -i ubuntu-20.04-cbmc-5.30.1-Linux.deb \
1010
&& cbmc --version

0 commit comments

Comments
 (0)