public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Michael Matz <matz@suse.de>
Cc: Richard Guenther <richard.guenther@gmail.com>,
	gcc-patches@gcc.gnu.org,         gcc@gcc.gnu.org
Subject: Re: Designs for better debug info in GCC
Date: Wed, 07 Nov 2007 18:45:00 -0000	[thread overview]
Message-ID: <ork5otuc6w.fsf@oliva.athome.lsd.ic.unicamp.br> (raw)
In-Reply-To: <Pine.LNX.4.64.0711071815540.23011@wotan.suse.de> (Michael Matz's message of "Wed\, 7 Nov 2007 18\:20\:31 +0100 \(CET\)")

On Nov  7, 2007, Michael Matz <matz@suse.de> wrote:

> On Wed, 7 Nov 2007, Alexandre Oliva wrote:

>> This will fail on a very fundamental level.  Consider code such as:
>> 
>> f(int x, int y) { int c; /* other vars */
>>  c = x; do_something_with(c, ...); // doesn't touch x or y
>>  c = y; do_something_else_with(c, ...); // doesn't touch x or y

>> This can (and should) be trivially optimized to:
>> 
>> f(int x, int y) { /* other vars */
>>  do_something_with(x, ...); // doesn't touch x or y
>>  do_something_else_with(y, ...); // doesn't touch x or y
>> 
>> But now, if I 'print c' in a debugger in the middle of one of the
>> do_something_*with expansions, what do I get?
>> 
>> With the approach I'm implementing, you should get x and y at the
>> appropriate points, even though variable c doesn't really exist any
>> more.
>> 
>> With your approach, what will you get?

> x and y at the appropriate part.  Whatever holds 'x' at a point (SSA name, 
> pseudo or mem) will also mention that it holds 'c'.  At a later point 
> whichever holds 'y' will also mention in holds 'c' .

I.e., there will be two parallel locations throughout the entire
function that hold the value of 'c'.  Something like:

f(int x /* but also c */, int y /* but also c */) { /* other vars */
 do_something_with(x, ...); // doesn't touch x or y
 do_something_else_with(y, ...); // doesn't touch x or y

Now, what will you get if you 'print c' in the debugger (or if any
other debug info evaluator needs to tell what the value of user
variable c is) at a point within do_something_with(c,...) or
do_something_else_with(c)?


Now consider that f is inlined into the following code:

int g(point2d p) {
  /* lots of code */
  f(p.x, p.y);
  /* more code */
  f(p.y, p.x);
  /* even more code */
}

g gets fully scalarized, so, before inlining, we have:

int g(point2d p) {
  int p$x = p.x, int p$y = p.y;
  /* lots of code */
  f(p$x, p$y);
  /* more code */
  f(p$y, p$x);
  /* even more code */
}

after inlining of f, we end up with:

int g(point2d p) {
  int p$x = p.x, int p$y = p.y;
  /* lots of code */
  { int f()::x.1 /* but also f()::c.1 */ = p$x, f()::y.1 /* but also f()::c.1 */ = p$y;
    { /* other vars */
      do_something_with(f()::x.1, ...); // doesn't touch x or y
      do_something_else_with(f()::y.1, ...); // doesn't touch x or y
  } }
  /* more code */
  { int f()::x.2 /* but also f()::c.2 */ = p$x, f()::y.2 /* but also f()::c.2 */ = p$y;
    { /* other vars */
      do_something_with(f()::x.2, ...); // doesn't touch x or y
      do_something_else_with(f()::y.2, ...); // doesn't touch x or y
  } }
  /* even more code */
}

then, we further optimize g and get:

int g(point2d p) {
  int p$x /* but also f()::x.1, f()::c.1, f()::y.2, f()::c.2 */ = p.x;
  int p$y /* but also f()::y.1, f()::c.1, f()::x.2, f()::c.2 */ = p.y;
  /* lots of code */
  { { /* other vars */
      do_something_with(p$x, ...); // doesn't touch x or y
      do_something_else_with(p$y, ...); // doesn't touch x or y
  } }
  /* more code */
  { { /* other vars */
      do_something_with(p$y, ...); // doesn't touch x or y
      do_something_else_with(p$x, ...); // doesn't touch x or y
  } }
  /* even more code */
}

and now, if you try to resolve the variable name 'c' to a location or
a value within any of the occurrences of do_something_*with(), what do
you get?  What ranges do you generate for each of the variables
involved?

>> There isn't any assignment to x or y you could hook your notes to.

> But there are _places_ for x and y.  Those places can and are also 
> associated with c.

This just goes to show that there's a fundamental mistake in the
mapping.  Instead of mapping user-level concepts to implementation
concepts, which is what debug information is meant to do, you're
mapping implementation details to user-level concepts.

Unfortunately, this mapping is not biunivocal.  The chosen
representation is fundamentally lossy.  It can't possibly get you
accurate debug information.  And the above is just an initial example
of the loss of information that will lead to *incorrect* debug
information, which is far worse than *incomplete* information.

>> Even if you were to set up side representations to model the additional 
>> variables that end up mapped to the incoming arguments, you'd have 'c' 
>> in both, and at the entry point.  How would you tell?

> I don't understand the question.

See the discussion about resolving 'c' above.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

  reply	other threads:[~2007-11-07 18:45 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-05  8:28 [vta] don't let debug insns get in the way of simple vect reduction Alexandre Oliva
2007-11-05 11:27 ` Richard Guenther
2007-11-07  7:52   ` Designs for better debug info in GCC (was: Re: [vta] don't let debug insns get in the way of simple vect reduction) Alexandre Oliva
2007-11-07 16:16     ` Ian Lance Taylor
2007-11-07 19:11       ` Designs for better debug info in GCC Alexandre Oliva
2007-11-07 22:57         ` Ian Lance Taylor
2007-11-07 23:05           ` Daniel Jacobowitz
2007-11-08  0:00           ` Mark Mitchell
2007-11-08  0:15             ` David Edelsohn
2007-11-08  0:35               ` Mark Mitchell
2007-11-08  5:14                 ` Alexandre Oliva
2007-11-08 18:28                   ` Alexandre Oliva
2007-11-22 23:07                 ` Frank Ch. Eigler
2007-11-22 23:13                   ` Richard Guenther
2007-11-23 20:53                     ` Frank Ch. Eigler
2007-11-24  1:53                       ` Alexandre Oliva
2007-11-24 15:02                     ` Robert Dewar
2007-11-08  5:15               ` Alexandre Oliva
2007-11-08 18:18                 ` Alexandre Oliva
2007-11-08 19:46                 ` Andrew Pinski
2007-11-08 20:39                   ` Alexandre Oliva
2007-11-09  8:39                   ` Robert Dewar
2007-11-08  5:44             ` Alexandre Oliva
2007-11-08 18:37               ` Alexandre Oliva
2007-11-08 19:13               ` Mark Mitchell
2007-11-08 19:13                 ` David Daney
2007-11-08 19:17                   ` Mark Mitchell
2007-11-09  2:09                 ` Alexandre Oliva
2007-11-12  4:49                   ` Mark Mitchell
2007-11-12 18:45                     ` Alexandre Oliva
2007-11-12 18:49                       ` Joe Buck
2007-11-25  6:57                         ` Alexandre Oliva
2007-11-25 12:09                           ` Richard Kenner
2007-11-12 18:53                       ` Ian Lance Taylor
2007-11-24  2:12                         ` Alexandre Oliva
2007-11-13 10:30                       ` Mark Mitchell
2007-11-24  1:54                         ` Alexandre Oliva
2007-11-13 15:30                       ` Michael Matz
2007-11-24  2:00                         ` Alexandre Oliva
2007-11-26 21:01                           ` Michael Matz
2007-11-27  5:31                             ` Alexandre Oliva
2007-11-27 20:31                               ` Michael Matz
2007-11-27 21:44                                 ` Alexandre Oliva
2007-11-08  9:54             ` Richard Guenther
2007-11-08  5:01           ` Alexandre Oliva
2007-11-08 18:15             ` Alexandre Oliva
2007-11-08 19:13             ` Ian Lance Taylor
2007-11-08 20:27               ` Alexandre Oliva
2007-11-08 21:26                 ` Ian Lance Taylor
2007-11-09  9:53                   ` Robert Dewar
2007-11-12  5:36                     ` Mark Mitchell
2007-11-12 17:34                       ` Alexandre Oliva
2007-11-12 17:54                         ` Mark Mitchell
2007-11-24  1:55                           ` Alexandre Oliva
2007-11-26  1:08                             ` Mark Mitchell
2007-12-05 14:22                               ` Diego Novillo
2007-12-05 22:10                                 ` Joe Buck
2007-12-15 21:41                                 ` Alexandre Oliva
2007-12-16  3:15                                   ` Daniel Berlin
2007-12-16 13:09                                     ` Alexandre Oliva
2007-12-17  1:27                                       ` Daniel Berlin
2007-12-17  4:20                                         ` Joe Buck
2007-12-17  8:13                                           ` Geert Bosch
2007-12-18  1:24                                             ` Alexandre Oliva
2007-12-18  1:29                                               ` Joe Buck
2007-12-18  4:40                                                 ` Alexandre Oliva
2007-12-18  7:42                                                   ` Robert Dewar
2007-12-18  8:09                                                     ` Alexandre Oliva
2007-12-18 14:01                                                       ` Robert Dewar
2007-12-18 21:20                                                         ` Alexandre Oliva
2007-12-18  7:35                                               ` Robert Dewar
2007-12-18  8:34                                                 ` Alexandre Oliva
2007-12-17 18:36                                           ` Alexandre Oliva
2007-12-17 17:59                                         ` Alexandre Oliva
2007-12-17 18:02                                           ` Diego Novillo
2007-12-17 20:34                                             ` Alexandre Oliva
2007-12-17 20:45                                               ` Diego Novillo
2007-12-18  1:02                                                 ` Alexandre Oliva
2007-12-18  1:14                                                   ` Diego Novillo
2007-12-18  5:21                                                     ` Alexandre Oliva
2007-12-18  9:10                                                       ` Alexandre Oliva
2007-12-18 13:20                                                         ` Diego Novillo
2007-12-18 15:42                                                           ` Alexandre Oliva
2007-12-18 22:43                                                         ` Daniel Berlin
2007-12-19  6:07                                                           ` Alexandre Oliva
2007-12-19  8:39                                                             ` Daniel Berlin
2007-12-19 16:12                                                               ` Daniel Berlin
2007-12-19 16:36                                                                 ` Andrew MacLeod
2007-12-19 19:49                                                                   ` Daniel Berlin
2007-12-19 20:00                                                                 ` Andrew MacLeod
2007-12-19 20:57                                                                   ` Daniel Berlin
2007-12-19 20:07                                                                 ` Alexandre Oliva
2007-12-19 22:00                                                                   ` Daniel Berlin
2007-12-20  9:26                                                                     ` Alexandre Oliva
2007-12-20 17:04                                                                       ` Ian Lance Taylor
2007-12-20 20:53                                                                         ` Alexandre Oliva
2007-12-19 20:27                                                               ` Alexandre Oliva
2007-12-18 23:35                                                         ` Daniel Berlin
2007-12-19  5:50                                                           ` Alexandre Oliva
2007-12-19 16:35                                                             ` Daniel Berlin
2007-12-19 19:46                                                               ` Alexandre Oliva
2007-12-19 20:39                                                                 ` Daniel Jacobowitz
2007-12-31 15:40                                               ` Richard Guenther
2007-12-16 21:42                                   ` Mark Mitchell
2007-11-09  9:55                   ` Seongbae Park (박성배, 朴成培)
2007-11-09 11:08                     ` Robert Dewar
2007-11-08  8:58           ` Paolo Bonzini
2007-11-07 17:20     ` Designs for better debug info in GCC (was: Re: [vta] don't let debug insns get in the way of simple vect reduction) Michael Matz
2007-11-07 18:45       ` Alexandre Oliva [this message]
2007-11-08 10:23         ` Designs for better debug info in GCC Michael Matz
2007-11-08 14:02           ` Robert Dewar
2007-11-08 15:13             ` H.J. Lu
2007-11-08 16:11             ` Michael Matz
2007-11-08 17:48               ` Alexandre Oliva
2007-11-09 12:46                 ` Michael Matz
2007-11-12 18:31                   ` Alexandre Oliva
2007-11-13 13:56                     ` Michael Matz
2007-11-24  2:34                       ` Alexandre Oliva
2007-11-26 20:56                         ` Michael Matz
2007-11-27  5:30                           ` Alexandre Oliva
2007-11-08 16:37             ` Alexandre Oliva
2007-11-09  1:26               ` Joe Buck
2007-11-09 14:53                 ` Daniel Jacobowitz
2007-11-09 17:06                   ` Robert Dewar
2007-11-09  1:26               ` Robert Dewar
2007-11-12 16:56                 ` Alexandre Oliva
2007-11-08 16:32           ` Alexandre Oliva
2007-11-12 21:04 Steven Bosscher
2007-11-24  1:37 ` Alexandre Oliva
2007-11-24  2:35   ` Steven Bosscher
2007-11-24 15:08     ` Alexandre Oliva
2007-11-24 15:18       ` Richard Kenner
2007-11-24 20:11         ` Alexandre Oliva
2007-11-24 20:46           ` Bernd Schmidt
2007-11-25  0:42             ` Alexandre Oliva
2007-11-25  7:19               ` Richard Guenther
2007-11-25 14:30                 ` Alexandre Oliva
2007-11-25 14:46                   ` Richard Guenther
2007-11-26 10:11                     ` Alexandre Oliva
2007-11-26 12:26                       ` Richard Guenther
2007-11-26 18:58                         ` Alexandre Oliva
2007-11-25 14:22               ` Alexandre Oliva
2007-11-24 20:48           ` Richard Kenner
2007-11-25  0:02             ` Alexandre Oliva
2007-11-25 14:23           ` Robert Dewar
2007-12-15 20:32             ` Alexandre Oliva
2007-12-15 21:41               ` Robert Dewar
2007-11-24 16:45       ` Steven Bosscher
2007-11-24 18:50         ` Alexandre Oliva
2007-11-24 20:21           ` Richard Guenther

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=ork5otuc6w.fsf@oliva.athome.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=matz@suse.de \
    --cc=richard.guenther@gmail.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).