public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/43983]  New: var-tracking needlessly throws away location info for SRAed vars
@ 2010-05-04 15:11 jakub at gcc dot gnu dot org
  2010-05-04 15:13 ` [Bug debug/43983] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-04 15:11 UTC (permalink / raw)
  To: gcc-bugs

track_expr_p has:
4496  /* If this expression is really a debug alias of some other declaration,
we
4497     don't need to track this expression if the ultimate declaration is
4498     ignored.  */
4499  realdecl = expr;
4500  if (DECL_DEBUG_EXPR_IS_FROM (realdecl) && DECL_DEBUG_EXPR (realdecl))
4501    {
4502      realdecl = DECL_DEBUG_EXPR (realdecl);
4503      /* ??? We don't yet know how to emit DW_OP_piece for variable
4504         that has been SRA'ed.  */
4505      if (!DECL_P (realdecl))
4506        return 0;
4507    }

I'd say if the DECL_DEBUG_EXPR is a COMPONENT_REF, ARRAY_REF etc. from a
reasonably short type, the easiest thing would be just to let var-tracking
track the individual vars and let dwarf2out_var_location assemble them
together.


-- 
           Summary: var-tracking needlessly throws away location info for
                    SRAed vars
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
@ 2010-05-04 15:13 ` jakub at gcc dot gnu dot org
  2010-05-05 15:22 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-04 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2010-05-04 15:12 -------
Sample testcase:
struct A { int i; int j; };

int
foo (int k)
{
  struct A a = { 4, k + 6 };
  asm ("" : "+r" (a.i));
  a.j++;
  bar (a.i);
  bar (a.j);
  return a.i + a.j;
}


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-05-04 15:12:44
               date|                            |


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
  2010-05-04 15:13 ` [Bug debug/43983] " jakub at gcc dot gnu dot org
@ 2010-05-05 15:22 ` jakub at gcc dot gnu dot org
  2010-05-05 19:07 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-05 15:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2010-05-05 15:22 -------
Created an attachment (id=20563)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20563&action=view)
gcc46-pr43983.patch

So far only lightly tested patch.


-- 


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
  2010-05-04 15:13 ` [Bug debug/43983] " jakub at gcc dot gnu dot org
  2010-05-05 15:22 ` jakub at gcc dot gnu dot org
@ 2010-05-05 19:07 ` jakub at gcc dot gnu dot org
  2010-05-05 20:03 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-05 19:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2010-05-05 19:06 -------
Two issues discovered with the patch.  One is easy:
--- gcc/dwarf2out.c 2010-05-05 17:14:56.000000000 +0200
+++ gcc/dwarf2out.c 2010-05-05 20:51:40.000000000 +0200
@@ -7916,7 +7916,7 @@
                {
                  rtx piece = *piece_loc;
                  diff -= decl_piece_bitsize (piece);
-                 piece_loc = &XEXP (piece, 1);
+                 *piece_loc = XEXP (piece, 1);
                  free_EXPR_LIST_node (piece);
                }
              /* Add padding if needed.  */

The other shows on various libgcc files with -m32 - apparently SRA leaves
sometimes the original decl in the IL together with SRAed variables, the patch
assumed that either the SRAed variables, or the original appear, but not both.


-- 


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-05-05 19:07 ` jakub at gcc dot gnu dot org
@ 2010-05-05 20:03 ` rguenth at gcc dot gnu dot org
  2010-05-06  8:45 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-05 20:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-05-05 20:02 -------
(In reply to comment #3)
> Two issues discovered with the patch.  One is easy:
> --- gcc/dwarf2out.c 2010-05-05 17:14:56.000000000 +0200
> +++ gcc/dwarf2out.c 2010-05-05 20:51:40.000000000 +0200
> @@ -7916,7 +7916,7 @@
>                 {
>                   rtx piece = *piece_loc;
>                   diff -= decl_piece_bitsize (piece);
> -                 piece_loc = &XEXP (piece, 1);
> +                 *piece_loc = XEXP (piece, 1);
>                   free_EXPR_LIST_node (piece);
>                 }
>               /* Add padding if needed.  */
> 
> The other shows on various libgcc files with -m32 - apparently SRA leaves
> sometimes the original decl in the IL together with SRAed variables, the patch
> assumed that either the SRAed variables, or the original appear, but not both.

It indeed happens on purpose.  We in some cases re-build the aggregate
for aggregate uses.


-- 


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-05-05 20:03 ` rguenth at gcc dot gnu dot org
@ 2010-05-06  8:45 ` jakub at gcc dot gnu dot org
  2010-05-13 10:41 ` jakub at gcc dot gnu dot org
  2010-05-13 10:53 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-06  8:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2010-05-06 08:44 -------
