re PR tree-optimization/42645 ("-fcompare-debug failure" at -O1)
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Jan 2010 09:43:31 +0000 (10:43 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Jan 2010 09:43:31 +0000 (10:43 +0100)
PR tree-optimization/42645
* tree-inline.c (processing_debug_stmt): Move earlier.  Make static.
(remap_ssa_name): If processing_debug_stmt and name wasn't found in
decl_map, set processing_debug_stmt to -1 and return name without
any remapping.

* g++.dg/other/pr42645-1.C: New test.
* g++.dg/other/pr42645-2.C: New test.

From-SVN: r155830

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr42645-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/pr42645-2.C [new file with mode: 0644]
gcc/tree-inline.c

index b233eb6..47491c0 100644 (file)
@@ -1,3 +1,11 @@
+2010-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/42645
+       * tree-inline.c (processing_debug_stmt): Move earlier.  Make static.
+       (remap_ssa_name): If processing_debug_stmt and name wasn't found in
+       decl_map, set processing_debug_stmt to -1 and return name without
+       any remapping.
+
 2010-01-11  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        * doc/install.texi (Specific#x-x-cygwin): Document minimum required
index 0093948..cc978cd 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/42645
+       * g++.dg/other/pr42645-1.C: New test.
+       * g++.dg/other/pr42645-2.C: New test.
+
 2010-01-11  Janis Johnson  <janis187@us.ibm.com>
 
        PR target/42416
diff --git a/gcc/testsuite/g++.dg/other/pr42645-1.C b/gcc/testsuite/g++.dg/other/pr42645-1.C
new file mode 100644 (file)
index 0000000..5dc76f9
--- /dev/null
@@ -0,0 +1,26 @@
+// PR tree-optimization/42645
+// { dg-do compile }
+// { dg-options "-fcompare-debug -O1" }
+
+extern void foo ();
+
+struct S
+{
+  struct T
+  {
+    int t1;
+    char t2[4];
+    T *t3;
+  } t;
+  int m1 () const { return t.t3[0].t1; }
+  char *m2 () { foo (); }
+  void m3 (int x) { char *m = m2 (); if (m1 () > 0 && x > 0); }
+  void m4 () { if (m1 () > 0) for (int i = 0; i < 4; i++) t.t2[i] = 0; }
+};
+
+void
+f (S *a)
+{
+  a->m3 (0);
+  a->m4 ();
+}
diff --git a/gcc/testsuite/g++.dg/other/pr42645-2.C b/gcc/testsuite/g++.dg/other/pr42645-2.C
new file mode 100644 (file)
index 0000000..67632e5
--- /dev/null
@@ -0,0 +1,34 @@
+// PR tree-optimization/42645
+// { dg-do compile }
+// { dg-options "-fcompare-debug -O1" }
+
+struct C
+{
+  bool b;
+  C ();
+};
+
+static inline C *foo () {}
+
+extern void f4 ();
+
+static inline int
+f3 ()
+{
+  f4 ();
+}
+
+static inline void
+f2 (bool b)
+{
+  int tmp = f3 ();
+  if (C ().b && b)
+    C ();
+}
+
+void
+f1 ()
+{
+  C *c = foo ();
+  f2 (c->b);
+}
index aacd903..883a431 100644 (file)
@@ -1,5 +1,5 @@
 /* Tree inlining.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Alexandre Oliva <aoliva@redhat.com>
 
@@ -171,6 +171,12 @@ insert_debug_decl_map (copy_body_data *id, tree key, tree value)
   *pointer_map_insert (id->debug_map, key) = value;
 }
 
+/* If nonzero, we're remapping the contents of inlined debug
+   statements.  If negative, an error has occurred, such as a
+   reference to a variable that isn't available in the inlined
+   context.  */
+static int processing_debug_stmt = 0;
+
 /* Construct new SSA name for old NAME. ID is the inline context.  */
 
 static tree
@@ -185,6 +191,12 @@ remap_ssa_name (tree name, copy_body_data *id)
   if (n)
     return unshare_expr (*n);
 
+  if (processing_debug_stmt)
+    {
+      processing_debug_stmt = -1;
+      return name;
+    }
+
   /* Do not set DEF_STMT yet as statement is not copied yet. We do that
      in copy_bb.  */
   new_tree = remap_decl (SSA_NAME_VAR (name), id);
@@ -244,12 +256,6 @@ remap_ssa_name (tree name, copy_body_data *id)
   return new_tree;
 }
 
-/* If nonzero, we're remapping the contents of inlined debug
-   statements.  If negative, an error has occurred, such as a
-   reference to a variable that isn't available in the inlined
-   context.  */
-int processing_debug_stmt = 0;
-
 /* Remap DECL during the copying of the BLOCK tree for the function.  */
 
 tree