summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-03-27 21:51:40 -0700
committerGitHub <noreply@github.com>2020-03-27 21:51:40 -0700
commit2b758fbdc46fc8fe5241bcf1ba5bbd81e6d556ed (patch)
treead75a0205850e7c3fa7e1a561eb378267aa7e798
parentd595a45b66cbb4d59472d2954131ee1f4cf6ad8e (diff)
downloadbinaryen-2b758fbdc46fc8fe5241bcf1ba5bbd81e6d556ed.tar.gz
binaryen-2b758fbdc46fc8fe5241bcf1ba5bbd81e6d556ed.tar.bz2
binaryen-2b758fbdc46fc8fe5241bcf1ba5bbd81e6d556ed.zip
Error out when EH is used in unsupported code (#2713)
This calls `Fatal()` when EH instructions are used in unsupported code. Currently EH instructions are unsupported in Flatten, ReReloop, and DataFlow-using passes.
-rw-r--r--src/dataflow/graph.h3
-rw-r--r--src/passes/Flatten.cpp5
-rw-r--r--src/passes/ReReloop.cpp3
3 files changed, 11 insertions, 0 deletions
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h
index 6a984ad72..114a38f11 100644
--- a/src/dataflow/graph.h
+++ b/src/dataflow/graph.h
@@ -230,6 +230,9 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
return doVisitUnreachable(unreachable);
} else if (auto* drop = curr->dynCast<Drop>()) {
return doVisitDrop(drop);
+ } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() ||
+ curr->is<BrOnExn>()) {
+ Fatal() << "DataFlow does not support EH instructions yet";
} else {
return doVisitGeneric(curr);
}
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
index 0a6a7022a..9139d5dca 100644
--- a/src/passes/Flatten.cpp
+++ b/src/passes/Flatten.cpp
@@ -68,6 +68,11 @@ struct Flatten
return;
}
+ if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() ||
+ curr->is<BrOnExn>()) {
+ Fatal() << "Flatten does not support EH instructions yet";
+ }
+
if (Properties::isControlFlowStructure(curr)) {
// handle control flow explicitly. our children do not have control flow,
// but they do have preludes which we need to set up in the right place
diff --git a/src/passes/ReReloop.cpp b/src/passes/ReReloop.cpp
index 8f83f8a8f..004e922ed 100644
--- a/src/passes/ReReloop.cpp
+++ b/src/passes/ReReloop.cpp
@@ -284,6 +284,9 @@ struct ReReloop final : public Pass {
ReturnTask::handle(*this, ret);
} else if (auto* un = curr->dynCast<Unreachable>()) {
UnreachableTask::handle(*this, un);
+ } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() ||
+ curr->is<BrOnExn>()) {
+ Fatal() << "ReReloop does not support EH instructions yet";
} else {
// not control flow, so just a simple element
getCurrBlock()->list.push_back(curr);