From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: GCC 9 backports
Date: Tue, 14 May 2019 08:45:00 -0000 [thread overview]
Message-ID: <97ec7d16-eebe-4124-7018-22242c76a797@suse.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 95 bytes --]
Hi.
There are 2 backport patches that I've just tested and I'm going to install them.
Martin
[-- Attachment #2: 0001-Backport-r271116.patch --]
[-- Type: text/x-patch, Size: 4910 bytes --]
From 4ad5f7ebfa965fc65acca851e48e9f56e9a2f20d Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 May 2019 07:04:58 +0000
Subject: [PATCH 1/2] Backport r271116
gcc/ChangeLog:
2019-05-13 Martin Liska <mliska@suse.cz>
PR gcov-profile/90380
* gcov.c (enum loop_type): Remove the enum and
the operator.
(handle_cycle): Assert that we should not reach
a negative count.
(circuit): Use loop_found instead of a tri-state loop_type.
(get_cycles_count): Do not handle NEGATIVE_LOOP as it can't
happen.
---
gcc/gcov.c | 53 ++++++++++++++++++-----------------------------------
1 file changed, 18 insertions(+), 35 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 1fc37a07c34..6bcd2b23748 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -676,27 +676,11 @@ bool function_info::group_line_p (unsigned n, unsigned src_idx)
typedef vector<arc_info *> arc_vector_t;
typedef vector<const block_info *> block_vector_t;
-/* Enum with types of loop in CFG. */
-
-enum loop_type
-{
- NO_LOOP = 0,
- LOOP = 1,
- NEGATIVE_LOOP = 3
-};
-
-/* Loop_type operator that merges two values: A and B. */
-
-inline loop_type& operator |= (loop_type& a, loop_type b)
-{
- return a = static_cast<loop_type> (a | b);
-}
-
/* Handle cycle identified by EDGES, where the function finds minimum cs_count
and subtract the value from all counts. The subtracted value is added
to COUNT. Returns type of loop. */
-static loop_type
+static void
handle_cycle (const arc_vector_t &edges, int64_t &count)
{
/* Find the minimum edge of the cycle, and reduce all nodes in the cycle by
@@ -712,7 +696,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
for (unsigned i = 0; i < edges.size (); i++)
edges[i]->cs_count -= cycle_count;
- return cycle_count < 0 ? NEGATIVE_LOOP : LOOP;
+ gcc_assert (cycle_count >= 0);
}
/* Unblock a block U from BLOCKED. Apart from that, iterate all blocks
@@ -743,12 +727,12 @@ unblock (const block_info *u, block_vector_t &blocked,
blocked by a block. COUNT is accumulated count of the current LINE.
Returns what type of loop it contains. */
-static loop_type
+static bool
circuit (block_info *v, arc_vector_t &path, block_info *start,
block_vector_t &blocked, vector<block_vector_t> &block_lists,
line_info &linfo, int64_t &count)
{
- loop_type result = NO_LOOP;
+ bool loop_found = false;
/* Add v to the block list. */
gcc_assert (find (blocked.begin (), blocked.end (), v) == blocked.end ());
@@ -763,15 +747,19 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
path.push_back (arc);
if (w == start)
- /* Cycle has been found. */
- result |= handle_cycle (path, count);
+ {
+ /* Cycle has been found. */
+ handle_cycle (path, count);
+ loop_found = true;
+ }
else if (find (blocked.begin (), blocked.end (), w) == blocked.end ())
- result |= circuit (w, path, start, blocked, block_lists, linfo, count);
+ loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
+ count);
path.pop_back ();
}
- if (result != NO_LOOP)
+ if (loop_found)
unblock (v, blocked, block_lists);
else
for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
@@ -788,14 +776,13 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
list.push_back (v);
}
- return result;
+ return loop_found;
}
-/* Find cycles for a LINFO. If HANDLE_NEGATIVE_CYCLES is set and the line
- contains a negative loop, then perform the same function once again. */
+/* Find cycles for a LINFO. */
static gcov_type
-get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
+get_cycles_count (line_info &linfo)
{
/* Note that this algorithm works even if blocks aren't in sorted order.
Each iteration of the circuit detection is completely independent
@@ -803,7 +790,7 @@ get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
Therefore, operating on a permuted order (i.e., non-sorted) only
has the effect of permuting the output cycles. */
- loop_type result = NO_LOOP;
+ bool loop_found = false;
gcov_type count = 0;
for (vector<block_info *>::iterator it = linfo.blocks.begin ();
it != linfo.blocks.end (); it++)
@@ -811,14 +798,10 @@ get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
arc_vector_t path;
block_vector_t blocked;
vector<block_vector_t > block_lists;
- result |= circuit (*it, path, *it, blocked, block_lists, linfo,
- count);
+ loop_found |= circuit (*it, path, *it, blocked, block_lists, linfo,
+ count);
}
- /* If we have a negative cycle, repeat the find_cycles routine. */
- if (result == NEGATIVE_LOOP && handle_negative_cycles)
- count += get_cycles_count (linfo, false);
-
return count;
}
--
2.21.0
[-- Attachment #3: 0002-Backport-r271117.patch --]
[-- Type: text/x-patch, Size: 2702 bytes --]
From b566f10c6650baabc72cf090a08774936b1f703b Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 May 2019 07:05:23 +0000
Subject: [PATCH 2/2] Backport r271117
gcc/ChangeLog:
2019-05-13 Martin Liska <mliska@suse.cz>
PR gcov-profile/90380
* gcov.c (handle_cycle): Do not support zero cycle count,
it should not be possible.
(path_contains_zero_cycle_arc): New function.
(circuit): Ignore zero cycle arc counts.
---
gcc/gcov.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 6bcd2b23748..b06a6714c2e 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -696,7 +696,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
for (unsigned i = 0; i < edges.size (); i++)
edges[i]->cs_count -= cycle_count;
- gcc_assert (cycle_count >= 0);
+ gcc_assert (cycle_count > 0);
}
/* Unblock a block U from BLOCKED. Apart from that, iterate all blocks
@@ -722,6 +722,17 @@ unblock (const block_info *u, block_vector_t &blocked,
unblock (*it, blocked, block_lists);
}
+/* Return true when PATH contains a zero cycle arc count. */
+
+static bool
+path_contains_zero_cycle_arc (arc_vector_t &path)
+{
+ for (unsigned i = 0; i < path.size (); i++)
+ if (path[i]->cs_count == 0)
+ return true;
+ return false;
+}
+
/* Find circuit going to block V, PATH is provisional seen cycle.
BLOCKED is vector of blocked vertices, BLOCK_LISTS contains vertices
blocked by a block. COUNT is accumulated count of the current LINE.
@@ -742,7 +753,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
block_info *w = arc->dst;
- if (w < start || !linfo.has_block (w))
+ if (w < start
+ || arc->cs_count == 0
+ || !linfo.has_block (w))
continue;
path.push_back (arc);
@@ -752,7 +765,8 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
handle_cycle (path, count);
loop_found = true;
}
- else if (find (blocked.begin (), blocked.end (), w) == blocked.end ())
+ else if (!path_contains_zero_cycle_arc (path)
+ && find (blocked.begin (), blocked.end (), w) == blocked.end ())
loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
count);
@@ -765,7 +779,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
block_info *w = arc->dst;
- if (w < start || !linfo.has_block (w))
+ if (w < start
+ || arc->cs_count == 0
+ || !linfo.has_block (w))
continue;
size_t index
--
2.21.0
next reply other threads:[~2019-05-14 8:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 8:45 Martin Liška [this message]
2019-05-14 8:47 ` Martin Liška
2019-05-24 7:43 ` Martin Liška
2019-07-04 9:23 ` Martin Liška
2019-07-22 9:36 ` Martin Liška
2019-08-23 11:56 ` Martin Liška
2019-09-02 8:56 ` Martin Liška
2019-10-23 12:12 ` Martin Liška
2020-02-28 17:51 ` Martin Liška
2020-03-10 10:09 ` Martin Liška
2020-04-03 10:32 ` Martin Liška
2020-04-20 9:25 ` Martin Liška
2020-10-02 10:05 ` Martin Liška
2020-10-02 11:15 ` Martin Liška
2020-10-15 9:07 ` Martin Liška
2020-10-16 8:51 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97ec7d16-eebe-4124-7018-22242c76a797@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).