public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides.
@ 2011-12-12 21:58 nikolay at totalviewtech dot com
  2011-12-13 11:21 ` [Bug debug/51517] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: nikolay at totalviewtech dot com @ 2011-12-12 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51517
           Summary: [4.4 regression ] Wrong debug information for pointers
                    with negative strides.
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nikolay@totalviewtech.com


Created attachment 26062
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26062
Example to demostrate

Consider attached examples, pointer ip: 
integer, dimension (:), pointer :: ip

If you associate it twice for two variables, 
.....
ip   => it  (10:1:-2)
.... 
ip    => unpleasant%small_pad

than stride calculated as zero
 <2><b2>: Abbrev Number: 7 (DW_TAG_variable)
     DW_AT_name        : ip    
     DW_AT_decl_file   : 1    
     DW_AT_decl_line   : 8    
     DW_AT_type        : <165>    
     DW_AT_location    : 3 byte block: 91 b0 7e     (DW_OP_fbreg: -208)
 <1><165>: Abbrev Number: 15 (DW_TAG_array_type)
     DW_AT_data_location: 2 byte block: 97 6     (DW_OP_push_object_address;
DW_OP_deref)
     DW_AT_associated  : 4 byte block: 97 6 30 2e    
(DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
     DW_AT_type        : <60>    
     DW_AT_sibling     : <189>
 <2><176>: Abbrev Number: 14 (DW_TAG_subrange_type)
     DW_AT_lower_bound : 4 byte block: 97 23 20 6    
(DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
     DW_AT_upper_bound : 4 byte block: 97 23 28 6    
(DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
     DW_AT_stride      : 6 byte block: 97 23 18 6 30 1e    
(DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_lit0;
DW_OP_mul)

I think error is in: DW_OP_lit0. Should be something like DW_OP_lit2

This is regression from 4.4 and is broken in 4.5 and 4.6

I have attached an example that you can compile and verify.


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

* [Bug debug/51517] [4.5/4.6/4.7 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
@ 2011-12-13 11:21 ` rguenth at gcc dot gnu.org
  2011-12-14 14:37 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-13 11:21 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.4.6
   Target Milestone|---                         |4.5.4
            Summary|[4.4 regression ] Wrong     |[4.5/4.6/4.7 Regression]
                   |debug information for       |Wrong debug information for
                   |pointers with negative      |pointers with negative
                   |strides.                    |strides.


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

* [Bug debug/51517] [4.5/4.6/4.7 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
  2011-12-13 11:21 ` [Bug debug/51517] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
@ 2011-12-14 14:37 ` jakub at gcc dot gnu.org
  2011-12-14 15:20 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-14 14:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-14
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |matz at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-14 14:33:50 UTC ---
There are multiple issues here:
1) the fortran FE adds DECL_INITIAL to the span variable, which doesn't make
any
sense for an automatic variable (and isn't needed for TREE_STATIC either,
because
those are initialized to 0 by default).

--- gcc/fortran/trans-decl.c.jj    2011-12-11 22:02:37.000000000 +0100
+++ gcc/fortran/trans-decl.c    2011-12-14 15:20:03.656835603 +0100
@@ -1434,7 +1434,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       gfc_finish_var_decl (span, sym);
       TREE_STATIC (span) = TREE_STATIC (decl);
       DECL_ARTIFICIAL (span) = 1;
-      DECL_INITIAL (span) = build_int_cst (gfc_array_index_type, 0);

       GFC_DECL_SPAN (decl) = span;
       GFC_TYPE_ARRAY_SPAN (TREE_TYPE (decl)) = span;

If the FE wants to initialize the span.N variable to zero when it is not
TREE_STATIC, it really should add a statement to a right spot that initializes
it to 0, having DECL_INITIAL does nothing and just confuses dwarf2out.

2) for some reason the span.0 variable doesn't get DECL_RTL during expansion,
actually it gets it to one MEM location for the span.0_?? = 4; store and a
different location for the span.0_?? = 44; store:
      /* For the benefit of debug information at -O0 (where vartracking
         doesn't run) record the place also in the base DECL if it's
         a normal variable (not a parameter).  */
      if (x && x != pc_rtx && TREE_CODE (SSA_NAME_VAR (t)) == VAR_DECL)
        {
          tree var = SSA_NAME_VAR (t);
          /* If we don't yet have something recorded, just record it now.  */
          if (!DECL_RTL_SET_P (var))
            SET_DECL_RTL (var, x);
          /* If we have it set already to "multiple places" don't
             change this.  */
          else if (DECL_RTL (var) == pc_rtx)
            ;
          /* If we have something recorded and it's not the same place
             as we want to record now, we have multiple partitions for the
             same base variable, with different places.  We can't just
             randomly chose one, hence we have to say that we don't know.
             This only happens with optimization, and there var-tracking
             will figure out the right thing.  */
          else if (DECL_RTL (var) != x)
            SET_DECL_RTL (var, pc_rtx);
        }

Apparently we have multiple partitions for the same base variable at -O0 :(.
The variable is !DECL_IGNORED_P, although it is DECL_ARTIFICIAL.
Micha, any ideas why it got two partitions instead of just one as expected?

The 1) patch would turn this from invalid debug info into valid, but
incomplete, debug info.  Figuring out 2) would supposedly turn it into valid
complete debug info.
And, one would hope that if/when the array descriptor format finally changes
(is it now scheduled for 4.8, or later?) and stride will be in bytes rather
than whatever units it currently is, this span.N stuff will be no longer
needed.


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

