From c1e1a688fb50bffe2ab21e4cce7374ac65e89205 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 25 Jul 2016 12:56:08 +0200 Subject: [PATCH] Handle loops with loop->latch == NULL (PR gcov-profile/71868) PR gcov-profile/71868 * cfgloopanal.c (expected_loop_iterations_unbounded): When we have a function with multiple latches, count them all. From-SVN: r238706 --- gcc/ChangeLog | 6 ++++++ gcc/cfgloopanal.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 18a969f46e6..7a8a69c5a45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-25 Martin Liska + + PR gcov-profile/71868 + * cfgloopanal.c (expected_loop_iterations_unbounded): When we + have a function with multiple latches, count them all. + 2016-07-25 Martin Liska * tree-ssa-loop-niter.c (loop_only_exit_p): Release body array. diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 2739f44a3a6..001cf45ee9c 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -244,7 +244,7 @@ expected_loop_iterations_unbounded (const struct loop *loop, /* If we have no profile at all, use AVG_LOOP_NITER. */ if (profile_status_for_fn (cfun) == PROFILE_ABSENT) expected = PARAM_VALUE (PARAM_AVG_LOOP_NITER); - else if (loop->latch->count || loop->header->count) + else if (loop->latch && (loop->latch->count || loop->header->count)) { gcov_type count_in, count_latch; @@ -274,8 +274,8 @@ expected_loop_iterations_unbounded (const struct loop *loop, freq_latch = 0; FOR_EACH_EDGE (e, ei, loop->header->preds) - if (e->src == loop->latch) - freq_latch = EDGE_FREQUENCY (e); + if (flow_bb_inside_loop_p (loop, e->src)) + freq_latch += EDGE_FREQUENCY (e); else freq_in += EDGE_FREQUENCY (e); -- 2.30.2