[PATCH 4/6] return auto_vec from get_dominated_by

Trevor Saunders tbsaunde@tbsaunde.org
Wed Jun 16 03:09:17 GMT 2021


On Tue, Jun 15, 2021 at 01:18:54PM +0200, Bernhard Reutner-Fischer wrote:
> On 15 June 2021 08:46:57 CEST, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >On Tue, Jun 15, 2021 at 8:02 AM Trevor Saunders <tbsaunde@tbsaunde.org>
> >wrote:
> >>
> >> Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
> >>
> >> bootstrapped and regtested on x86_64-linux-gnu, ok?
> >
> >OK.
> >
> >Thanks,
> >Richard.
> >
> >> gcc/ChangeLog:
> >>
> >>         * dominance.c (get_dominated_by): Return
> >auto_vec<basic_block>.
> >>         * dominance.h (get_dominated_by): Likewise.
> >>         * auto-profile.c (afdo_find_equiv_class): Adjust.
> >>         * cfgloopmanip.c (duplicate_loop_to_header_edge): Likewise.
> >>         * loop-unroll.c (unroll_loop_runtime_iterations): Likewise.
> >>         * tree-cfg.c (test_linear_chain): Likewise.
> >>         (test_diamond): Likewise.
> >> ---
> 
> >> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> >> index 02256580c98..6bdd1a561fd 100644
> >> --- a/gcc/tree-cfg.c
> >> +++ b/gcc/tree-cfg.c
> >> @@ -9917,22 +9917,20 @@ test_linear_chain ()
> >>    calculate_dominance_info (CDI_DOMINATORS);
> >>    ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_b));
> >>    ASSERT_EQ (bb_b, get_immediate_dominator (CDI_DOMINATORS, bb_c));
> >> -  vec<basic_block> dom_by_b = get_dominated_by (CDI_DOMINATORS,
> >bb_b);
> >> +  auto_vec<basic_block> dom_by_b = get_dominated_by (CDI_DOMINATORS,
> >bb_b);
> >>    ASSERT_EQ (1, dom_by_b.length ());
> >>    ASSERT_EQ (bb_c, dom_by_b[0]);
> >>    free_dominance_info (CDI_DOMINATORS);
> >> -  dom_by_b.release ();
> >>
> >>    /* Similarly for post-dominance: each BB in our chain is
> >post-dominated
> >>       by the one after it.  */
> >>    calculate_dominance_info (CDI_POST_DOMINATORS);
> >>    ASSERT_EQ (bb_b, get_immediate_dominator (CDI_POST_DOMINATORS,
> >bb_a));
> >>    ASSERT_EQ (bb_c, get_immediate_dominator (CDI_POST_DOMINATORS,
> >bb_b));
> >> -  vec<basic_block> postdom_by_b = get_dominated_by
> >(CDI_POST_DOMINATORS, bb_b);
> >> +  auto_vec<basic_block> postdom_by_b = get_dominated_by
> >(CDI_POST_DOMINATORS, bb_b);
> >>    ASSERT_EQ (1, postdom_by_b.length ());
> >>    ASSERT_EQ (bb_a, postdom_by_b[0]);
> >>    free_dominance_info (CDI_POST_DOMINATORS);
> >> -  postdom_by_b.release ();
> >>
> >>    pop_cfun ();
> >>  }
> >> @@ -9991,10 +9989,10 @@ test_diamond ()
> >>    ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_b));
> >>    ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_c));
> >>    ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_d));
> >> -  vec<basic_block> dom_by_a = get_dominated_by (CDI_DOMINATORS,
> >bb_a);
> >> +  auto_vec<basic_block> dom_by_a = get_dominated_by (CDI_DOMINATORS,
> >bb_a);
> >>    ASSERT_EQ (3, dom_by_a.length ()); /* B, C, D, in some order.  */
> >>    dom_by_a.release ();
> 
> I'm curious why you keep the release() above and ...

There was no particular reason, I just didn't make a very complete
search to remove them all, as they should be harmless.  I'm certainly
happy to remove them, but wonder if it wouldn't make more sense to go on
a broader search for uses of release and see why they are necessary or
remove them.

thanks

Trev


More information about the Gcc-patches mailing list