Closed cbeuw closed 7 months ago
Reduced to
#![feature(custom_mir, core_intrinsics)]
#![allow(internal_features)]
use std::intrinsics::mir::*;
fn p(x: u8) {
println!("{x}");
}
#[custom_mir(dialect = "runtime", phase = "initial")]
pub fn fn0() {
mir! {
let _5: u8;
let _8: i128;
let _10: isize;
let _22: ();
let _23: isize;
{
Call(_5 = fn1(), ReturnTo(bb1), UnwindUnreachable())
}
bb1 = {
_10 = _5 as isize;
_23 = 256isize * _10;
_5 = _23 as u8;
Call(_22 = p(_5), ReturnTo(bb2), UnwindUnreachable())
}
bb2 = {
Return()
}
}
}
pub fn fn1() -> u8 {
42
}
pub fn main() {
fn0();
}
Thanks for the bug report! I've filled https://github.com/bytecodealliance/wasmtime/issues/7999 as this is a Cranelift bug.
The Cranelift fix has been backported.
Fuzzer generated custom MIR:
After
RET = _3 * _10
, the value ofRET
should be10752_isize
(0x2A00). Casting tou8
is 0, so the program should print 0. This is what LLVM backend and Miri prints.However, with
rustc_codegen_cranelift
at-Copt-level=3
it prints 42