Skip to content
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

x64: Register allocation failure with simd instructions #3337

Closed
alexcrichton opened this issue Sep 12, 2021 · 1 comment · Fixed by #3550
Closed

x64: Register allocation failure with simd instructions #3337

alexcrichton opened this issue Sep 12, 2021 · 1 comment · Fixed by #3550
Labels
bug Incorrect behavior in the current implementation that needs fixing cranelift:area:x64 Issues related to x64 codegen fuzz-bug Bugs found by a fuzzer wasm-proposal:simd Issues related to the WebAssembly SIMD proposal

Comments

@alexcrichton
Copy link
Member

I think that this is along the lines of #3160, but this input:

(module
  (type (;0;) (func))
  (func (;0;) (type 0)
    v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000
    i64x2.extend_low_i32x4_u
    v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000
    i64x2.mul
    i32x4.all_true
    i64.load offset=1 align=1
    drop
    unreachable)
  (func (;1;) (type 0)
    nop)
  (memory (;0;) 5613 17832))

yields:

$ cargo run -q reduce/test.wat --enable-all
 ERROR cranelift_codegen::machinst::compile > Register allocation error for vcode
VCode_ShowWithRRU {{
  Entry block: 0
Block 0:
  (original IR block: block0)
  (instruction range: 0 .. 13)
  Inst 0:   movq    %rdi, %v0J
  Inst 1:   movq    %rsi, %v1J
  Inst 2:   movdqa  %v6V, %v7V
  Inst 3:   pxor    %v14V, %v14V
  Inst 4:   pcmpeqd %v7V, %v14V
  Inst 5:   ptest   %v14V, %v14V
  Inst 6:   setz    %v8Jb
  Inst 7:   movq    %v8J, %v9J
  Inst 8:   andq    $1, %v9J
  Inst 9:   movl    %v9Jl, %v10Jl
  Inst 10:   movq    36(%v0J), %v11J
  Inst 11:   movq    1(%v11J,%v10J,1), %v13J
  Inst 12:   ud2 unreachable
}}

Error: Analysis(EntryLiveinValues([v6V]))
thread '<unnamed>' panicked at 'register allocation: Analysis(EntryLiveinValues([v6V]))', cranelift/codegen/src/machinst/compile.rs:96:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@alexcrichton alexcrichton added bug Incorrect behavior in the current implementation that needs fixing fuzz-bug Bugs found by a fuzzer cranelift:area:x64 Issues related to x64 codegen wasm-proposal:simd Issues related to the WebAssembly SIMD proposal labels Sep 12, 2021
@cfallin
Copy link
Member

cfallin commented Sep 12, 2021

@jlb6740 could you take a look? It looks like the SIMD lowering is missing an instruction somewhere: the movdqa moves out of v6, but v6 is never set. I expect this is an issue with the i64x2.extend_low_i32x4_u based on the input.

alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Nov 11, 2021
Fixes an issue where existing lowerings had accidental silent
fall-through which meant that input wasm of just the right shape would
panic the code generator.

Closes bytecodealliance#3337
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Nov 19, 2021
This commit adds a test from bytecodealliance#3337 which is an issue that was fixed
in bytecodealliance#3506 due to moving `imul` lowering rules to ISLE which fixed the
underlying issue of accidentally not falling through to the necessary
case for general `i64x2.mul` multiplication.

Closes bytecodealliance#3337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior in the current implementation that needs fixing cranelift:area:x64 Issues related to x64 codegen fuzz-bug Bugs found by a fuzzer wasm-proposal:simd Issues related to the WebAssembly SIMD proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants