bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.42k stars 1.3k forks source link

Cranelift: ISLE extraction panics #3743

Open abrown opened 2 years ago

abrown commented 2 years ago

When I create a new extractor, one to extract the comparison flag from a comparison referenced by select, ISLE panics.

Steps to Reproduce

Add:

(decl select_fcmp_flag (FloatCC) Inst)
(extractor (select_fcmp_flag comparison_flag)
      (select (def_inst (fcmp comparison_flag a b)) x y))

Then run:

cargo build -p cranelift-codegen --features rebuild-isle

Expected Results

The ISLE code to generate without failure.

Actual Results

  --- stderr
  thread 'main' panicked at 'assertion failed: !tyenv.errors.is_empty()', cranelift/isle/isle/src/sema.rs:1055:29
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Versions and Environment

Cranelift version or commit: latest HEAD

abrown commented 2 years ago

cc: @fitzgen

fitzgen commented 2 years ago

Standalone reproducer test case:

(type FloatCC (enum))
(type Inst (enum))
(type Value (enum))

(type ValueArray2 (enum))
(decl value_array_2 (Value Value) ValueArray2)
(extern constructor value_array_2 pack_value_array_2)
(extern extractor infallible value_array_2 unpack_value_array_2)

(type ValueArray3 (enum))
(decl value_array_3 (Value Value Value) ValueArray3)
(extern constructor value_array_3 pack_value_array_3)
(extern extractor infallible value_array_3 unpack_value_array_3)

(decl inst_data (InstructionData) Inst)
(extern extractor infallible inst_data inst_data)

(type Opcode extern (enum Fcmp Select))

(type InstructionData (enum (FloatCompare (opcode Opcode) (args ValueArray2) (cond FloatCC))
                            (Ternary (opcode Opcode) (args ValueArray3))))

(decl def_inst (Inst) Value)
(extern extractor def_inst def_inst)

(decl fcmp (FloatCC Value Value) Inst)
(extractor
 (fcmp Cond x y)
 (inst_data (InstructionData.FloatCompare (Opcode.Fcmp) (value_array_2 x y) Cond)))

(decl select (Value Value Value) Inst)
(extractor
 (select c x y)
 (inst_data (InstructionData.Ternary (Opcode.Select) (value_array_3 c x y))))

(decl select_fcmp_flag (FloatCC) Inst)
(extractor (select_fcmp_flag comparison_flag)
           (select (def_inst (fcmp comparison_flag a b)) x y))
github-actions[bot] commented 2 years ago

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "isle" Thus the following users have been cc'd because of the following labels: * cfallin: isle * fitzgen: isle To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file. [Learn more.](https://github.com/bytecodealliance/subscribe-to-label-action)