summaryrefslogtreecommitdiff
path: root/src/ir/stack-utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/stack-utils.cpp')
-rw-r--r--src/ir/stack-utils.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ir/stack-utils.cpp b/src/ir/stack-utils.cpp
index ef871040b..bc0fd2eb4 100644
--- a/src/ir/stack-utils.cpp
+++ b/src/ir/stack-utils.cpp
@@ -15,6 +15,7 @@
*/
#include "stack-utils.h"
+#include "ir/properties.h"
namespace wasm {
@@ -30,6 +31,28 @@ void removeNops(Block* block) {
block->list.resize(newIndex);
}
+bool mayBeUnreachable(Expression* expr) {
+ if (Properties::isControlFlowStructure(expr)) {
+ return true;
+ }
+ switch (expr->_id) {
+ case Expression::Id::BreakId:
+ return expr->cast<Break>()->condition == nullptr;
+ case Expression::Id::CallId:
+ return expr->cast<Call>()->isReturn;
+ case Expression::Id::CallIndirectId:
+ return expr->cast<CallIndirect>()->isReturn;
+ case Expression::Id::ReturnId:
+ case Expression::Id::SwitchId:
+ case Expression::Id::UnreachableId:
+ case Expression::Id::ThrowId:
+ case Expression::Id::RethrowId:
+ return true;
+ default:
+ return false;
+ }
+}
+
} // namespace StackUtils
StackSignature::StackSignature(Expression* expr) {