-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should be implemented in ISLE: inst = v12 = smulhi.i8 v0, v0
, type = Some(types::I8)
#1455
Comments
It looks like you are multiplying a 128bit integer with a 16bit integer. I don't think that is possible in surface rust. Probably something the MIR verifier should be made to deny. |
By multiplying I assume you meant shift right?
This surface Rust also triggers the same panic (though it has UB): #![allow(arithmetic_overflow)]
pub fn fn13(mut _7:i8) {
let mut _31: (i128, i16) = (0,0);
let mut _25: i16 = 0;
let mut _39: i16 = 0;
_31.1 = _7 as i16;
_25 = _31.1 * _31.1;
_31 = (50414009528881047150422352225052180952_i128, _25);
_25 = _31.1 >> _31.0 as u128;
std::hint::black_box(_25);
}
pub fn main() {
fn13(0);
} |
I misread the The only place where cg_clif emits an rustc_codegen_cranelift/src/num.rs Line 257 in cdae185
I see. It doesn't have UB by the way. There is no unsafe code. Shifting with overflow is defined as panicking at runtime. The lint you suppressed only triggers when rustc knows the shift amount at compile time already. In any case I can't reproduce this error on aarch64-unknown-linux-gnu, but I can reproduce it on x86_64-unknown-linux-gnu. It seems to be a Cranelift issue. I reduced it to:
|
I've reported this upstream at bytecodealliance/wasmtime#7865. Thanks for reporting this to me! |
I've found something similar involving simd stuff, might be related: auto-reduced (treereduce-rust): #![crate_type = "lib"]
#![feature(repr_simd, platform_intrinsics)]
#[repr(simd)]
pub struct f32x2(pub f32, pub f32);
extern "platform-intrinsic" {
fn simd_fcos<T>(x: T) -> T;
}
pub unsafe extern "C-unwind" fn fcos_32x2(a: f32x2) -> f32x2 {
simd_fcos(a)
}
original code
original: // compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
#![feature(repr_simd, platform_intrinsics)]
#![allow(non_camel_case_types)]
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x2(pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x8(pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x16(pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32);
extern "platform-intrinsic" {
fn simd_fcos<T>(x: T) -> T;
}
// CHECK-LABEL: @fcos_32x2
#[no_mangle]
pub unsafe extern "C-unwind" fn fcos_32x2(a: f32x2) -> f32x2 {
// CHECK: call <2 x float> @llvm.cos.v2f32
simd_fcos(a)
}
// CHECK-LABEL: @fcos_32x4
#[no_mangle]
pub unsafe fn fcos_32x4(a: f32x4) -> f32x4 {
// CHECK: call <4 x float> @llvm.cos.v4f32
simd_fcos(a)
}
// CHECK-LABEL: @fcos_32x8
#[no_mangle]
pub unsafe fn fcos_32x8(a: f32x8) -> f32x8 {
// CHECK: call <8 x float> @llvm.cos.v8f32
simd_fcos(a)
}
// CHECK-LABEL: @fcos_32x16
#[no_mangle]
pub unsafe fn fcos_32x16(a: f32x16) -> f32x16 {
// CHECK: call <16 x float> @llvm.cos.v16f32
simd_fcos(a)
}
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x2(pub f64, pub f64);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x4(pub f64, pub f64, pub f64, pub f64);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x8(pub f64, pub f64, pub f64, pub f64,
pub f64, pub f64, pub f64, pub f64);
// CHECK-LABEL: @fcos_64x4
#[no_mangle]
pub unsafe fn fcos_64x4(a: f64x4) -> f64x4 {
// CHECK: call <4 x double> @llvm.cos.v4f64
simd_fcos(a)
}
// CHECK-LABEL: @fcos_64x2
#[no_mangle]
pub unsafe fn fcos_64x2(a: f64x2) -> f64x2 {
// CHECK: call <2 x double> @llvm.cos.v2f64
simd_fcos(a)
}
// CHECK-LABEL: @fcos_64x8
#[no_mangle]
pub unsafe fn fcos_64x8(a: f64x8) -> f64x8 {
// CHECK: call <8 x double> @llvm.cos.v8f64
simd_fcos(a)
} Version information
Command: Program output
|
The multiplication issue has been fixed. @matthiaskrgr I can't reproduce your crash. I had to change it to #![crate_type = "lib"]
#![feature(repr_simd, intrinsics)]
#[repr(simd)]
pub struct f32x2(pub f32, pub f32);
extern "rust-intrinsic" {
fn simd_fcos<T>(x: T) -> T;
}
pub unsafe extern "C-unwind" fn fcos_32x2(a: f32x2) -> f32x2 {
simd_fcos(a)
} as |
is this an x86 thing again? 😅 with #1455 (comment)
|
Yes, it reproduces on x86_64. |
I'm not sure if f32x2 is allowed at all by the x86_64 systemv calling convention. It is on aarch64 though ( |
In any case I opened bytecodealliance/wasmtime#8075 to suggest adding |
Reproduction is in Custom MIR. Not sure if this can be triggered from surface rust
On latest cdae185
The text was updated successfully, but these errors were encountered: