Stream: git-wasmtime

Topic: wasmtime / PR #6850 [draft] cranelift: Validate `iconst` ...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2023 at 00:04):

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 .. 0xFFFFFFFF

fix #3059

Explain why this change is needed:

As mentioned in #3059, iconst currently allows any immediate within the range of an i64, even for iconst.i8, iconst.i16 or iconst.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: Dec 23 2024 at 12:05 UTC