From 2aa0cf300998c62aea8cc6698f8325653a9f0895 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 9 Sep 2020 13:01:21 -0700 Subject: Poppy IR wast parsing and validation (#3105) Adds an IR profile to each function so the validator can determine which validation rules to apply and adds a flag to have the wast parser set the profile to Poppy for testing purposes. --- src/ir/stack-utils.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/ir/stack-utils.cpp') 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()->condition == nullptr; + case Expression::Id::CallId: + return expr->cast()->isReturn; + case Expression::Id::CallIndirectId: + return expr->cast()->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) { -- cgit v1.2.3