diff options
author | Thomas Lively <tlively@google.com> | 2022-10-04 21:51:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-04 19:51:35 -0700 |
commit | 5b0977d564ef7f20f066a3082720b5b7327642c2 (patch) | |
tree | 441411e4b0fbe3efe321fd87199a3c07024329b1 /src | |
parent | 9868e17f729983722ca0f8f5a4c91f63db52a703 (diff) | |
download | binaryen-5b0977d564ef7f20f066a3082720b5b7327642c2.tar.gz binaryen-5b0977d564ef7f20f066a3082720b5b7327642c2.tar.bz2 binaryen-5b0977d564ef7f20f066a3082720b5b7327642c2.zip |
Simplify and fix heap type counting (#5110)
Annotations on array.get and array.set were not being counted and the code could
generally be simplified since `count` already ignores types that don't need to
be counted.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/module-utils.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 84cd66c60..5044d303c 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -54,17 +54,15 @@ struct CodeScanner if (auto* call = curr->dynCast<CallIndirect>()) { counts.note(call->heapType); } else if (auto* call = curr->dynCast<CallRef>()) { - if (call->isReturn && call->target->type.isFunction()) { - counts.note(call->target->type); - } + counts.note(call->target->type); } else if (curr->is<RefNull>()) { counts.note(curr->type); - } else if (auto* make = curr->dynCast<StructNew>()) { - handleMake(make); - } else if (auto* make = curr->dynCast<ArrayNew>()) { - handleMake(make); - } else if (auto* make = curr->dynCast<ArrayInit>()) { - handleMake(make); + } else if (curr->is<StructNew>()) { + counts.note(curr->type); + } else if (curr->is<ArrayNew>()) { + counts.note(curr->type); + } else if (curr->is<ArrayInit>()) { + counts.note(curr->type); } else if (auto* cast = curr->dynCast<RefCast>()) { counts.note(cast->intendedType); } else if (auto* cast = curr->dynCast<RefTest>()) { @@ -77,6 +75,11 @@ struct CodeScanner counts.note(get->ref->type); } else if (auto* set = curr->dynCast<StructSet>()) { counts.note(set->ref->type); + } else if (auto* get = curr->dynCast<ArrayGet>()) { + counts.note(get->ref->type); + } else if (auto* set = curr->dynCast<ArraySet>()) { + counts.note(set->ref->type); + } else if (Properties::isControlFlowStructure(curr)) { if (curr->type.isTuple()) { // TODO: Allow control flow to have input types as well @@ -86,12 +89,6 @@ struct CodeScanner } } } - - template<typename T> void handleMake(T* curr) { - if (curr->type != Type::unreachable) { - counts.note(curr->type.getHeapType()); - } - } }; Counts getHeapTypeCounts(Module& wasm) { |