about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-09 07:11:28 +0000
committerbors <bors@rust-lang.org>2024-06-09 07:11:28 +0000
commitd5fa08cad8ad2729582aabc8e8663c966237b28d (patch)
tree5b6338f6cdaf7d89767fac6d6fa7bb3f2df42a5e
parent989dfb1066502570e9784a9140665fcc1868a8cf (diff)
parenta13a9ab75997c9a5130956873532260428046499 (diff)
downloadrust-d5fa08cad8ad2729582aabc8e8663c966237b28d.tar.gz
rust-d5fa08cad8ad2729582aabc8e8663c966237b28d.zip
Auto merge of #3659 - RalfJung:bitmask-too-large, r=RalfJung
simd_bitmask: nicer error when the mask is too big

Cc https://github.com/rust-lang/miri/issues/3658
-rw-r--r--src/tools/miri/src/intrinsics/simd.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/miri/src/intrinsics/simd.rs b/src/tools/miri/src/intrinsics/simd.rs
index d82c523b817..7aa37ba449e 100644
--- a/src/tools/miri/src/intrinsics/simd.rs
+++ b/src/tools/miri/src/intrinsics/simd.rs
@@ -452,13 +452,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
                 let (no, no_len) = this.operand_to_simd(no)?;
                 let (dest, dest_len) = this.mplace_to_simd(dest)?;
                 let bitmask_len = dest_len.next_multiple_of(8);
+                if bitmask_len > 64 {
+                    throw_unsup_format!(
+                        "simd_bitmask: masks larger than 64 elements are currently not supported"
+                    );
+                }
 
                 // The mask must be an integer or an array.
                 assert!(
                     mask.layout.ty.is_integral()
                         || matches!(mask.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8)
                 );
-                assert!(bitmask_len <= 64);
                 assert_eq!(bitmask_len, mask.layout.size.bits());
                 assert_eq!(dest_len, yes_len);
                 assert_eq!(dest_len, no_len);
@@ -498,13 +502,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
                 let [op] = check_arg_count(args)?;
                 let (op, op_len) = this.operand_to_simd(op)?;
                 let bitmask_len = op_len.next_multiple_of(8);
+                if bitmask_len > 64 {
+                    throw_unsup_format!(
+                        "simd_bitmask: masks larger than 64 elements are currently not supported"
+                    );
+                }
 
                 // Returns either an unsigned integer or array of `u8`.
                 assert!(
                     dest.layout.ty.is_integral()
                         || matches!(dest.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8)
                 );
-                assert!(bitmask_len <= 64);
                 assert_eq!(bitmask_len, dest.layout.size.bits());
                 let op_len = u32::try_from(op_len).unwrap();