OSDN Git Service

PR debug/43290
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Mar 2010 18:17:10 +0000 (18:17 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Mar 2010 18:17:10 +0000 (18:17 +0000)
* reg-notes.def (REG_CFA_SET_VDRAP): New note.
* dwarf2out.c (dwarf2out_frame_debug_expr): Remove rule 20 - setting
of fde->vdrap_reg.
(dwarf2out_frame_debug): Handle REG_CFA_SET_VDRAP note.
(based_loc_descr): Only express drap or vdrap regno based expressions
using DW_OP_fbreg when not optimizing.
* config/i386/i386.c (ix86_get_drap_rtx): When not optimizing,
make the vDRAP = DRAP assignment RTX_FRAME_RELATED_P and add
REG_CFA_SET_VDRAP note.

PR debug/36728
* gcc.dg/guality/pr36728-1.c: New test.
* gcc.dg/guality/pr36728-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157363 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/dwarf2out.c
gcc/reg-notes.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/pr36728-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/guality/pr36728-2.c [new file with mode: 0644]

index 55a998c..3ee158e 100644 (file)
@@ -1,3 +1,16 @@
+2010-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43290
+       * reg-notes.def (REG_CFA_SET_VDRAP): New note.
+       * dwarf2out.c (dwarf2out_frame_debug_expr): Remove rule 20 - setting
+       of fde->vdrap_reg.
+       (dwarf2out_frame_debug): Handle REG_CFA_SET_VDRAP note.
+       (based_loc_descr): Only express drap or vdrap regno based expressions
+       using DW_OP_fbreg when not optimizing.
+       * config/i386/i386.c (ix86_get_drap_rtx): When not optimizing,
+       make the vDRAP = DRAP assignment RTX_FRAME_RELATED_P and add
+       REG_CFA_SET_VDRAP note.
+
 2010-03-10  Alexander Monakov  <amonakov@ispras.ru>
 
        PR tree-optimization/43236
index 087c30f..5f560c4 100644 (file)
@@ -8382,7 +8382,7 @@ ix86_get_drap_rtx (void)
       unsigned int regno = find_drap_reg ();
       rtx drap_vreg;
       rtx arg_ptr;
-      rtx seq;
+      rtx seq, insn;
 
       arg_ptr = gen_rtx_REG (Pmode, regno);
       crtl->drap_reg = arg_ptr;
@@ -8391,8 +8391,13 @@ ix86_get_drap_rtx (void)
       drap_vreg = copy_to_reg (arg_ptr);
       seq = get_insns ();
       end_sequence ();
-
-      emit_insn_before (seq, NEXT_INSN (entry_of_function ()));
+      
+      insn = emit_insn_before (seq, NEXT_INSN (entry_of_function ()));
+      if (!optimize)
+       {
+         add_reg_note (insn, REG_CFA_SET_VDRAP, drap_vreg);
+         RTX_FRAME_RELATED_P (insn) = 1;
+       }
       return drap_vreg;
     }
   else
index 5aa9df4..4601444 100644 (file)
@@ -2160,15 +2160,7 @@ dwarf2out_frame_debug_cfa_restore (rtx reg, const char *label)
                && cfa.indirect == 0
                && cfa.reg != HARD_FRAME_POINTER_REGNUM
   effects: Use DW_CFA_def_cfa_expression to define cfa
-          cfa.reg == fde->drap_reg
-
-  Rule 20:
-  (set reg fde->drap_reg)
-  constraints: fde->vdrap_reg == INVALID_REGNUM
-  effects: fde->vdrap_reg = reg.
-  (set mem fde->drap_reg)
-  constraints: fde->drap_reg_saved == 1
-  effects: none.  */
+          cfa.reg == fde->drap_reg  */
 
 static void
 dwarf2out_frame_debug_expr (rtx expr, const char *label)
@@ -2239,24 +2231,6 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
 
   fde = current_fde ();
 
-  if (REG_P (src)
-      && fde
-      && fde->drap_reg == REGNO (src)
-      && (fde->drap_reg_saved
-         || REG_P (dest)))
-    {
-      /* Rule 20 */
-      /* If we are saving dynamic realign argument pointer to a
-        register, the destination is virtual dynamic realign
-        argument pointer.  It may be used to access argument.  */
-      if (REG_P (dest))
-       {
-         gcc_assert (fde->vdrap_reg == INVALID_REGNUM);
-         fde->vdrap_reg = REGNO (dest);
-       }
-      return;
-    }
-
   switch (GET_CODE (dest))
     {
     case REG:
@@ -2781,6 +2755,20 @@ dwarf2out_frame_debug (rtx insn, bool after_p)
        handled_one = true;
        break;
 
+      case REG_CFA_SET_VDRAP:
+       n = XEXP (note, 0);
+       if (REG_P (n))
+         {
+           dw_fde_ref fde = current_fde ();
+           gcc_assert (fde
+                       && fde->drap_reg != INVALID_REGNUM
+                       && fde->vdrap_reg == INVALID_REGNUM);
+           if (REG_P (n))
+             fde->vdrap_reg = REGNO (n);
+         }
+       handled_one = true;
+       break;
+
       default:
        break;
       }
@@ -12736,13 +12724,18 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset,
          return new_loc_descr (DW_OP_fbreg, offset, 0);
        }
     }
