public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/24399] Dead code in partition_dups_1
  2019-01-01  0:00 [Bug default/24399] New: Dead code in partition_dups_1 vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2019-01-01  0:00 ` vries at gcc dot gnu.org
@ 2019-01-01  0:00 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=24399

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
I think this fixes it:
...
diff --git a/dwz.c b/dwz.c
index 6b6a33e..9728400 100644
--- a/dwz.c
+++ b/dwz.c
@@ -5347,7 +5347,7 @@ partition_dups_1 (dw_die_ref *arr, size_t vec_size,
         the same set of referrers, try to see if we can put also those
         into the partial unit.  They can be put there only if they
         don't refer to DIEs that won't be put into partial units.  */
-      if (second_phase && force && force < j - k)
+      if (second_phase && force && force < j - i)
        {
          /* First optimistically assume all such DIEs can be put there,
             thus mark all such DIEs as going to be included, so that
...

Note: j - i is the size of the partition [i,j).

The intention of the test 'force < j - k' is to test whether there are any
unforced dies in the partition. If all dies in the partition are forced, than
there's no need to enter this clause.

So overall, the code tests whether in the second phase, there are some forced
dies (force > 0) and some unforced dies (force < j - i). If there are no forced
dies, we're done. If there are only forced dies, we're also done. If there are
some forced and unforced dies, try to add unforced dies to the partial unit
already assigned the forced dies.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/24399] Dead code in partition_dups_1
  2019-01-01  0:00 [Bug default/24399] New: Dead code in partition_dups_1 vries at gcc dot gnu.org
  2019-01-01  0:00 ` [Bug default/24399] " vries at gcc dot gnu.org
@ 2019-01-01  0:00 ` vries at gcc dot gnu.org
  2019-01-01  0:00 ` vries at gcc dot gnu.org
  2019-01-01  0:00 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=24399

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
It's rather hard to trigger the clause though. It only triggers in
testsuite/dwz-external.tests/kernel-multifile.sh, and then it still doesn't
have any effect (where effect is defined as: number of children created in
partial unit is larger than the value of variable 'forced').

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/24399] New: Dead code in partition_dups_1
@ 2019-01-01  0:00 vries at gcc dot gnu.org
  2019-01-01  0:00 ` [Bug default/24399] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=24399

            Bug ID: 24399
           Summary: Dead code in partition_dups_1
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: default
          Assignee: nobody at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: dwz at sourceware dot org
  Target Milestone: ---

There's this clause in partition_dups_1:
...
      /* If during second_phase there are some DIEs we want to force            
         into a partial unit because they are referenced from something         
         already forced into a partial unit, but also some DIEs with            
         the same set of referrers, try to see if we can put also those         
         into the partial unit.  They can be put there only if they             
         don't refer to DIEs that won't be put into partial units.  */
      if (second_phase && force && force < j - k)
        {
...

It seems that the clause is dead. I can't trigger this abort in the test
suites:
...
diff --git a/dwz.c b/dwz.c
index 6b6a33e..c44d53d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -5349,6 +5349,7 @@ partition_dups_1 (dw_die_ref *arr, size_t vec_size,
         don't refer to DIEs that won't be put into partial units.  */
       if (second_phase && force && force < j - k)
        {
+         abort ();
          /* First optimistically assume all such DIEs can be put there,
             thus mark all such DIEs as going to be included, so that
             even if one of those DIEs references another one from those
...

There's a loop just before this optimization:
...
      for (k = i; k < j; k++)
        {
          if (second_phase && arr[k]->die_ref_seen)
            force++;
          size += calc_sizes (arr[k]);
          for (ref = arr[k]->die_parent;
               ref->die_named_namespace && ref->die_dup == NULL;
               ref = ref->die_parent)
            {
              ref->die_dup = arr[k];
              namespaces++;
            }
        }
...
and it does not contain a break, so the expected end status will be k == j.

So, the condition 'force < j - k' with force >= will always evaluate to false.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/24399] Dead code in partition_dups_1
  2019-01-01  0:00 [Bug default/24399] New: Dead code in partition_dups_1 vries at gcc dot gnu.org
  2019-01-01  0:00 ` [Bug default/24399] " vries at gcc dot gnu.org
  2019-01-01  0:00 ` vries at gcc dot gnu.org
@ 2019-01-01  0:00 ` vries at gcc dot gnu.org
  2019-01-01  0:00 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=24399

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/24399] Dead code in partition_dups_1
  2019-01-01  0:00 [Bug default/24399] New: Dead code in partition_dups_1 vries at gcc dot gnu.org
@ 2019-01-01  0:00 ` vries at gcc dot gnu.org
  2019-01-01  0:00 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=24399

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
The commit https://sourceware.org/git/?p=dwz.git;a=commit;
h=04a676d5c88b25bf887261c3085ec8acfb89ead5 :
- fixes the problem in the optimization condition, and 
- limits the optimization to off-by-default, enabled
  by --devel-partition-dups-opt (so: developer-mode only).

This does address the dead code issue, so: marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-18 12:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [Bug default/24399] New: Dead code in partition_dups_1 vries at gcc dot gnu.org
2019-01-01  0:00 ` [Bug default/24399] " vries at gcc dot gnu.org
2019-01-01  0:00 ` vries at gcc dot gnu.org
2019-01-01  0:00 ` vries at gcc dot gnu.org
2019-01-01  0:00 ` vries at gcc dot gnu.org

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).