alexcrichton opened issue #4513:
Given this input module:
(module (type (;0;) (func (param i64))) (func (;0;) (type 0) (param i64) (local f64 f64 i32) i32.const 0 if ;; label = @1 unreachable end i32.const 0 i32.const -1 i32.rem_u f64.convert_i32_s f64.neg f64.neg drop ) )
this currently panics in codegen with:
$ cargo run -q compile foo.wat thread '<unnamed>' panicked at 'assertion failed: first_mov_emitted', cranelift/codegen/src/isa/aarch64/lower/isle.rs:221:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cc @akirilov-arm
alexcrichton labeled issue #4513:
Given this input module:
(module (type (;0;) (func (param i64))) (func (;0;) (type 0) (param i64) (local f64 f64 i32) i32.const 0 if ;; label = @1 unreachable end i32.const 0 i32.const -1 i32.rem_u f64.convert_i32_s f64.neg f64.neg drop ) )
this currently panics in codegen with:
$ cargo run -q compile foo.wat thread '<unnamed>' panicked at 'assertion failed: first_mov_emitted', cranelift/codegen/src/isa/aarch64/lower/isle.rs:221:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cc @akirilov-arm
alexcrichton commented on issue #4513:
Shrunken slightly:
(module (func (param i32) (result i32) local.get 0 i32.const -1 i32.rem_u ) )
cfallin commented on issue #4513:
This patch works locally for me with the above (and passes tests; to pass some tests the "match u32::MAX or u64::MAX for bits == 32" logic was necessary):
diff --git a/cranelift/codegen/src/isa/aarch64/lower/isle.rs b/cranelift/codegen/src/isa/aarch64/lower/isle.rs index fa4556f03..bd1c50fd9 100644 --- a/cranelift/codegen/src/isa/aarch64/lower/isle.rs +++ b/cranelift/codegen/src/isa/aarch64/lower/isle.rs @@ -157,7 +157,9 @@ where size: OperandSize::Size64, }); return rd.to_reg(); - } else if value == u64::MAX { + } else if (bits == 64 && value == u64::MAX) + || (bits == 32 && (value & u32::MAX as u64) == u32::MAX as u64) + { self.emit(&MInst::MovWide { op: MoveWideOp::MovN, rd,
@akirilov-arm I'm not sure if we fully grok the invariants here though (especially re: extensions), so could you check the above? The code was introduced as part of the recent CVE fix I believe.
akirilov-arm commented on issue #4513:
@cfallin I believe that you have pinpointed the problematic spot precisely, but I think that there is a further improvement to be made (actually a simplification to make it easier to reason about the code), so I am working on a fix.
akirilov-arm edited a comment on issue #4513:
@cfallin I believe that you have pinpointed the problematic spot precisely, but I think that there is a further improvement to be made (actually a simplification to make it easier to reason about the code), so I am working on a fix.
P.S.
srem
andurem
tests are also severely lacking.
akirilov-arm labeled issue #4513:
Given this input module:
(module (type (;0;) (func (param i64))) (func (;0;) (type 0) (param i64) (local f64 f64 i32) i32.const 0 if ;; label = @1 unreachable end i32.const 0 i32.const -1 i32.rem_u f64.convert_i32_s f64.neg f64.neg drop ) )
this currently panics in codegen with:
$ cargo run -q compile foo.wat thread '<unnamed>' panicked at 'assertion failed: first_mov_emitted', cranelift/codegen/src/isa/aarch64/lower/isle.rs:221:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cc @akirilov-arm
akirilov-arm labeled issue #4513:
Given this input module:
(module (type (;0;) (func (param i64))) (func (;0;) (type 0) (param i64) (local f64 f64 i32) i32.const 0 if ;; label = @1 unreachable end i32.const 0 i32.const -1 i32.rem_u f64.convert_i32_s f64.neg f64.neg drop ) )
this currently panics in codegen with:
$ cargo run -q compile foo.wat thread '<unnamed>' panicked at 'assertion failed: first_mov_emitted', cranelift/codegen/src/isa/aarch64/lower/isle.rs:221:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cc @akirilov-arm
cfallin closed issue #4513:
Given this input module:
(module (type (;0;) (func (param i64))) (func (;0;) (type 0) (param i64) (local f64 f64 i32) i32.const 0 if ;; label = @1 unreachable end i32.const 0 i32.const -1 i32.rem_u f64.convert_i32_s f64.neg f64.neg drop ) )
this currently panics in codegen with:
$ cargo run -q compile foo.wat thread '<unnamed>' panicked at 'assertion failed: first_mov_emitted', cranelift/codegen/src/isa/aarch64/lower/isle.rs:221:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cc @akirilov-arm
Last updated: Dec 23 2024 at 12:05 UTC