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 PR44632


When gimplifying local parameters we can't clear TREE_ADDRESSABLE
of the PARM_DECLs we replace with VAR_DECLs in their value-expr
as the following gimplification will still look at that addressable
bit when deciding NRV.

Bootstrapped and tested on x86_64-unknown-linux-gnu by me and
hppa-linux-gnu by Dave.  Installed on trunk.

Richard.

2010-08-09  Richard Guenther  <rguenther@suse.de>

	PR middle-end/44632
	* function.c (gimplify_parameters): Do not clear addressable
	bit of the original parameter.

	* g++.dg/opt/nrv17.C: New testcase.

Index: gcc/function.c
===================================================================
*** gcc/function.c	(revision 163028)
--- gcc/function.c	(working copy)
*************** gimplify_parameters (void)
*** 3570,3581 ****
  		  DECL_IGNORED_P (local) = 0;
  		  /* If PARM was addressable, move that flag over
  		     to the local copy, as its address will be taken,
! 		     not the PARMs.  */
  		  if (TREE_ADDRESSABLE (parm))
! 		    {
! 		      TREE_ADDRESSABLE (parm) = 0;
! 		      TREE_ADDRESSABLE (local) = 1;
! 		    }
  		}
  	      else
  		{
--- 3570,3579 ----
  		  DECL_IGNORED_P (local) = 0;
  		  /* If PARM was addressable, move that flag over
  		     to the local copy, as its address will be taken,
! 		     not the PARMs.  Keep the parms address taken
! 		     as we'll query that flag during gimplification.  */
  		  if (TREE_ADDRESSABLE (parm))
! 		    TREE_ADDRESSABLE (local) = 1;
  		}
  	      else
  		{
Index: gcc/testsuite/g++.dg/opt/nrv17.C
===================================================================
*** gcc/testsuite/g++.dg/opt/nrv17.C	(revision 0)
--- gcc/testsuite/g++.dg/opt/nrv17.C	(revision 0)
***************
*** 0 ****
--- 1,32 ----
+ // { dg-do run }
+ 
+ #include <cstdlib>
+ #include <complex>
+ 
+ void __attribute__((noinline))
+ h(std::complex<double> x)
+ {
+   if (x.real() != 2.0)
+     std::abort ();
+ }
+ 
+ void __attribute__((noinline))
+ g(std::complex<double> x)
+ {
+   if (x.real() != 0.5)
+     std::abort ();
+ }
+ 
+ void __attribute__((noinline))
+ f(std::complex<double> x)
+ {
+   h (x);
+   x = 1.0 / x;
+   g (x);
+ }
+ 
+ int main()
+ {
+   f(2.0);
+   return 0;
+ }


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