diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-09-09 13:01:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 13:01:21 -0700 |
commit | 2aa0cf300998c62aea8cc6698f8325653a9f0895 (patch) | |
tree | 2116bc18fd58514589821858c528951e76c5178b /src/ir/stack-utils.cpp | |
parent | 41ea543093ed734c73e5202c58c899be447b3223 (diff) | |
download | binaryen-2aa0cf300998c62aea8cc6698f8325653a9f0895.tar.gz binaryen-2aa0cf300998c62aea8cc6698f8325653a9f0895.tar.bz2 binaryen-2aa0cf300998c62aea8cc6698f8325653a9f0895.zip |
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.
Diffstat (limited to 'src/ir/stack-utils.cpp')
-rw-r--r-- | src/ir/stack-utils.cpp | 23 |
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) { |