public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed][odr] Guard odr code with odr_active_p
Date: Wed, 01 Jan 2020 00:00:00 -0000	[thread overview]
Message-ID: <20200213175958.GA14390@delia> (raw)

Hi,

The odr optimization is enabled by the odr variable.

When enabled, some DIEs will get an die_odr_state of ODR_DEF or ODR_DECL,
which is then handled further by code guarded with odr.

However, it may be the case that all DIEs were marked with ODR_NONE, because:
- read_debug_info was run in low-mem mode, or
- read_debug_info was run in optimize-multifile mode, or
- there were no DIEs for which the optimization was applicable.

If all DIEs were marked with ODR_NONE, there is no point in entering further
odr handling code.

Add a variable odr_active_p that is set to true when at least one DIE has an
die_odr_state that is not ODR_NONE, and use the variable to guard some odr code.

Committed to trunk.

Thanks,
- Tom

[odr] Guard odr code with odr_active_p

2020-02-13  Tom de Vries  <tdevries@suse.de>

	* dwz.c (odr_active_p): New var.
	(set_die_odr_state): Set odr_active_p to true.
	(read_debug_info): Initialize odr_active_p to false.
	(partition_dups_1, partition_dups): Use odr_active_p instead of odr.

---
 dwz.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dwz.c b/dwz.c
index f08bf4e..0c13682 100644
--- a/dwz.c
+++ b/dwz.c
@@ -223,6 +223,7 @@ int odr = 1;
 enum odr_mode { ODR_BASIC, ODR_LINK };
 enum odr_mode odr_mode = ODR_LINK;
 int odr_mode_parsed = 0;
+bool odr_active_p = false;
 
 /* Struct to gather statistics.  */
 struct stats
@@ -2544,6 +2545,8 @@ set_die_odr_state (dw_cu_ref cu, dw_die_ref die)
     /* Ignore anonymous types.  */
     return;
 
+  odr_active_p = true;
+
   if (decl_p && !other_p && die->die_child == NULL)
     {
       /* Detected a declaration with no attributes other than DW_AT_name and
@@ -5610,6 +5613,7 @@ read_debug_info (DSO *dso, int kind, unsigned int *die_count)
   struct dw_cu cu_buf;
   struct dw_die die_buf;
 
+  odr_active_p = false;
   if (odr)
     odr_phase = 1;
 
@@ -6958,7 +6962,7 @@ partition_dups_1 (dw_die_ref *arr, size_t vec_size,
 	      dw_die_ref child;
 	      if (second_phase && !arr[k]->die_ref_seen)
 		continue;
-	      if (odr && odr_mode != ODR_BASIC)
+	      if (odr_active_p && odr_mode != ODR_BASIC)
 		arr[k] = reorder_dups (arr[k]);
 	      if (dump_pus_p)
 		dump_die (arr[k]);
@@ -7113,14 +7117,14 @@ partition_dups (void)
 
   to_free = obstack_alloc (&ob2, 1);
 
-  if (odr)
+  if (odr_active_p)
     odr_phase = 2;
 
   for (cu = first_cu; cu; cu = cu->cu_next)
     partition_find_dups (&ob2, cu->cu_die);
   vec_size = obstack_object_size (&ob2) / sizeof (void *);
 
-  if (odr)
+  if (odr_active_p)
     {
       arr = (dw_die_ref *) obstack_base (&ob2);
       if (progress_p)
@@ -7170,7 +7174,7 @@ partition_dups (void)
       vec_size = obstack_object_size (&ob2) / sizeof (void *);
     }
 
-  if (odr)
+  if (odr_active_p)
     odr_phase = 3;
 
   if (stats_p)
@@ -7179,7 +7183,7 @@ partition_dups (void)
   if (vec_size != 0)
     {
       arr = (dw_die_ref *) obstack_finish (&ob2);
-      if (odr)
+      if (odr_active_p)
 	for (i = 0; i < vec_size; ++i)
 	  {
 	    assert (arr[i] != NULL);

                 reply	other threads:[~2020-02-13 18:00 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=20200213175958.GA14390@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).