public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Guenther" <richard.guenther@gmail.com>
To: "Alexandre Oliva" <aoliva@redhat.com>
Cc: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] New SSA variable mapping infrastructure
Date: Fri, 09 Nov 2007 11:55:00 -0000	[thread overview]
Message-ID: <84fc9c000711090153m32ec85fo760209f1a5375603@mail.gmail.com> (raw)
In-Reply-To: <ord4uk711t.fsf@oliva.athome.lsd.ic.unicamp.br>

On 11/9/07, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Nov  8, 2007, "Richard Guenther" <richard.guenther@gmail.com> wrote:
>
> > It would be nice to have a gdb testcase testing for not having this
> > wrong debug information - at least that would make it easier to
> > understand your point.
>
> Consider this:
>
> int foo(int i, int j) {
>   int l;
>   int k = 0;
>
>   l = function_that_returns_5 ();
>   breakpoint0 ();
>   asm ("" : : "X" (l)); /* ensure it's live */
>
>   l = j + i * 10;
>
>   if (i < j) {
>     k = i * 10;
>     breakpoint1();
>   } else
>     breakpoint2();
>   }
>
>   breakpoint3();
>
>   return l + k;
> }
>
> Set a breakpoint in all 3 breakpoint functions and, when you reach
> them, go up one frame and print k and l.
>
> With your design, the optimizations that completely drop the second
> assignment to l, leaving nothing behind to mark the death of the
> previous value, debug information will likely indicate that variable l
> still holds value 5 through to the end of the function, unless the
> location holding it is reused for some other purpose, the only case in
> which current var-tracking would realize l is no longer available
> there.

Right.  As optimization drops the second assignment to 'l' we only are
able to note that at the point we return from the function 'l' is computed
again:

foo (i, j)
{
  int k.6;
  int k;
  int l;

<bb 2>:
  l = function_that_returns_5 ();
  breakpoint0 ();
  __asm__ __volatile__(""::"X" l);
  k.6 = i * 10 E{ k };
  if (i < j)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  breakpoint1 ();
  k = k.6;
  goto <bb 5>;

<bb 4>:
  breakpoint2 ();
  k = 0;

<bb 5>:
  breakpoint3 ();
  return (j + k.6 E{ l }) + k;

}

And you are right, with our design-proposal there is no way to say that at the
point of the second assignment to 'l' (even if that is removed), the
name 'l' shall
be no longer associated with the constant '5'.

So indeed, it is very likely that in the debugger you would be able to print
'l' and get 5 at all breakpoint locations.  'k' will also print as i *
10 at at least
breakpoint1() and breakpoint2() (it will be "correct" at
breakpoint3()).  Basically
the constraints we can force on debug information is only that at the point of
a use of a name the location information will be correct.  I also don't see how
you can solve this problem without retaining placeholders for each DCEd
instruction (which is what you do).  So yes, your approach is vastly superior
in the sense of creating correct debug information for optimized code.

What our approach basically does is to identify all names that a computed value
has at any point during program execution.  All flow-sensitive information that
is not tracked we hope to recover (I see it's not possible to recover
all of it).

So we're obviously going to finish our approach to a point where you can try
it (that is, run gdb sessions on the improved output) and then put it
on a branch.

Richard.

  reply	other threads:[~2007-11-09  9:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-03 18:26 Richard Guenther
2007-10-04  6:27 ` Michael Matz
2007-11-07  8:29   ` Alexandre Oliva
2007-10-18 12:46 ` Paolo Bonzini
2007-11-07  8:14 ` Alexandre Oliva
2007-11-07 10:34   ` Richard Guenther
2007-11-07 19:29     ` Alexandre Oliva
2007-11-08  9:25       ` Richard Guenther
2007-11-08 17:25         ` Alexandre Oliva
2007-11-08 20:51           ` Richard Guenther
2007-11-09  1:11             ` Alexandre Oliva
2007-11-09 11:55               ` Richard Guenther [this message]
2007-11-12 18:40                 ` Alexandre Oliva
2007-11-13 11:13                   ` Richard Guenther
2007-11-25 11:23                     ` Alexandre Oliva
2007-11-25 13:38                       ` 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=84fc9c000711090153m32ec85fo760209f1a5375603@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=aoliva@redhat.com \
    --cc=gcc-patches@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).