bytecodealliance / bytecodealliance/wasmtime

Cranelift: unexpected panic on riscv64: called `Option::unwrap()` on a `None` value

Open
#11,183 6 comments 0 reactions 0 assignees View on GitHub
bug cranelift cranelift:area:riscv64
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

### `.clif` Test Case

```

test optimize
set opt_level=none
set preserve_frame_pointers=true
set enable_multi_ret_implicit_sret=true
target x86_64 sse42 has_avx
target aarch64
target s390x
target riscv64gc has_zcd has_zbkb has_zbc has_zbs has_zicond has_zvl32b has_zvl64b has_zvl128b has_zvl1024b has_zvl2048b has_zvl4096b has_zvl8192b has_zvl16384b has_zvl32768b

function u1:6(f32, f32) -> f32, f32 {
block0(v0: f32, v1: f32):
return v0, v0
}

function u1:5(i64 , f32) -> f32 {
sig0 = (f32, f32) -> f32, f32
fn0 = u1:6 sig0

block0(v0: i64, v1: f32):
v17 = iconst.i64 0
v23 = f32const 0x1.5270eep-1
v24 = select_spectre_guard.f32 v0, v1, v23
v26, v27 = call fn0(v23, v24)
return v23
}

function %main() -> f32 {
sig0 = (i64 , f32) -> f32
fn0 = u1:5 sig0

block0:
v3 = iconst.i64 23
v4 = f32const 0x1.5270eep-1
v5 = call fn0(v3,v4)
return v5
}

; print: %main()

```

### Result
```
[x86 ] %main() -> 0x1.5270eep-1
return code: 0

[riscv64] thread 'main' panicked at cranelift/codegen/src/isa/riscv64/lower/isle.rs:169:22:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
return code: 101
```

I tried removing the instruction `v26, v27 = call fn0(v23, v24)`, and that made the case run successfully.
I'm not sure whether this issue is related to #10951

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.