diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-03-23 14:29:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-23 14:29:49 -0700 |
commit | 18fcad6df1edb3589759018da172c03414cfc561 (patch) | |
tree | b63723712c28bf4e121c74d88220bc6583e807df /src/wasm/wasm-validator.cpp | |
parent | 03ae7fcbfc5cedefd25c2414616cb1d3f77ab51b (diff) | |
download | binaryen-18fcad6df1edb3589759018da172c03414cfc561.tar.gz binaryen-18fcad6df1edb3589759018da172c03414cfc561.tar.bz2 binaryen-18fcad6df1edb3589759018da172c03414cfc561.zip |
Allow subtypes in tuple operations (#2700)
Some optimizations may replace tuple elements with simpler values, and
those simpler values may be a subtype of the original value. Tuple
operations should continue to validate without being refinalized in
these cases.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 984c25b3f..d81297408 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1917,9 +1917,10 @@ void FunctionValidator::visitTupleMake(TupleMake* curr) { } types.push_back(op->type); } - shouldBeTrue(Type(types) == curr->type, - curr, - "Type of tuple.make does not match types of its operands"); + shouldBeSubType(Type(types), + curr->type, + curr, + "Type of tuple.make does not match types of its operands"); } void FunctionValidator::visitTupleExtract(TupleExtract* curr) { @@ -1929,13 +1930,15 @@ void FunctionValidator::visitTupleExtract(TupleExtract* curr) { curr, "If tuple.extract has an unreachable operand, it must be unreachable"); } else { - shouldBeTrue(curr->index < curr->tuple->type.size(), - curr, - "tuple.extract index out of bounds"); - shouldBeTrue( - curr->type == curr->tuple->type.expand()[curr->index], - curr, - "tuple.extract type does not match the type of the extracted element"); + bool inBounds = curr->index < curr->tuple->type.size(); + shouldBeTrue(inBounds, curr, "tuple.extract index out of bounds"); + if (inBounds) { + shouldBeSubType( + curr->tuple->type.expand()[curr->index], + curr->type, + curr, + "tuple.extract type does not match the type of the extracted element"); + } } } |