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 regression of PR30965


This fixes the regression we have for PR30965 (we don't inline the
calls anymore) and adds a testcase for that PR.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to mainline.

Richard.

2007-07-05  Richard Guenther  <rguenther@suse.de>

	* gimplify.c (gimplify_call_expr): Prefer DECL_ARGUMENTS over
	TYPE_ARG_TYPES for verification of argument types.  Use
	DECL_ARG_TYPE instead of the PARM_DECL type.  Take excess
	parameters as variable arguments.

Index: testsuite/g++.dg/opt/pr30965.C
===================================================================
--- testsuite/g++.dg/opt/pr30965.C	(revision 0)
+++ testsuite/g++.dg/opt/pr30965.C	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+
+#include <tr1/functional>
+#include <algorithm>
+
+extern void assign( long* variable, long v )
+{
+        std::transform( variable, variable + 1, variable,
+                std::tr1::bind( std::plus< long >(), 0L, v ) );
+}
+extern void assign( long& variable, long v )
+{
+        std::transform( &variable, &variable + 1, &variable,
+                std::tr1::bind( std::plus< long >(), 0L, v ) );
+}
+
+/* { dg-final { scan-tree-dump-times ";; Function" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "variable = v" 2 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: gimplify.c
===================================================================
*** gimplify.c	(revision 126369)
--- gimplify.c	(working copy)
*************** gimplify_call_expr (tree *expr_p, tree *
*** 2135,2141 ****
    /* Verify if the type of the argument matches that of the function
       declaration.  If we cannot verify this or there is a mismatch,
       mark the call expression so it doesn't get inlined later.  */
!   if (parms)
      {
        for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
  	{
--- 2135,2161 ----
    /* Verify if the type of the argument matches that of the function
       declaration.  If we cannot verify this or there is a mismatch,
       mark the call expression so it doesn't get inlined later.  */
!   if (decl && DECL_ARGUMENTS (decl))
!     {
!       for (i = 0, p = DECL_ARGUMENTS (decl); i < nargs;
! 	   i++, p = TREE_CHAIN (p))
! 	{
! 	  /* We cannot distinguish a varargs function from the case
! 	     of excess parameters, still defering the inlining decision
! 	     to the callee is possible.  */
! 	  if (!p)
! 	    break;
! 	  if (p == error_mark_node
! 	      || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
! 	      || !fold_convertible_p (DECL_ARG_TYPE (p),
! 				      CALL_EXPR_ARG (*expr_p, i)))
! 	    {
! 	      CALL_CANNOT_INLINE_P (*expr_p) = 1;
! 	      break;
! 	    }
! 	}
!     }
!   else if (parms)
      {
        for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
  	{
*************** gimplify_call_expr (tree *expr_p, tree *
*** 2154,2172 ****
  	    }
  	}
      }
-   else if (decl && DECL_ARGUMENTS (decl))
-     {
-       for (i = 0, p = DECL_ARGUMENTS (decl); i < nargs;
- 	   i++, p = TREE_CHAIN (p))
- 	if (!p
- 	    || p == error_mark_node
- 	    || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
- 	    || !fold_convertible_p (TREE_TYPE (p), CALL_EXPR_ARG (*expr_p, i)))
- 	  {
- 	    CALL_CANNOT_INLINE_P (*expr_p) = 1;
- 	    break;
- 	  }
-     }
    else if (nargs != 0)
      CALL_CANNOT_INLINE_P (*expr_p) = 1;
  
--- 2174,2179 ----


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