timjrd opened PR #6850 from timjrd:cranelift_validate_iconst_ranges
to bytecodealliance:main
:
Implements the following checks:
iconst.i8
immediate must be within 0 .. 0xFF
iconst.i16
immediate must be within 0 .. 0xFFFF
iconst.i32
immediate must be within 0 .. 0xFFFFFFFFfix #3059
Explain why this change is needed:
As mentioned in #3059,
iconst
currently allows any immediate within the range of ani64
, even foriconst.i8
,iconst.i16
oriconst.i32
.This breaks some tests!
Running
cargo test
in/cranelift/codegen
returns successfully. I also added a few tests concerning the new checks.Running
cargo test
in/cranelift
returns some failures. For example:1: - inst1 (v1 = iconst.i8 -1): constant immediate is out of bounds [...] failures: bugpoint::tests::test_reduce run::test::nop
Which is expected if we forbid negative immediates, @jameysharp could you please confirm?
Running
cargo test
at the root of this repo returns a lot of failures, possibly related to negative immediates.This is my first contribution so this patch is probably broken.
Last updated: Nov 22 2024 at 16:03 UTC