summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/flat.h7
-rw-r--r--src/ir/module-utils.h18
-rw-r--r--src/ir/properties.h5
3 files changed, 17 insertions, 13 deletions
diff --git a/src/ir/flat.h b/src/ir/flat.h
index 01a94a759..d54d4771f 100644
--- a/src/ir/flat.h
+++ b/src/ir/flat.h
@@ -64,17 +64,12 @@ namespace wasm {
namespace Flat {
-inline bool isControlFlowStructure(Expression* curr) {
- return curr->is<Block>() || curr->is<If>() || curr->is<Loop>() ||
- curr->is<Try>();
-}
-
inline void verifyFlatness(Function* func) {
struct VerifyFlatness
: public PostWalker<VerifyFlatness,
UnifiedExpressionVisitor<VerifyFlatness>> {
void visitExpression(Expression* curr) {
- if (isControlFlowStructure(curr)) {
+ if (Properties::isControlFlowStructure(curr)) {
verify(!curr->type.isConcrete(),
"control flow structures must not flow values");
} else if (curr->is<LocalSet>()) {
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index 0e18266e8..be924f742 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -19,6 +19,7 @@
#include "ir/find_all.h"
#include "ir/manipulation.h"
+#include "ir/properties.h"
#include "pass.h"
#include "support/unique_deferring_queue.h"
#include "wasm.h"
@@ -435,16 +436,19 @@ collectSignatures(Module& wasm,
if (func->imported()) {
return;
}
- struct TypeCounter : PostWalker<TypeCounter> {
+ struct TypeCounter
+ : PostWalker<TypeCounter, UnifiedExpressionVisitor<TypeCounter>> {
Counts& counts;
TypeCounter(Counts& counts) : counts(counts) {}
-
- void visitCallIndirect(CallIndirect* curr) { counts[curr->sig]++; }
- void visitBlock(Block* curr) {
- // TODO: Allow blocks to have input types as well
- if (curr->type.isMulti()) {
- counts[Signature(Type::none, curr->type)]++;
+ void visitExpression(Expression* curr) {
+ if (auto* call = curr->dynCast<CallIndirect>()) {
+ counts[call->sig]++;
+ } else if (Properties::isControlFlowStructure(curr)) {
+ // TODO: Allow control flow to have input types as well
+ if (curr->type.isMulti()) {
+ counts[Signature(Type::none, curr->type)]++;
+ }
}
}
};
diff --git a/src/ir/properties.h b/src/ir/properties.h
index b4dfbbd5e..094d90bd6 100644
--- a/src/ir/properties.h
+++ b/src/ir/properties.h
@@ -59,6 +59,11 @@ inline bool isSymmetric(Binary* binary) {
}
}
+inline bool isControlFlowStructure(Expression* curr) {
+ return curr->is<Block>() || curr->is<If>() || curr->is<Loop>() ||
+ curr->is<Try>();
+}
+
// Check if an expression is a control flow construct with a name,
// which implies it may have breaks to it.
inline bool isNamedControlFlow(Expression* curr) {