afonso360 opened PR #5971 from fuzz-full-simd
to main
:
:wave: Hey,
This PR adds all SIMD instructions currently supported by the interpreter to the fuzzer. There is a surprising amount of missing coverage even with all of these ones (i.e. lots of work to do in the interpreter)!
I've also had to disable aligned loads/stores for > 8 bytes. It's really hard to do this without support from cranelift, and I think its probably best to go add support for that before re-enabling it here.
I gave this a bunch of fuzzing time, and it has stopped crashing on all arches. S390X was a little bit harder since I was only able to test it on QEMU and its quite a bit slower than native hardware though it ran about 12hours on 8 cores without crashing, so ¯\\\_(ツ)\_\/¯.
afonso360 requested jameysharp for a review on PR #5971.
jameysharp submitted PR review.
jameysharp created PR review comment:
What do you think of this style? (It may need help from
rustfmt
, I'm just typing things straight into this comment.)let unimplemented_cc = match (fgen.target_triple.architecture, cc) { // Some FloatCC's are not implemented on AArch64, see: // https://github.com/bytecodealliance/wasmtime/issues/4850 (Architecture::Aarch64(_), FloatCC::OrderedNotEqual | FloatCC::UnorderedOrEqual | FloatCC::UnorderedOrLessThan | FloatCC::UnorderedOrLessThanOrEqual | FloatCC::UnorderedOrGreaterThan | FloatCC::UnorderedOrGreaterThanOrEqual) => true, (Architecture::X86_64, FloatCC::UnorderedOrEqual | FloatCC::OrderedNotEqual) if args[0].is_vector() => true, _ => false, }; if unimplemented_cc {
jameysharp created PR review comment:
I think OpcodeConstraints::requires_typevar_operand is most of what we need to avoid having to update this table:
let ctrl_type = if opcode.constraints().requires_typevar_operand() {
Also please update the comment above.
The rest of what we need is figuring out which operand is the typevar operand. It is _almost_ always operand 0, but it depends on the instruction format. For
Ternary
it's operand 1, and forTernaryImm8
it's operand 2. (Seecranelift/codegen/meta/src/shared/formats.rs
and look for calls toInstructionFormatBuilder::typevar_operand
.)Since
insert_opcode
is used for theTernary
format, this technically would look at the wrong typevar operand. Fortunately, all currentTernary
-format opcodes haverequires_typevar_operand=false
, so we don't actually have to fix this today.As future work, I think we should provide a method to get the index of the typevar operand. I think it should be on
InstructionFormat
. There's anInstructionData::typevar_operand
method today that gets theValue
from the appropriate operand of an instruction, but here we need the operand index. (We could replace the existingtypevar_operand
method by calling this new one and indexing intoInstructionData::arguments
, I think.)
jameysharp submitted PR review.
jameysharp created PR review comment:
I'm tempted to assert here that the provided opcode is
Opcode::Shuffle
, since this function will be called for any opcode that uses theShuffle
format. I mean, yes, there's only one such opcode today, but just in case...
afonso360 submitted PR review.
afonso360 created PR review comment:
I think OpcodeConstraints::requires_typevar_operand is most of what we need to avoid having to update this table:
Oh that's really nice! I didn't know that existed.
As future work, I think we should provide a method to get the index of the typevar operand. I think it should be on InstructionFormat. There's an InstructionData::typevar_operand method today that gets the Value from the appropriate operand of an instruction, but here we need the operand index. (We could replace the existing typevar_operand method by calling this new one and indexing into InstructionData::arguments, I think.)
I was thinking about this in a slightly different way. With the new fancy constraint based generation we always know the correct
ctrl_type
, so we could update the inserter signature to also receive that. There are a bunch of inserters that currently do something likerets.first().unwrap()
which we can cleanup.Either way, this can definitely be improved!
afonso360 updated PR #5971 from fuzz-full-simd
to main
.
afonso360 submitted PR review.
afonso360 created PR review comment:
I don't really mind that, but the rustfmt format for that makes it quite hard to parse for me, what do you think?
let unimplemented_cc = match (fgen.target_triple.architecture, cc) { // Some FloatCC's are not implemented on AArch64, see: // https://github.com/bytecodealliance/wasmtime/issues/4850 ( Architecture::Aarch64(_), FloatCC::OrderedNotEqual | FloatCC::UnorderedOrEqual | FloatCC::UnorderedOrLessThan | FloatCC::UnorderedOrLessThanOrEqual | FloatCC::UnorderedOrGreaterThan | FloatCC::UnorderedOrGreaterThanOrEqual, ) => true, (Architecture::X86_64, FloatCC::UnorderedOrEqual | FloatCC::OrderedNotEqual) if args[0].is_vector() => { true } _ => false, }; if unimplemented_cc {
jameysharp submitted PR review.
jameysharp created PR review comment:
Hmm, yeah, that's... not ideal? It's just that I'd prefer to use
match
instead ofslice::contains
to let the compiler decide how to implement this check. I guess for me that preference slightly outweighs style preferences, but I'm willing to be persuaded otherwise.Two things we could try which might improve the style:
- Put each arch/cc combination in a separate match arm, e.g.
(Architecture::Aarch64(_), FloatCC::OrderedNotEqual) => true
instead of using or-patterns- Replace
if x => true
with=> x
afonso360 updated PR #5971 from fuzz-full-simd
to main
.
afonso360 has enabled auto merge for PR #5971.
afonso360 merged PR #5971.
Last updated: Nov 22 2024 at 16:03 UTC