Created an attachment (id=20578)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20578&action=view)
gcc46-pr43983.patch

Updated patch that should fix both issues, currently bootstrapping/regtesting
it.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #20563|0                           |1
        is obsolete|                            |


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-05-06  8:45 ` jakub at gcc dot gnu dot org
@ 2010-05-13 10:41 ` jakub at gcc dot gnu dot org
  2010-05-13 10:53 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-13 10:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2010-05-13 10:41 -------
Subject: Bug 43983

Author: jakub
Date: Thu May 13 10:40:51 2010
New Revision: 159357

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159357
Log:
        PR debug/43983
        * var-tracking.c (track_expr_p): Allow tracking of variables optimized
        by SRA.
        * Makefile.in (dwarf2out.o): Depend on $(TREE_FLOW_H).
        * tree-sra.c (create_access_replacement): Call unshare_expr before
        passing expr to SET_DECL_DEBUG_EXPR, and remove any SSA_NAMEs from
        it.
        * dwarf2out.c: Include tree-flow.h.
        (struct var_loc_node): Rename var_loc_note field to loc, add comment.
        (size_of_loc_descr, output_loc_operands, output_loc_operands_raw):
        Handle DW_OP_bit_piece.
        (decl_piece_bitsize, decl_piece_varloc_ptr, decl_piece_node,
        construct_piece_list, adjust_piece_list): New functions.
        (add_var_loc_to_decl): Handle SRA optimized variables.
        Adjust for var_loc_note to loc field renaming.
        (dw_loc_list_1): For WANT_ADDRESS == 2 prefer DECL_MODE of decl
        in VAR_LOCATION note.
        (new_loc_descr_op_bit_piece): New function.
        (dw_sra_loc_expr): New function.
        (dw_loc_list): Use it.  Don't handle the last range after the
        loop, handle it inside of the loop.  Adjust for var_loc_note
        to loc field renaming.
        (add_location_or_const_value_attribute): Only special case
        single entry loc lists if loc is NOTE_P.  Adjust for
        var_loc_note to loc field renaming.
        (dwarf2out_var_location): Don't set newloc->var_loc_note
        and newloc->next here.

        * gcc.dg/guality/sra-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/guality/sra-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c
    trunk/gcc/var-tracking.c


-- 


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


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

* [Bug debug/43983] var-tracking needlessly throws away location info for SRAed vars
  2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-05-13 10:41 ` jakub at gcc dot gnu dot org
@ 2010-05-13 10:53 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-13 10:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2010-05-13 10:53 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2010-05-13 10:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-04 15:11 [Bug debug/43983] New: var-tracking needlessly throws away location info for SRAed vars jakub at gcc dot gnu dot org
2010-05-04 15:13 ` [Bug debug/43983] " jakub at gcc dot gnu dot org
2010-05-05 15:22 ` jakub at gcc dot gnu dot org
2010-05-05 19:07 ` jakub at gcc dot gnu dot org
2010-05-05 20:03 ` rguenth at gcc dot gnu dot org
2010-05-06  8:45 ` jakub at gcc dot gnu dot org
2010-05-13 10:41 ` jakub at gcc dot gnu dot org
2010-05-13 10:53 ` jakub at gcc dot gnu dot 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).