This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use VIEW_CONVERT_EXPR in SRA created debug stmts if needed (PR debug/59776)


Hi!

As discussed in the PR, this patch adds VCE if types aren't compatible,
in order not to create invalid debug stmts.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

--- gcc/tree-sra.c.jj	2014-02-08 00:53:46.000000000 +0100
+++ gcc/tree-sra.c	2014-02-11 14:31:51.469937602 +0100
@@ -2950,6 +2950,10 @@ load_assign_lhs_subreplacements (struct
 						  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);
--- gcc/testsuite/gcc.dg/guality/pr59776.c.jj	2014-02-11 14:44:04.604957250 +0100
+++ gcc/testsuite/gcc.dg/guality/pr59776.c	2014-02-11 14:52:57.000000000 +0100
@@ -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;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]