From 244da920eedafec42da4e91b83c09d0021a36a7f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 19 May 2016 19:57:14 -0700 Subject: notice only branches out in EffectAnalyzer, internal control flow can be ignored (#530) --- src/ast_utils.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/ast_utils.h') diff --git a/src/ast_utils.h b/src/ast_utils.h index 96c6a9319..07db4806b 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -53,9 +53,11 @@ struct EffectAnalyzer : public PostWalker 0) branches = true; } - bool branches = false; + bool branches = false; // branches out of this expression bool calls = false; std::set localsRead; std::set localsWritten; @@ -101,9 +103,25 @@ struct EffectAnalyzer : public PostWalker breakNames; + + void visitBreak(Break *curr) { + breakNames.insert(curr->name); + } + void visitSwitch(Switch *curr) { + for (auto name : curr->targets) { + breakNames.insert(name); + } + breakNames.insert(curr->default_); + } + void visitBlock(Block* curr) { + if (curr->name.is()) breakNames.erase(curr->name); // these were internal breaks + } + void visitLoop(Loop* curr) { + if (curr->in.is()) breakNames.erase(curr->in); // these were internal breaks + if (curr->out.is()) breakNames.erase(curr->out); // these were internal breaks + } + void visitCall(Call *curr) { calls = true; } void visitCallImport(CallImport *curr) { calls = true; } void visitCallIndirect(CallIndirect *curr) { calls = true; } -- cgit v1.2.3