summaryrefslogtreecommitdiff
path: root/src/passes/ReReloop.cpp
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-08 05:58:28 +0200
committerGitHub <noreply@github.com>2020-09-08 05:58:28 +0200
commit4a8d1abc61e657436616203a75935b3df8af515b (patch)
tree5e234a1310af6e63c2526c5d9cfb511eed574660 /src/passes/ReReloop.cpp
parenta6816a287bd3f802cb6db51032e77145f036c8b7 (diff)
downloadbinaryen-4a8d1abc61e657436616203a75935b3df8af515b.tar.gz
binaryen-4a8d1abc61e657436616203a75935b3df8af515b.tar.bz2
binaryen-4a8d1abc61e657436616203a75935b3df8af515b.zip
Fix Relooper leaking Branches (#3097)
Fixes the `Relooper` leaking `Branch`es in `Optimizer::SkipEmptyBlocks`, by refactoring the API so a `std::unique_ptr` is ensured for each `Block`, `Branch` and `Shape` upon adding to the relooper.
Diffstat (limited to 'src/passes/ReReloop.cpp')
-rw-r--r--src/passes/ReReloop.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/passes/ReReloop.cpp b/src/passes/ReReloop.cpp
index 004e922ed..b35efa8d4 100644
--- a/src/passes/ReReloop.cpp
+++ b/src/passes/ReReloop.cpp
@@ -50,9 +50,7 @@ struct ReReloop final : public Pass {
CFG::Block* currCFGBlock = nullptr;
CFG::Block* makeCFGBlock() {
- auto* ret = new CFG::Block(builder->makeBlock());
- relooper->AddBlock(ret);
- return ret;
+ return relooper->AddBlock(builder->makeBlock());
}
CFG::Block* setCurrCFGBlock(CFG::Block* curr) {
@@ -321,7 +319,7 @@ struct ReReloop final : public Pass {
// blocks that do not have any exits are dead ends in the relooper. we need
// to make sure that are in fact dead ends, and do not flow control
// anywhere. add a return as needed
- for (auto* cfgBlock : relooper->Blocks) {
+ for (auto& cfgBlock : relooper->Blocks) {
auto* block = cfgBlock->Code->cast<Block>();
if (cfgBlock->BranchesOut.empty() && block->type != Type::unreachable) {
block->list.push_back(function->sig.results == Type::none