public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/36690] [4.3/4.4 Regression] .debug_line first line is behind the first instruction
Date: Thu, 10 Jul 2008 12:02:00 -0000	[thread overview]
Message-ID: <20080710120115.23385.qmail@sourceware.org> (raw)
In-Reply-To: <bug-36690-12292@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from jakub at gcc dot gnu dot org  2008-07-10 12:01 -------
Created an attachment (id=15888)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15888&action=view)
gcc44-pr36690.patch

Unfinished patch which solves the testcase in this PR and a couple of other
problems, but still there are plenty of issues.

It adds goto_block field to edges, because sometimes an edge is the only place
that uses certain scope.  Consider say:
void bar (int);

void foo (int i)
{
  if (!i)
    bar (0);
  else
    {
      static int z = 5;
      goto f1;
    }
  bar (1);
f1:
  bar (2);
}
At -O0 -g we really should be able to put breakpoint on goto f1 and see the z
variable.  Another testcase I've been playing with is:
void
bar (int i)
{
}

void
foo (int i, int j)
{
  if (j)
    {
      bar (i + 1);
      goto f1;
    }
  bar (i + 2);
  goto f2;
f1:
  if (i > 10)
    goto f3;
f2:
  if (i > 40)
    goto f4;
  else
    goto f5;
f3:
  bar (i);
f4:
  bar (i);
f5:
  bar (i);
}

int
main (void)
{
  foo (0, 1);
  foo (11, 1);
  foo (21, 0);
  foo (41, 0);
  return 0;
}

Here IMNSHO at -O0 -g one should be able to step through all the gotos, so
there should be some instructions with the locations of the gotos.  With the
attached patch one goto gets a location in the assembly, but the rest don't. 
One problem
is that already the into_cfglayout pass does some optimizations I wouldn't
think are appropriate for -O0, like merging basic blocks.  That's e.g. where
the
goto_locus of goto f1; is gone.  Either we should prevent that kind of
optimization if (!optimize) and the edge has goto_locus, or e.g. could insert
a nop insn with goto_locus as INSN_LOCATOR and hope at -O0 nothing later on
optimizes that out.  Another problem is with the conditional branches.  For
them
I'm afraid we can't put goto_locus on the conditional jump.  If just one
edge has goto_locus and the other does not, at (!optimize) we could possibly
invert the condition and thus let the unconditional jump be the insn that
holds the goto_locus INSN_LOCATOR.  But for the case where both edges have
goto_locus, I think we should just insert an extra conditional jump, so that
there are two unconditional jumps, each with its goto_locus.


-- 


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


  parent reply	other threads:[~2008-07-10 12:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 15:35 [Bug debug/36690] New: " jan dot kratochvil at redhat dot com
2008-07-01 15:53 ` [Bug debug/36690] [4.3/4.4 Regression] " jsm28 at gcc dot gnu dot org
2008-07-02  9:23 ` jakub at gcc dot gnu dot org
2008-07-10 12:02 ` jakub at gcc dot gnu dot org [this message]
2008-07-10 13:44 ` hubicka at ucw dot cz
2008-07-10 14:28 ` rguenth at gcc dot gnu dot org
2008-08-27 22:13 ` jsm28 at gcc dot gnu dot org
2008-10-03  8:56 ` jakub at gcc dot gnu dot org
2008-10-07 18:51 ` jakub at gcc dot gnu dot org
2008-10-07 19:02 ` jakub at gcc dot gnu dot org
2008-10-10  7:29 ` cnstar9988 at gmail dot com
2008-11-21 23:49 ` pinskia at gcc dot gnu dot 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=20080710120115.23385.qmail@sourceware.org \
    --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).