summaryrefslogtreecommitdiff
path: root/src/tools/wasm-reduce.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-07-01 01:56:23 +0000
committerGitHub <noreply@github.com>2021-06-30 18:56:23 -0700
commitca27f40a2f1070a16ee7c0efc18ff35d342d8027 (patch)
treeab0f2b1b731737bc409db21f677b97be16f67c0f /src/tools/wasm-reduce.cpp
parent10ef52d62468aec5762742930630e882dc5e5c0b (diff)
downloadbinaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.tar.gz
binaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.tar.bz2
binaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.zip
Preserve Function HeapTypes (#3952)
When using nominal types, func.ref of two functions with identical signatures but different HeapTypes will yield different types. To preserve these semantics, Functions need to track their HeapTypes, not just their Signatures. This PR replaces the Signature field in Function with a HeapType field and adds new utility methods to make it almost as simple to update and query the function HeapType as it was to update and query the Function Signature.
Diffstat (limited to 'src/tools/wasm-reduce.cpp')
-rw-r--r--src/tools/wasm-reduce.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp
index 48435fac0..ed2b9b564 100644
--- a/src/tools/wasm-reduce.cpp
+++ b/src/tools/wasm-reduce.cpp
@@ -483,7 +483,7 @@ struct Reducer
auto* save = curr;
Unreachable un;
Nop nop;
- bool useUnreachable = getFunction()->sig.results != Type::none;
+ bool useUnreachable = getFunction()->getResults() != Type::none;
if (useUnreachable) {
replaceCurrent(&un);
} else {
@@ -977,7 +977,7 @@ struct Reducer
auto* func = module->functions[0].get();
// We can't remove something that might have breaks to it.
if (!func->imported() && !Properties::isNamedControlFlow(func->body)) {
- auto funcSig = func->sig;
+ auto funcType = func->type;
auto* funcBody = func->body;
for (auto* child : ChildIterator(func->body)) {
if (!(child->type.isConcrete() || child->type == Type::none)) {
@@ -985,7 +985,7 @@ struct Reducer
}
// Try to replace the body with the child, fixing up the function
// to accept it.
- func->sig.results = child->type;
+ func->type = Signature(funcType.getSignature().params, child->type);
func->body = child;
if (writeAndTestReduction()) {
// great, we succeeded!
@@ -994,7 +994,7 @@ struct Reducer
break;
}
// Undo.
- func->sig = funcSig;
+ func->type = funcType;
func->body = funcBody;
}
}