public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments
@ 2020-05-26 18:25 jamborm at gcc dot gnu.org
  2020-05-26 18:28 ` [Bug debug/95343] IPA-SRA can result in wrong " jamborm at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-05-26 18:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

            Bug ID: 95343
           Summary: IPA-SRA can result in bad debug info about removed
                    function arguments
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamborm at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-linux
            Target: x86_64-linux

Created attachment 48608
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48608&action=edit
Testcase

ipa_param_adjustments::modify_call does not properly account for extra
arguments left over from clone materialization when recording debug
info.  Therefore, when the attached testcase is compiled with -O2 or
higher and run in gdb with a breakpoint is set at line 20 where we
examine the value of parameter i, it incorrectly reports 4, even
though it should be 2.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
@ 2020-05-26 18:28 ` jamborm at gcc dot gnu.org
  2020-05-26 18:36 ` jamborm at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-05-26 18:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jamborm at gcc dot gnu.org
            Summary|IPA-SRA can result in bad   |IPA-SRA can result in wrong
                   |debug info about removed    |debug info about removed
                   |function arguments          |function arguments
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2020-05-26
     Ever confirmed|0                           |1

--- Comment #1 from Martin Jambor <jamborm at gcc dot gnu.org> ---
The simplest fix which will make i reported as "optimized out" is the
following.  But I am testing a patch which can make gdb actually show
the correct 4.  Still, the following is usable for gcc 10 if the full
patch is deemed too risky:

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 978916057f0..2a04f7b3ce5 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -787,7 +787,12 @@ ipa_param_adjustments::modify_call (gcall *stmt,
          if (!is_gimple_reg (old_parm) || kept[i])
            continue;
          tree origin = DECL_ORIGIN (old_parm);
-         tree arg = gimple_call_arg (stmt, i);
+         int index;
+         if (transitive_remapping)
+           index = index_map[i];
+         else
+           index = i;
+         tree arg = gimple_call_arg (stmt, index);

          if (!useless_type_conversion_p (TREE_TYPE (origin), TREE_TYPE (arg)))
            {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
  2020-05-26 18:28 ` [Bug debug/95343] IPA-SRA can result in wrong " jamborm at gcc dot gnu.org
@ 2020-05-26 18:36 ` jamborm at gcc dot gnu.org
  2020-05-28 12:38 ` jamborm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-05-26 18:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Martin Jambor from comment #1)
> ...I am testing a patch which can make gdb actually show
> the correct 4. 

I meant the correct value 2, of course.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
  2020-05-26 18:28 ` [Bug debug/95343] IPA-SRA can result in wrong " jamborm at gcc dot gnu.org
  2020-05-26 18:36 ` jamborm at gcc dot gnu.org
@ 2020-05-28 12:38 ` jamborm at gcc dot gnu.org
  2020-07-02 12:31 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-05-28 12:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

--- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I have proposed a patch series on the mailing list to address PR 93385 and the
last patch in it also addresses this issue and allows gdb to print the correct
value of the removed parameter:

https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546705.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-05-28 12:38 ` jamborm at gcc dot gnu.org
@ 2020-07-02 12:31 ` cvs-commit at gcc dot gnu.org
  2020-07-03 12:51 ` cvs-commit at gcc dot gnu.org
  2021-02-17 16:23 ` jamborm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-02 12:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:053c88093a45f175f446eda009f3312e4e508514

commit r11-1787-g053c88093a45f175f446eda009f3312e4e508514
Author: Martin Jambor <mjambor@suse.cz>
Date:   Thu Jul 2 14:30:50 2020 +0200

    ipa-sra: Prevent constructing debug info from wrong argument

    The mechanism generating debug info for removed parameters did not
    adjust index of the argument in the call statement to take into
    account extra arguments IPA-SRA might have produced when splitting a
    strucutre.  This patch addresses that omission and stops gdb from
    showing incorrect value for the removed parameter and says "value
    optimized out" instead.  The guality testcase will end up as
    UNSUPPORTED in the results which is how Richi told me on IRC we deal
    with this.

    It is possible to generate debug info to actually show the value of
    the removed parameter but so far my approaches to do just that seem
    toocontroversial
    (https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546705.html), so
    before I come up with something better I'd like to push this to master
    and the gcc-10 branch in time for the GCC 10.2 release.

    gcc/ChangeLog:

    2020-07-01  Martin Jambor  <mjambor@suse.cz>

            PR debug/95343
            * ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
Adjust
            argument index if necessary.

    gcc/testsuite/ChangeLog:

    2020-07-01  Martin Jambor  <mjambor@suse.cz>

            PR debug/95343
            * gcc.dg/guality/pr95343.c: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-07-02 12:31 ` cvs-commit at gcc dot gnu.org
@ 2020-07-03 12:51 ` cvs-commit at gcc dot gnu.org
  2021-02-17 16:23 ` jamborm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-03 12:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Martin Jambor
<jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:61e4ee3f2c0e3d77602c87866cd5c0cfb81d5da2

commit r10-8421-g61e4ee3f2c0e3d77602c87866cd5c0cfb81d5da2
Author: Martin Jambor <mjambor@suse.cz>
Date:   Fri Jul 3 14:51:02 2020 +0200

    ipa-sra: Prevent constructing debug info from wrong argument

    The mechanism generating debug info for removed parameters did not
    adjust index of the argument in the call statement to take into
    account extra arguments IPA-SRA might have produced when splitting a
    strucutre.  This patch addresses that omission and stops gdb from
    showing incorrect value for the removed parameter and says "value
    optimized out" instead.  The guality testcase will end up as
    UNSUPPORTED in the results which is how Richi told me on IRC we deal
    with this.

    It is possible to generate debug info to actually show the value of
    the removed parameter but so far my approaches to do just that seem
    toocontroversial
    (https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546705.html), so
    before I come up with something better I'd like to push this to master
    and the gcc-10 branch in time for the GCC 10.2 release.

    gcc/ChangeLog:

    2020-07-01  Martin Jambor  <mjambor@suse.cz>

            PR debug/95343
            * ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
Adjust
            argument index if necessary.

    gcc/testsuite/ChangeLog:

    2020-07-01  Martin Jambor  <mjambor@suse.cz>

            PR debug/95343
            * gcc.dg/guality/pr95343.c: New test.

    (cherry picked from commit 053c88093a45f175f446eda009f3312e4e508514)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/95343] IPA-SRA can result in wrong debug info about removed function arguments
  2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-07-03 12:51 ` cvs-commit at gcc dot gnu.org
@ 2021-02-17 16:23 ` jamborm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2021-02-17 16:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95343

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
This bug is fixed, the debug info is no longer wrong, just also missing in
cases where we could actually provide it.  But that is a different thing, so
let me close this one.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-17 16:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 18:25 [Bug debug/95343] New: IPA-SRA can result in bad debug info about removed function arguments jamborm at gcc dot gnu.org
2020-05-26 18:28 ` [Bug debug/95343] IPA-SRA can result in wrong " jamborm at gcc dot gnu.org
2020-05-26 18:36 ` jamborm at gcc dot gnu.org
2020-05-28 12:38 ` jamborm at gcc dot gnu.org
2020-07-02 12:31 ` cvs-commit at gcc dot gnu.org
2020-07-03 12:51 ` cvs-commit at gcc dot gnu.org
2021-02-17 16:23 ` jamborm at gcc dot gnu.org

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).