diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-10 20:48:39 -0700 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-11 11:07:46 -0700 |
commit | 75162c41b83f67eee967b1d7a1068ba87e17b4eb (patch) | |
tree | 72fc847f229639d2e8abe399f59357a7d4498fa4 /src/passes/RemoveUnusedBrs.cpp | |
parent | b2445bf12b1ba96209b6ebece3806503411f1c94 (diff) | |
download | binaryen-75162c41b83f67eee967b1d7a1068ba87e17b4eb.tar.gz binaryen-75162c41b83f67eee967b1d7a1068ba87e17b4eb.tar.bz2 binaryen-75162c41b83f67eee967b1d7a1068ba87e17b4eb.zip |
fix block removal in remove-unused-brs, even if not taken, if named, we must preserve it
Diffstat (limited to 'src/passes/RemoveUnusedBrs.cpp')
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 572105187..b725de901 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -259,7 +259,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // so only do it if it looks useful, which it definitely is if // (a) $somewhere is straight out (so the br out vanishes), and // (b) this br_if is the only branch to that block (so the block will vanish) - if (brIf->name == block->name && BranchUtils::BranchSeeker::count(block, block->name) == 1) { + if (brIf->name == block->name && BranchUtils::BranchSeeker::countNamed(block, block->name) == 1) { // note that we could drop the last element here, it is a br we know for sure is removable, // but telling stealSlice to steal all to the end is more efficient, it can just truncate. list[i] = builder.makeIf(brIf->condition, builder.makeBreak(brIf->name), builder.stealSlice(block, i + 1, list.size())); @@ -449,7 +449,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { auto* br = list[0]->dynCast<Break>(); if (br && br->condition && br->name == curr->name) { assert(!br->value); // can't, it would be dropped or last in the block - if (BranchUtils::BranchSeeker::count(curr, curr->name) == 1) { + if (BranchUtils::BranchSeeker::countNamed(curr, curr->name) == 1) { // no other breaks to that name, so we can do this Builder builder(*getModule()); replaceCurrent(builder.makeIf( |