OSDN Git Service

PR debug/43150
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Feb 2010 10:50:13 +0000 (10:50 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Feb 2010 10:50:13 +0000 (10:50 +0000)
* gimplify.c (gimplify_type_sizes): Clear DECL_IGNORED_P for VLA
bounds even for -O+.
* var-tracking.c (track_expr_p): If !need_rtl, don't mandate
expr needs to have DECL_NAME set.

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

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

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/vla-1.c [new file with mode: 0644]
gcc/var-tracking.c

index b5f7c1a..9298c2e 100644 (file)
@@ -1,3 +1,11 @@
+2010-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43150
+       * gimplify.c (gimplify_type_sizes): Clear DECL_IGNORED_P for VLA
+       bounds even for -O+.
+       * var-tracking.c (track_expr_p): If !need_rtl, don't mandate
+       expr needs to have DECL_NAME set.
+
 2010-02-24  Nick Clifton  <nickc@redhat.com>
 
        * config/mep/mep.c: Include gimple.h.
index 618e3a6..1838747 100644 (file)
@@ -7367,9 +7367,10 @@ gimplify_type_sizes (tree type, gimple_seq *list_p)
       /* These types may not have declarations, so handle them here.  */
       gimplify_type_sizes (TREE_TYPE (type), list_p);
       gimplify_type_sizes (TYPE_DOMAIN (type), list_p);
-      /* When not optimizing, ensure VLA bounds aren't removed.  */
-      if (!optimize
-         && TYPE_DOMAIN (type)
+      /* Ensure VLA bounds aren't removed, for -O0 they should be variables
+        with assigned stack slots, for -O1+ -g they should be tracked
+        by VTA.  */
+      if (TYPE_DOMAIN (type)
          && INTEGRAL_TYPE_P (TYPE_DOMAIN (type)))
        {
          t = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
index 4acf557..cce88bf 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43150
+       * gcc.dg/guality/vla-1.c: New test.
+
 2010-02-24  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/43042
diff --git a/gcc/testsuite/gcc.dg/guality/vla-1.c b/gcc/testsuite/gcc.dg/guality/vla-1.c
new file mode 100644 (file)
index 0000000..2db1c29
--- /dev/null
@@ -0,0 +1,36 @@
+/* PR debug/43150 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+void __attribute__((noinline))
+bar (short *p)
+{
+  __builtin_memset (p, '\0', 17 * sizeof (*p));
+  asm volatile ("" : : "r" (p) : "memory");
+}
+
+int __attribute__((noinline))
+f1 (int i)
+{
+  char a[i + 1];
+  a[0] = 5;            /* { dg-final { gdb-test 17 "i" "5" } } */
+  return a[0];         /* { dg-final { gdb-test 17 "sizeof (a)" "6" } } */
+}
+
+int __attribute__((noinline))
+f2 (int i)
+{
+  short a[i * 2 + 7];  /* { dg-final { gdb-test 24 "i" "5" } } */
+  bar (a);             /* { dg-final { gdb-test 24 "sizeof (a)" "17 * sizeof (short)" } } */
+  return a[i + 4];
+}
+
+int
+main ()
+{
+  int i = 5;
+  asm volatile ("" : "=r" (i) : "0" (i));
+  f1 (i);
+  f2 (i);
+  return 0;
+}
index 049dca4..6e9af6e 100644 (file)
@@ -4150,7 +4150,7 @@ track_expr_p (tree expr, bool need_rtl)
     return 0;
 
   /* It also must have a name...  */
-  if (!DECL_NAME (expr))
+  if (!DECL_NAME (expr) && need_rtl)
     return 0;
 
   /* ... and a RTL assigned to it.  */