summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-13 12:00:11 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-13 12:00:11 -0700
commit00dd3b97455652113fa36cf639315388052f502d (patch)
treedf08b863bd0e06963f25229c8e85f762cbf4e992
parent29cf8735b0a0dd1cd6640e27206f2e2ac78503c1 (diff)
downloadbinaryen-00dd3b97455652113fa36cf639315388052f502d.tar.gz
binaryen-00dd3b97455652113fa36cf639315388052f502d.tar.bz2
binaryen-00dd3b97455652113fa36cf639315388052f502d.zip
fix validation of memBytes, if the load type is unreachable, we can't and shouldn't try to validate
-rw-r--r--src/wasm-validator.h2
-rw-r--r--src/wasm/wasm-validator.cpp7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 2ec530476..f83f5209d 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -217,7 +217,7 @@ public:
void validateAlignment(size_t align, WasmType type, Index bytes, bool isAtomic,
Expression* curr);
- void validateMemBytes(uint8_t bytes, WasmType ty, Expression* curr);
+ void validateMemBytes(uint8_t bytes, WasmType type, Expression* curr);
void validateBinaryenIR(Module& wasm);
};
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index c1f44a68b..25f2588d3 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -237,14 +237,17 @@ void WasmValidator::visitAtomicRMW(AtomicRMW* curr) {
void WasmValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) {
validateMemBytes(curr->bytes, curr->type, curr);
}
-void WasmValidator::validateMemBytes(uint8_t bytes, WasmType ty, Expression* curr) {
+void WasmValidator::validateMemBytes(uint8_t bytes, WasmType type, Expression* curr) {
+ if (type == unreachable) {
+ return; // nothing to validate in this case
+ }
switch (bytes) {
case 1:
case 2:
case 4:
break;
case 8: {
- shouldBeEqual(getWasmTypeSize(ty), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
+ shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
break;
}
default: fail("Memory operations must be 1,2,4, or 8 bytes", curr);