]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/59776 (gcc -g -O1 ICE in expand_debug_locations, at cfgexp...
authorJakub Jelinek <jakub@redhat.com>
Thu, 6 Mar 2014 07:59:29 +0000 (08:59 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 6 Mar 2014 07:59:29 +0000 (08:59 +0100)
Backport from mainline
2014-02-11  Richard Henderson  <rth@redhat.com>
    Jakub Jelinek  <jakub@redhat.com>

PR debug/59776
* tree-sra.c (load_assign_lhs_subreplacements): Add VIEW_CONVERT_EXPR
around drhs if type conversion to lacc->type is not useless.

* gcc.dg/guality/pr59776.c: New test.

From-SVN: r208366

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/pr59776.c [new file with mode: 0644]
gcc/tree-sra.c

index 0c9e168241a4cfa8fc17d041548d3c911ec8cc56..eeed95ae7756fc02fd719509955d4eb6b48905eb 100644 (file)
@@ -1,6 +1,13 @@
 2014-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-02-11  Richard Henderson  <rth@redhat.com>
+                   Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/59776
+       * tree-sra.c (load_assign_lhs_subreplacements): Add VIEW_CONVERT_EXPR
+       around drhs if type conversion to lacc->type is not useless.
+
        2014-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/60026
index 7ff01fdf122c6ab5cb10ce8b0616374f26800508..8cef5c6671ade170058040c7ca40f37a1307689f 100644 (file)
@@ -1,6 +1,11 @@
 2014-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/59776
+       * gcc.dg/guality/pr59776.c: New test.
+
        2014-02-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR preprocessor/56824
diff --git a/gcc/testsuite/gcc.dg/guality/pr59776.c b/gcc/testsuite/gcc.dg/guality/pr59776.c
new file mode 100644 (file)
index 0000000..382abb6
--- /dev/null
@@ -0,0 +1,29 @@
+/* PR debug/59776 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+struct S { float f, g; };
+
+__attribute__((noinline, noclone)) void
+foo (struct S *p)
+{
+  struct S s1, s2;                     /* { dg-final { gdb-test pr59776.c:17 "s1.f" "5.0" } } */
+  s1 = *p;                             /* { dg-final { gdb-test pr59776.c:17 "s1.g" "6.0" } } */
+  s2 = s1;                             /* { dg-final { gdb-test pr59776.c:17 "s2.f" "0.0" } } */
+  *(int *) &s2.f = 0;                  /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" } } */
+  asm volatile (NOP : : : "memory");   /* { dg-final { gdb-test pr59776.c:20 "s1.f" "5.0" } } */
+  asm volatile (NOP : : : "memory");   /* { dg-final { gdb-test pr59776.c:20 "s1.g" "6.0" } } */
+  s2 = s1;                             /* { dg-final { gdb-test pr59776.c:20 "s2.f" "5.0" } } */
+  asm volatile (NOP : : : "memory");   /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" } } */
+  asm volatile (NOP : : : "memory");
+}
+
+int
+main ()
+{
+  struct S x = { 5.0f, 6.0f };
+  foo (&x);
+  return 0;
+}
index 7d0a4dcc8c95b99f3337bd90dbea7f031be13ddf..43b2ce683cbe2050feee4498435cbd6785a18220 100644 (file)
@@ -2889,6 +2889,10 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc,
                                                  lacc);
              else
                drhs = NULL_TREE;
+             if (drhs
+                 && !useless_type_conversion_p (lacc->type, TREE_TYPE (drhs)))
+               drhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
+                                       lacc->type, drhs);
              ds = gimple_build_debug_bind (get_access_replacement (lacc),
                                            drhs, gsi_stmt (*old_gsi));
              gsi_insert_after (new_gsi, ds, GSI_NEW_STMT);