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 PR27830


This fixes PR27830 by ensuring to "fold" &* during inline substitution.
This is safe, because it only happens in the case of inlining a function
with return slot optimization, where dereferencing the pointer always
is ok.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Ok for mainline and 4.1?

Thanks,
Richard.

:ADDPATCH inline:

2006-06-08  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27830
	* tree-inline.c (copy_body_r): For copying the operand
	of an ADDR_EXPR make sure to fold &* afterwards.

	* g++.dg/tree-ssa/pr27830.C: New testcase.

Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 114387)
+++ tree-inline.c	(working copy)
@@ -659,7 +659,12 @@
       else if (TREE_CODE (*tp) == ADDR_EXPR)
 	{
 	  walk_tree (&TREE_OPERAND (*tp, 0), copy_body_r, id, NULL);
-	  recompute_tree_invariant_for_addr_expr (*tp);
+	  /* Handle the case where we substituted an INDIRECT_REF
+	     into the operand of the ADDR_EXPR.  */
+	  if (TREE_CODE (TREE_OPERAND (*tp, 0)) == INDIRECT_REF)
+	    *tp = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0);
+	  else
+	    recompute_tree_invariant_for_addr_expr (*tp);
 	  *walk_subtrees = 0;
 	}
     }
Index: testsuite/g++.dg/tree-ssa/pr27830.C
===================================================================
*** testsuite/g++.dg/tree-ssa/pr27830.C	(revision 0)
--- testsuite/g++.dg/tree-ssa/pr27830.C	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O" } */
+ 
+ struct gc{};
+ struct transform:public gc
+ {
+     double x, y, z, t;
+     transform (void){}
+ };
+ inline transform f (void)
+ {
+     return transform ();
+ };
+ void transformed (void)
+ {
+     new transform (f());
+ }
+ 


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