* [Bug debug/51517] [4.5/4.6/4.7 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
  2011-12-13 11:21 ` [Bug debug/51517] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
  2011-12-14 14:37 ` jakub at gcc dot gnu.org
@ 2011-12-14 15:20 ` jakub at gcc dot gnu.org
  2011-12-15 11:09 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-14 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

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 #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-14 15:14:22 UTC ---
Created attachment 26081
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26081
gcc47-pr51517.patch

Untested fix.

OT, can anyone please explain the following in trans-decl.c
(gfc_trans_deferred_vars):

      else if ((!sym->attr.dummy || sym->ts.deferred)
                && (sym->ts.type == BT_CLASS
                && CLASS_DATA (sym)->attr.pointer))
        break;

?  The break there will IMHO just cause the rest of the *->tlink chain deferred
vars not to be processed at all, is that the right thing to do?  continue; or ;
would make much more sense to me...


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

* [Bug debug/51517] [4.5/4.6/4.7 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
                   ` (2 preceding siblings ...)
  2011-12-14 15:20 ` jakub at gcc dot gnu.org
@ 2011-12-15 11:09 ` jakub at gcc dot gnu.org
  2011-12-15 11:11 ` [Bug debug/51517] [4.5/4.6 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-15 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-15 11:05:42 UTC ---
Author: jakub
Date: Thu Dec 15 11:05:37 2011
New Revision: 182362

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182362
Log:
    PR debug/51517
    * trans-decl.c (gfc_get_symbol_decl): Don't set DECL_INITAL on span.
    (gfc_trans_deferred_vars): Instead add its runtime initialization
    here.

    * tree-ssa-coalesce.c (coalesce_ssa_name): For !optimize, test
    !DECL_IGNORED_P instead of !DECL_ARTIFICIAL.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/tree-ssa-coalesce.c


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

* [Bug debug/51517] [4.5/4.6 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
                   ` (3 preceding siblings ...)
  2011-12-15 11:09 ` jakub at gcc dot gnu.org
@ 2011-12-15 11:11 ` jakub at gcc dot gnu.org
  2012-02-09 17:14 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-15 11:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.5/4.6/4.7 Regression]    |[4.5/4.6 Regression] Wrong
                   |Wrong debug information for |debug information for
                   |pointers with negative      |pointers with negative
                   |strides.                    |strides.

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-15 11:09:09 UTC ---
Fixed on the trunk so far.


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

* [Bug debug/51517] [4.5/4.6 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
                   ` (4 preceding siblings ...)
  2011-12-15 11:11 ` [Bug debug/51517] [4.5/4.6 " jakub at gcc dot gnu.org
@ 2012-02-09 17:14 ` jakub at gcc dot gnu.org
  2012-06-20 13:12 ` [Bug debug/51517] [4.5 " rguenth at gcc dot gnu.org
  2012-07-02 10:20 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-09 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-09 17:13:57 UTC ---
Author: jakub
Date: Thu Feb  9 17:13:50 2012
New Revision: 184048

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184048
Log:
    Backported from mainline
    2011-12-15  Jakub Jelinek  <jakub@redhat.com>

    PR debug/51517
    * tree-ssa-coalesce.c (coalesce_ssa_name): For !optimize, test
    !DECL_IGNORED_P instead of !DECL_ARTIFICIAL.

    * trans-decl.c (gfc_get_symbol_decl): Don't set DECL_INITAL on span.
    (gfc_trans_deferred_vars): Instead add its runtime initialization
    here.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_6-branch/gcc/tree-ssa-coalesce.c


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

* [Bug debug/51517] [4.5 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
                   ` (5 preceding siblings ...)
  2012-02-09 17:14 ` jakub at gcc dot gnu.org
@ 2012-06-20 13:12 ` rguenth at gcc dot gnu.org
  2012-07-02 10:20 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-20 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug debug/51517] [4.5 Regression] Wrong debug information for pointers with negative strides.
  2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
                   ` (6 preceding siblings ...)
  2012-06-20 13:12 ` [Bug debug/51517] [4.5 " rguenth at gcc dot gnu.org
@ 2012-07-02 10:20 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-02 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.5.4                       |4.6.3

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-02 10:20:06 UTC ---
Fixed in 4.6.3.


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

end of thread, other threads:[~2012-07-02 10:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12 21:58 [Bug debug/51517] New: [4.4 regression ] Wrong debug information for pointers with negative strides nikolay at totalviewtech dot com
2011-12-13 11:21 ` [Bug debug/51517] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-12-14 14:37 ` jakub at gcc dot gnu.org
2011-12-14 15:20 ` jakub at gcc dot gnu.org
2011-12-15 11:09 ` jakub at gcc dot gnu.org
2011-12-15 11:11 ` [Bug debug/51517] [4.5/4.6 " jakub at gcc dot gnu.org
2012-02-09 17:14 ` jakub at gcc dot gnu.org
2012-06-20 13:12 ` [Bug debug/51517] [4.5 " rguenth at gcc dot gnu.org
2012-07-02 10:20 ` rguenth 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).