summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-03-29 16:26:14 -0700
committerGitHub <noreply@github.com>2024-03-29 16:26:14 -0700
commitfedee9fb559e06db94eb5ae565914d59df5db315 (patch)
tree1b34abeb0dbca67896832945ff3b59ba6a4af07c /src
parentb1b0c3efc56951d210210f6a9d9731d7bd98b415 (diff)
downloadbinaryen-fedee9fb559e06db94eb5ae565914d59df5db315.tar.gz
binaryen-fedee9fb559e06db94eb5ae565914d59df5db315.tar.bz2
binaryen-fedee9fb559e06db94eb5ae565914d59df5db315.zip
GUFA: Fix hashing of GlobalInfo's type (#6455)
For a global we store the name and a type, and the type may be more precise than the global's type in the wasm. As a result, when hashing, it is not enough to hash only the name, so hash the type as well. Also add a random TODO as a comment.
Diffstat (limited to 'src')
-rw-r--r--src/ir/possible-contents.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ir/possible-contents.h b/src/ir/possible-contents.h
index 2773c1d31..7ff0f1a07 100644
--- a/src/ir/possible-contents.h
+++ b/src/ir/possible-contents.h
@@ -76,6 +76,9 @@ class PossibleContents {
// The contents flowing out will be a Global, but of a non-nullable type,
// unlike the original global.
Type type;
+ // TODO: Consider adding a depth here, or merging this with ConeType in some
+ // way. In principle, not having depth info can lead to loss of
+ // precision.
bool operator==(const GlobalInfo& other) const {
return name == other.name && type == other.type;
}
@@ -305,8 +308,9 @@ public:
// Nothing to add.
} else if (isLiteral()) {
rehash(ret, getLiteral());
- } else if (isGlobal()) {
- rehash(ret, getGlobal());
+ } else if (auto* global = std::get_if<GlobalInfo>(&value)) {
+ rehash(ret, global->name);
+ rehash(ret, global->type);
} else if (auto* coneType = std::get_if<ConeType>(&value)) {
rehash(ret, coneType->type);
rehash(ret, coneType->depth);