diff options
author | Alon Zakai <azakai@google.com> | 2019-12-04 13:04:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 13:04:57 -0800 |
commit | 4056443a5c926ac009b455bf6774445edb6050ba (patch) | |
tree | 4b6c17d538bcfc1637289fc78bfb296da4aab482 /src/ir/branch-utils.h | |
parent | a2f1a6375a596b3dea6fa615f6ff544c368c3991 (diff) | |
download | binaryen-4056443a5c926ac009b455bf6774445edb6050ba.tar.gz binaryen-4056443a5c926ac009b455bf6774445edb6050ba.tar.bz2 binaryen-4056443a5c926ac009b455bf6774445edb6050ba.zip |
Remove 'none' type as a branch target in ReFinalize (#2492)
That was needed for super-old wasm type system, where we allowed
(block $x
(br_if $x
(unreachable)
(nop)
)
)
That is, we differentiated "taken" branches from "named" ones (just
referred to by name, but not actually taken as it's in unreachable code).
We don't need to differentiate those any more. Remove the ReFinalize
code that considered it, and also remove the named/taken distinction in
other places.
Diffstat (limited to 'src/ir/branch-utils.h')
-rw-r--r-- | src/ir/branch-utils.h | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h index c4ff26c0c..53279eee6 100644 --- a/src/ir/branch-utils.h +++ b/src/ir/branch-utils.h @@ -151,12 +151,8 @@ inline std::set<Name> getBranchTargets(Expression* ast) { // Finds if there are branches targeting a name. Note that since names are // unique in our IR, we just need to look for the name, and do not need // to analyze scoping. -// By default we consider all branches, so any place there is a branch that -// names the target. You can unset 'named' to only note branches that appear -// reachable (i.e., are not obviously unreachable). struct BranchSeeker : public PostWalker<BranchSeeker> { Name target; - bool named = true; Index found = 0; Type valueType; @@ -176,15 +172,6 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { } void visitBreak(Break* curr) { - if (!named) { - // ignore an unreachable break - if (curr->condition && curr->condition->type == unreachable) { - return; - } - if (curr->value && curr->value->type == unreachable) { - return; - } - } // check the break if (curr->name == target) { noteFound(curr->value); @@ -192,15 +179,6 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { } void visitSwitch(Switch* curr) { - if (!named) { - // ignore an unreachable switch - if (curr->condition->type == unreachable) { - return; - } - if (curr->value && curr->value->type == unreachable) { - return; - } - } // check the switch for (auto name : curr->targets) { if (name == target) { @@ -213,39 +191,13 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { } void visitBrOnExn(BrOnExn* curr) { - if (!named) { - // ignore an unreachable br_on_exn - if (curr->exnref->type == unreachable) { - return; - } - } // check the br_on_exn if (curr->name == target) { noteFound(curr->sent); } } - static bool hasReachable(Expression* tree, Name target) { - if (!target.is()) { - return false; - } - BranchSeeker seeker(target); - seeker.named = false; - seeker.walk(tree); - return seeker.found > 0; - } - - static Index countReachable(Expression* tree, Name target) { - if (!target.is()) { - return 0; - } - BranchSeeker seeker(target); - seeker.named = false; - seeker.walk(tree); - return seeker.found; - } - - static bool hasNamed(Expression* tree, Name target) { + static bool has(Expression* tree, Name target) { if (!target.is()) { return false; } @@ -254,7 +206,7 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { return seeker.found > 0; } - static Index countNamed(Expression* tree, Name target) { + static Index count(Expression* tree, Name target) { if (!target.is()) { return 0; } |