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/47858] [4.5/4.6/4.7 Regression] IPA-SRA decreases quality of debug info
Date: Thu, 02 Jun 2011 12:23:00 -0000	[thread overview]
Message-ID: <bug-47858-4-iqTqMTid3V@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47858-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-02 12:21:51 UTC ---
Created attachment 24416
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24416
gcc47-pr47858.patch

Work in progress patch, so far just for the callee side only and not hooked
into IPA-SRA etc. too much.

main testcase used is:
volatile int vv;

static __attribute__((noinline)) int
f1 (int x, int y, int z)
{
  int a = x * 2;
  int b = y * 2;
  int c = z * 2;
  vv++;
  return x + z;
}

int
u1 (int x)
{
  return f1 (x, 2, 3) + f1 (x, 4, 3) + f1 (x + 6, x, 3) + x;
}

The main changes of this patch which I'd like to discuss are:
1) introduction of new debug stmt kind, DEBUG_SOURCE_BIND (something like
   we talked about on IRC, except due to use of the subcode we can't have flags
   and thus it is a new kind).  It has the source mapping semantics,
   so for GIMPLE POV is considered as a black box statement, which doesn't use
   anything.
   Alternatively, we could have a new tree which would embed a decl in it,
stand
   for black box and not be considered any kind of use.
2) remap_ssa_name creates these s=> debug stmts if possible instead of
resetting
   (replaces with D#N temporary set by s=>)
These two things alone fix the testcase in this comment with -g -O2
-fno-ipa-sra, during expansion it is expanded as ENTRY_VALUE and var-tracking
figures out it is even still available in a register.
For -O2 -g -fipa-sra, for b variable this offers a part of solution, in
particular:
3) add DW_OP_GNU_parameter_ref op, which references the artificial
DW_TAG_formal_parameter and corresponding DEBUG_PARAMETER_REF rtl
We should emit DEBUG y s=> y too when optimizing away the parameter so that the
parameter gets DW_OP_GNU_parameter_ref too (or alternatively expansion could
add those automatically for optimized away parameters directly in the form of
debug insn).

The original testcase from kernel needs __attribute__((noinline)) now on
may_create, otherwise it is inlined and doesn't test the interesting case.
And, for better coverage there should be struct dentry *child2 = child; or
similar at the start of may_create too, to also test vars whose value is
related to the optimized away parameter.  Again, some more work is needed not
to reset the # DEBUG child2 => child_2(D) stmt during eipa_sra, but instead add
# DEBUG D#N s=> child
# DEBUG child2 => D#N
and either again add it for the child parameter too
# DEBUG child s=> child
or handle it during expansion.

That is only the first part of the solution, there needs to be matching
DW_TAG_GNU_call_site_parameter with DW_AT_abstract_origin of the decl which
DW_OP_GNU_parameter_def will reference, with the right value.

This could be either again some special debug stmt kind before the call, or
perhaps could be just the call stmt itself taking DEBUG_EXPR_DECLs as extra
arguments (either normal args, but there is some risk of breaking various
passes), or say setting a flag in GIMPLE_CALL's subcode that it has
DEBUG_EXPR_DECL arguments and if it does, call some slower gimple_call_num_args
variant which would omit from the call DEBUG_EXPR_DECLs at the end.
At RTL level this could be e.g. represented by having DEBUG_EXPRs in
CALL_INSN_FUNCTION_USAGE.  So, we would have say:
  # DEBUG D#7 => 2
  D.2696_2 = f1.isra.0 (x_1(D), 3 [, D#7]);
  # DEBUG D#8 => 4
  D.2697_3 = f1.isra.0 (x_1(D), 3 [, D#8]);
  D.2698_4 = D.2696_2 + D.2697_3;
  D.2699_5 = x_1(D) + 6;
  # DEBUG D#9 => x_1(D)
  D.2700_6 = f1.isra.0 (D.2699_5, 3 [, D#9]);


  parent reply	other threads:[~2011-06-02 12:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 14:01 [Bug debug/47858] New: [4.5/4.6 " jakub at gcc dot gnu.org
2011-02-23 15:51 ` [Bug debug/47858] " rguenth at gcc dot gnu.org
2011-02-24 13:59 ` aoliva at gcc dot gnu.org
2011-03-02 12:47 ` jakub at gcc dot gnu.org
2011-04-28 15:38 ` [Bug debug/47858] [4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2011-06-02 12:23 ` jakub at gcc dot gnu.org [this message]
2011-06-03 10:46 ` jakub at gcc dot gnu.org
2011-06-07 15:44 ` jakub at gcc dot gnu.org
2011-06-22 10:43 ` jakub at gcc dot gnu.org
2011-11-28 15:34 ` 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-47858-4-iqTqMTid3V@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).