summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-02 14:18:48 -0800
committerGitHub <noreply@github.com>2020-12-02 14:18:48 -0800
commitaa53194dc3ce4676e124ee1af65eb8039b1da7b2 (patch)
treeb6dd38a61fffae1062ae12867fa26df3ad8c29fe /src
parente5f5d924ddee6d896203b3d1da862c463c01df24 (diff)
downloadbinaryen-aa53194dc3ce4676e124ee1af65eb8039b1da7b2.tar.gz
binaryen-aa53194dc3ce4676e124ee1af65eb8039b1da7b2.tar.bz2
binaryen-aa53194dc3ce4676e124ee1af65eb8039b1da7b2.zip
[OptimizeInstructions] Fix a fuzz bug with getting the shifts of an unreachable (#3413)
Diffstat (limited to 'src')
-rw-r--r--src/ir/properties.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir/properties.h b/src/ir/properties.h
index 1331eeb73..b86032ba0 100644
--- a/src/ir/properties.h
+++ b/src/ir/properties.h
@@ -132,6 +132,10 @@ inline Literals getLiterals(const Expression* curr) {
// Check if an expression is a sign-extend, and if so, returns the value
// that is extended, otherwise nullptr
inline Expression* getSignExtValue(Expression* curr) {
+ // We only care about i32s here, and ignore i64s, unreachables, etc.
+ if (curr->type != Type::i32) {
+ return nullptr;
+ }
using namespace Match;
int32_t leftShift = 0, rightShift = 0;
Expression* extended = nullptr;
@@ -184,6 +188,10 @@ inline Index getAlmostSignExtBits(Expression* curr, Index& extraLeftShifts) {
// Check if an expression is a zero-extend, and if so, returns the value
// that is extended, otherwise nullptr
inline Expression* getZeroExtValue(Expression* curr) {
+ // We only care about i32s here, and ignore i64s, unreachables, etc.
+ if (curr->type != Type::i32) {
+ return nullptr;
+ }
using namespace Match;
int32_t mask = 0;
Expression* extended = nullptr;