From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Improve --devel-verify-edges
Date: Tue, 01 Jan 2019 00:00:00 -0000 [thread overview]
Message-ID: <20191205152629.GA26133@delia> (raw)
Hi,
Improvements for verify_edges and verify_edges_1:
- improve structure
- add comments
- add verification of next field
Committed to trunk.
Thanks,
- Tom
Improve --devel-verify-edges
2019-12-05 Tom de Vries <tdevries@suse.de>
* dwz.c (verify_edges_1): Add comments. Merge last_idx init and
count and last_idx update into fors.
(verify_edges): Add comments. Split out verification of initial and
new PUs. Verify next field.
---
dwz.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 46 insertions(+), 10 deletions(-)
diff --git a/dwz.c b/dwz.c
index 8eb676c..6f88b82 100644
--- a/dwz.c
+++ b/dwz.c
@@ -6495,29 +6495,42 @@ static void
verify_edges_1 (struct import_cu *ipu, unsigned int *ic, unsigned int *oc)
{
struct import_edge *e1, *e2;
- unsigned int last_idx = 0, count;
- for (e1 = ipu->incoming, count = 0; e1; e1 = e1->next)
+ unsigned int last_idx, count;
+
+ for (last_idx = 0, count = 0, e1 = ipu->incoming;
+ e1;
+ last_idx = e1->icu->idx, count++, e1 = e1->next)
{
+ /* Verify that incoming edges are in ascending idx order. */
assert (count == 0 || e1->icu->idx > last_idx);
- last_idx = e1->icu->idx;
- count++;
+
+ /* Verify that each incoming edge has a corresponding outgoing edge. */
for (e2 = e1->icu->outgoing; e2; e2 = e2->next)
if (e2->icu == ipu)
break;
assert (e2);
}
+
+ /* Verify the number of incoming edges. */
assert (ipu->incoming_count == count);
- for (e1 = ipu->outgoing, count = 0; e1; e1 = e1->next)
+
+ for (last_idx = 0, count = 0, e1 = ipu->outgoing;
+ e1;
+ last_idx = e1->icu->idx, count++, e1 = e1->next)
{
+ /* Verify that outgoing edges are in ascending idx order. */
assert (count == 0 || e1->icu->idx > last_idx);
- last_idx = e1->icu->idx;
- count++;
+
+ /* Verify that each outgoing edge has a corresponding incoming edge. */
for (e2 = e1->icu->incoming; e2; e2 = e2->next)
if (e2->icu == ipu)
break;
assert (e2);
}
+
+ /* Verify the number of outgoing edges. */
assert (ipu->outgoing_count == count);
+
*ic += ipu->incoming_count;
*oc += ipu->outgoing_count;
}
@@ -6528,11 +6541,34 @@ void
verify_edges (struct import_cu **ipus, unsigned int npus, unsigned int ncus)
{
struct import_cu *ipu;
- unsigned int i, ic = 0, oc = 0;
- for (ipu = ipus[0]; ipu; ipu = ipu->next)
+ unsigned int i, ic, oc;
+
+ ic = 0;
+ oc = 0;
+
+ /* Verify initial PUs. */
+ for (i = 0; i < npus; ++i)
+ {
+ ipu = ipus[i];
+ if (i < npus - 1)
+ assert (ipu->next == ipus[i + 1]);
+ verify_edges_1 (ipu, &ic, &oc);
+ }
+
+ /* Verify new PUs. */
+ for (ipu = ipu->next; ipu; ipu = ipu->next)
verify_edges_1 (ipu, &ic, &oc);
+
+ /* Verify CUs. */
for (i = 0; i < ncus; i++)
- verify_edges_1 (ipus[i + npus], &ic, &oc);
+ {
+ ipu = ipus[npus + i];
+ assert (ipu->next == NULL);
+ verify_edges_1 (ipu, &ic, &oc);
+ }
+
+ /* Verify that the overall number of incoming and outgoing edges is
+ equal. */
assert (ic == oc);
}
reply other threads:[~2019-12-05 15:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20191205152629.GA26133@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
/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).