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] Fix PR73434


I am testing the following patch fixing a TBAA related miscompile.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-08-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/73434
	* tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address): Preserve
	TBAA info on the base when forwarding a non-invariant address.

	* gcc.dg/torture/pr73434.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 239406)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** vn_reference_maybe_forwprop_address (vec
*** 1225,1230 ****
--- 1225,1235 ----
  	{
  	  auto_vec<vn_reference_op_s, 32> tem;
  	  copy_reference_ops_from_ref (TREE_OPERAND (addr, 0), &tem);
+ 	  /* Make sure to preserve TBAA info.  */
+ 	  vn_reference_op_t new_mem_op = &tem[tem.length () - 2];
+ 	  gcc_assert (new_mem_op->opcode == MEM_REF);
+ 	  new_mem_op->op0 = fold_convert (TREE_TYPE (mem_op->op0),
+ 					  new_mem_op->op0);
  	  ops->pop ();
  	  ops->pop ();
  	  ops->safe_splice (tem);
Index: gcc/testsuite/gcc.dg/torture/pr73434.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr73434.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr73434.c	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ /* { dg-do run } */
+ 
+ typedef struct { unsigned char x; } A;
+ typedef struct { unsigned char x; } B;
+ 
+ int idx = 0;
+ 
+ A objs[1] = {{0}};
+ 
+ int main()
+ {
+   B *b = (B*)&objs[idx];
+   b->x++;
+   if (b->x)
+     b->x = 0;
+   if (b->x)
+     __builtin_abort ();
+   return 0;
+ }


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