public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/51902] lexical_blocks inside inlined_subroutines generate duplicate debug_ranges
Date: Thu, 19 Jan 2012 18:55:00 -0000	[thread overview]
Message-ID: <bug-51902-4-lmzGCOC7wU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51902-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51902

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-19 18:04:54 UTC ---
Created attachment 26385
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26385
gcc47-pr51902.patch

Partial patch.

The following example shows it even better, there are 5 identical 3 item
ranges:

static int k;

static int
foo (int i)
{
  int q1 = i, q2 = i;
  {
    int q3 = i;
    {
      int q4 = i, q5 = i;
      {
int j = i + 42;
return k + (j > 14 ? j : i);
      }
    }
  }
}

int
main (int argc, char **argv)
{
  int c = argc;
  k = 2 * c;
  c = foo (c);
  return c;
}

IMHO it is impossible to handle this solely in dwarf2out.c, you don't know if
the begin/end notes for a block are adjacent to its BLOCK_SUPERCONTEXT or not.
The attached patch is an untested attempt to provide that info (on a
per-fragment basis).  If the stmt BLOCK given to add_high_low_attributes has
BLOCK_SAME_RANGE bit set and all blocks in its BLOCK_FRAGMENT_CHAIN have it set
as well, then you should be able to use the range of its BLOCK_SUPERCONTEXT (if
both stmt and BLOCK_SUPERCONTEXT (stmt) have the same length of fragment chain,
then the whole supercontext's range, otherwise some tail part of it).  And
recursively so.

I guess in order to avoid searching through the fragment chains all the time
we should clear BLOCK_SAME_RANGE if BLOCK_SAME_RANGE (BLOCK_FRAGMENT_CHAIN) is
clear (somewhere still during reorder_blocks or number_blocks).

And then the question is how to find the range in the .debug_ranges table
effectively.  Walking the whole table would be O(n^2), so have some hash table
that maps the BLOCK_NUM ints that have BLOCK_SAME_RANGE children (at least one)
to .debug_range offsets?


  reply	other threads:[~2012-01-19 18:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-19 15:01 [Bug debug/51902] New: " mark at gcc dot gnu.org
2012-01-19 18:55 ` jakub at gcc dot gnu.org [this message]
2012-01-20 11:30 ` [Bug debug/51902] " jakub at gcc dot gnu.org
2012-01-20 14:19 ` mark at gcc dot gnu.org
2012-01-20 14:20 ` jakub at gcc dot gnu.org
2012-01-20 18:01 ` jakub at gcc dot gnu.org
2012-01-21  5:23 ` mark at gcc dot gnu.org
2012-01-23 15:33 ` jakub at gcc dot gnu.org
2012-01-24 10:37 ` jakub at gcc dot gnu.org
2012-03-05 20:18 ` jakub at gcc dot gnu.org
2012-03-06 17:43 ` jakub at gcc dot gnu.org

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=bug-51902-4-lmzGCOC7wU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).