From aa03e54ba09e597cd406a131f502a278db74fad0 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 1 Feb 2021 23:25:15 -0800 Subject: [PATCH] Fix IntrusivePtr release leaks in reaching-def logic --- src/script_opt/DefSetsMgr.h | 1 - src/script_opt/GenRDs.cc | 17 +++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/script_opt/DefSetsMgr.h b/src/script_opt/DefSetsMgr.h index eb2993fc60..0912ec3072 100644 --- a/src/script_opt/DefSetsMgr.h +++ b/src/script_opt/DefSetsMgr.h @@ -75,7 +75,6 @@ public: auto empty_rds = make_intrusive(); SetPreMinRDs(o, empty_rds); SetPreMaxRDs(o, empty_rds); - empty_rds.release(); } // Inherit a node's pre-RDs from those of another node. diff --git a/src/script_opt/GenRDs.cc b/src/script_opt/GenRDs.cc index 5f88ec53bf..9932d32725 100644 --- a/src/script_opt/GenRDs.cc +++ b/src/script_opt/GenRDs.cc @@ -392,9 +392,7 @@ void RD_Decorate::TraverseSwitch(const SwitchStmt* sw) // an empty RD. sw_post_min_rds = make_intrusive(); - mgr.SetPostRDs(sw, sw_post_min_rds, sw_post_max_rds); - sw_post_min_rds.release(); - sw_post_max_rds.release(); + mgr.SetPostRDs(sw, std::move(sw_post_min_rds), std::move(sw_post_max_rds)); block_defs.pop_back(); } @@ -409,9 +407,7 @@ void RD_Decorate::DoIfStmtConfluence(const IfStmt* i) auto max_else_branch_rd = mgr.GetPostMaxRDs(i->FalseBranch()); auto max_post_rds = max_if_branch_rd->Union(max_else_branch_rd); - mgr.SetPostRDs(i, min_post_rds, max_post_rds); - min_post_rds.release(); - max_post_rds.release(); + mgr.SetPostRDs(i, std::move(min_post_rds), std::move(max_post_rds)); } void RD_Decorate::DoLoopConfluence(const Stmt* s, const Stmt* top, @@ -478,10 +474,8 @@ void RD_Decorate::DoLoopConfluence(const Stmt* s, const Stmt* top, // of whether the loop body has flow reaching the end of it, // since an internal "next" can still cause definitions to // propagate to the beginning. - auto min_post_rds = s_min_pre->IntersectWithConsolidation(loop_min_post, - ds); - mgr.SetPostMinRDs(s, min_post_rds); - min_post_rds.release(); + auto min_post_rds = s_min_pre->IntersectWithConsolidation(loop_min_post, ds); + mgr.SetPostMinRDs(s, std::move(min_post_rds)); // Note, we use ignore_break=true because what we care about is not // whether flow goes just beyond the last statement of the body, @@ -492,8 +486,7 @@ void RD_Decorate::DoLoopConfluence(const Stmt* s, const Stmt* top, else { auto max_post_rds = s_max_pre->Union(loop_max_post); - mgr.SetPostMaxRDs(s, max_post_rds); - max_post_rds.release(); + mgr.SetPostMaxRDs(s, std::move(max_post_rds)); } }