-  else if (fde
+  else if (!optimize
+          && fde
           && fde->drap_reg != INVALID_REGNUM
           && (fde->drap_reg == REGNO (reg)
               || fde->vdrap_reg == REGNO (reg)))
     {
       /* Use cfa+offset to represent the location of arguments passed
-        on stack when drap is used to align stack.  */
+        on the stack when drap is used to align stack.
+        Only do this when not optimizing, for optimized code var-tracking
+        is supposed to track where the arguments live and the register
+        used as vdrap or drap in some spot might be used for something
+        else in other part of the routine.  */
       return new_loc_descr (DW_OP_fbreg, offset, 0);
     }
 
index 90b5fde..aa2daea 100644 (file)
@@ -1,5 +1,6 @@
 /* Register note definitions.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -153,6 +154,11 @@ REG_NOTE (CFA_REGISTER)
    first pattern is the register to be restored.  */
 REG_NOTE (CFA_RESTORE)
 
+/* Attached to insn that is RTX_FRAME_RELATED_P, marks insn that sets
+   vDRAP from DRAP.  If vDRAP is a register, vdrap_reg is initalized
+   to the argument, if it is a MEM, it is ignored.  */
+REG_NOTE (CFA_SET_VDRAP)
+
 /* Indicates that REG holds the exception context for the function.
    This context is shared by inline functions, so the code to acquire
    the real exception context is delayed until after inlining.  */
index e58f57d..0b8ec91 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/36728
+       * gcc.dg/guality/pr36728-1.c: New test.
+       * gcc.dg/guality/pr36728-2.c: New test.
+
 2010-03-10  Kaushik Phatak  <kaushik.phatak@kpitcummins.com>
 
        * gcc.dg/h8300-div-delay-slot.c: New test.
diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-1.c b/gcc/testsuite/gcc.dg/guality/pr36728-1.c
new file mode 100644 (file)
index 0000000..408e087
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR debug/36728 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+int __attribute__((noinline))
+foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
+{
+  char *x = __builtin_alloca (arg7);
+  int __attribute__ ((aligned(32))) y;
+
+  y = 2;
+  asm volatile ("" : "=m" (y) : "m" (y));
+  x[0] = 25;
+  asm volatile ("" : "=m" (x[0]) : "m" (x[0]));
+  return y;
+}
+
+/* { dg-final { gdb-test 12 "arg1" "1" } } */
+/* { dg-final { gdb-test 12 "arg2" "2" } } */
+/* { dg-final { gdb-test 12 "arg3" "3" } } */
+/* { dg-final { gdb-test 12 "arg4" "4" } } */
+/* { dg-final { gdb-test 12 "arg5" "5" } } */
+/* { dg-final { gdb-test 12 "arg6" "6" } } */
+/* { dg-final { gdb-test 12 "arg7" "30" } } */
+/* { dg-final { gdb-test 12 "y" "2" } } */
+/* { dg-final { gdb-test 14 "arg1" "1" } } */
+/* { dg-final { gdb-test 14 "arg2" "2" } } */
+/* { dg-final { gdb-test 14 "arg3" "3" } } */
+/* { dg-final { gdb-test 14 "arg4" "4" } } */
+/* { dg-final { gdb-test 14 "arg5" "5" } } */
+/* { dg-final { gdb-test 14 "arg6" "6" } } */
+/* { dg-final { gdb-test 14 "arg7" "30" } } */
+/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */
+/* { dg-final { gdb-test 14 "y" "2" } } */
+
+int
+main ()
+{
+  int l = 0;
+  asm volatile ("" : "=r" (l) : "0" (l));
+  foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-2.c b/gcc/testsuite/gcc.dg/guality/pr36728-2.c
new file mode 100644 (file)
index 0000000..983757b
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR debug/36728 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+int __attribute__((noinline))
+foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
+{
+  char x[30];
+  int __attribute__ ((aligned(32))) y;
+
+  y = 2;
+  asm volatile ("" : "=m" (y) : "m" (y));
+  x[0] = 25;
+  asm volatile ("" : "=m" (x[0]) : "m" (x[0]));
+  return y;
+}
+
+/* { dg-final { gdb-test 12 "arg1" "1" } } */
+/* { dg-final { gdb-test 12 "arg2" "2" } } */
+/* { dg-final { gdb-test 12 "arg3" "3" } } */
+/* { dg-final { gdb-test 12 "arg4" "4" } } */
+/* { dg-final { gdb-test 12 "arg5" "5" } } */
+/* { dg-final { gdb-test 12 "arg6" "6" } } */
+/* { dg-final { gdb-test 12 "arg7" "30" } } */
+/* { dg-final { gdb-test 12 "y" "2" } } */
+/* { dg-final { gdb-test 14 "arg1" "1" } } */
+/* { dg-final { gdb-test 14 "arg2" "2" } } */
+/* { dg-final { gdb-test 14 "arg3" "3" } } */
+/* { dg-final { gdb-test 14 "arg4" "4" } } */
+/* { dg-final { gdb-test 14 "arg5" "5" } } */
+/* { dg-final { gdb-test 14 "arg6" "6" } } */
+/* { dg-final { gdb-test 14 "arg7" "30" } } */
+/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */
+/* { dg-final { gdb-test 14 "y" "2" } } */
+
+int
+main ()
+{
+  int l = 0;
+  asm volatile ("" : "=r" (l) : "0" (l));
+  foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30);
+  return 0;
+}