summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-08-12 09:31:37 -0700
committerGitHub <noreply@github.com>2021-08-12 09:31:37 -0700
commitb84d2cf5491cabdeac565dcd9695d1673037f7e9 (patch)
tree68fc4c43d662c2c7d5baf68c07fa6bcc1cc23058 /src
parent344bfe98b3d4cdb9dac223e9b6b8be7f96332d59 (diff)
downloadbinaryen-b84d2cf5491cabdeac565dcd9695d1673037f7e9.tar.gz
binaryen-b84d2cf5491cabdeac565dcd9695d1673037f7e9.tar.bz2
binaryen-b84d2cf5491cabdeac565dcd9695d1673037f7e9.zip
Fix signed_ field initialization in Load. (#4075)
This was being set in the creation of Loads in the binary reader, but forgotten in the SIMD logic - which ends up creating a Load with type v128, and signed_ was uninitialized. Very hard to test this, but I saw it "break" hash value computation which is how I noticed this. Also initialize the I31 sign field. Now all of them in wasm.h are properly initialized.
Diffstat (limited to 'src')
-rw-r--r--src/wasm.h4
-rw-r--r--src/wasm/wasm-binary.cpp6
2 files changed, 2 insertions, 8 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 268611f34..e673a4c71 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -876,7 +876,7 @@ public:
Load(MixedArena& allocator) {}
uint8_t bytes;
- bool signed_;
+ bool signed_ = false;
Address offset;
Address align;
bool isAtomic;
@@ -1335,7 +1335,7 @@ public:
I31Get(MixedArena& allocator) {}
Expression* i31;
- bool signed_;
+ bool signed_ = false;
void finalize();
};
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index f58c4f783..ae0e24759 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -4041,12 +4041,6 @@ bool WasmBinaryBuilder::maybeVisitLoad(Expression*& out,
Load* curr;
auto allocate = [&]() {
curr = allocator.alloc<Load>();
- // The signed field does not matter in some cases (where the size of the
- // load is equal to the size of the type, in which case we do not extend),
- // but give it a default value nonetheless, to make hashing and other code
- // simpler, so that they do not need to consider whether the sign matters or
- // not.
- curr->signed_ = false;
};
if (!isAtomic) {
switch (code) {