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 for middle-end/15885


This patch fixes 15885 by special-casing BUILT_IN_VA_START in
gimplify_call_expr.  Other possible approaches would be to create a
VA_START_EXPR, or to lower va_start.  rth has talked about doing the latter
at some point, but this should hold us for now.

Tested x86_64-pc-linux-gnu, applied to trunk.

2004-07-14  Jason Merrill  <jason@redhat.com>

	PR middle-end/15885
	* gimplify.c (gimplify_arg): New fn, split out from...
	(gimplify_call_expr): Here.  Special-case BUILT_IN_VA_START.

*** gimplify.c.~1~	2004-07-14 16:54:19.000000000 -0400
--- gimplify.c	2004-07-15 16:14:18.000000000 -0400
*************** gimplify_self_mod_expr (tree *expr_p, tr
*** 1788,1793 ****
--- 1788,1818 ----
      }
  }
  
+ /* Subroutine of gimplify_call_expr:  Gimplify a single argument.  */
+ 
+ static enum gimplify_status
+ gimplify_arg (tree *expr_p, tree *pre_p)
+ {
+   bool (*test) (tree);
+   fallback_t fb;
+ 
+   /* In general, we allow lvalues for function arguments to avoid
+      extra overhead of copying large aggregates out of even larger
+      aggregates into temporaries only to copy the temporaries to
+      the argument list.  Make optimizers happy by pulling out to
+      temporaries those types that fit in registers.  */
+   if (is_gimple_reg_type (TREE_TYPE (*expr_p)))
+     test = is_gimple_val, fb = fb_rvalue;
+   else
+     test = is_gimple_lvalue, fb = fb_either;
+ 
+   /* There is a sequence point before a function call.  Side effects in
+      the argument list must occur before the actual call. So, when
+      gimplifying arguments, force gimplify_expr to use an internal
+      post queue which is then appended to the end of PRE_P.  */
+   return gimplify_expr (expr_p, pre_p, NULL, test, fb);
+ }
+ 
  /* Gimplify the CALL_EXPR node pointed by EXPR_P.  PRE_P points to the
     list where side effects that must happen before *EXPR_P should be stored.
     WANT_VALUE is true if the result of the call is desired.  */
*************** gimplify_call_expr (tree *expr_p, tree *
*** 1847,1852 ****
--- 1872,1882 ----
  	  *expr_p = new;
  	  return GS_OK;
  	}
+ 
+       if (DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_START)
+ 	/* Avoid gimplifying the second argument to va_start, which needs
+ 	   to be the plain PARM_DECL.  */
+ 	return gimplify_arg (&TREE_VALUE (TREE_OPERAND (*expr_p, 1)), pre_p);
      }
  
    /* There is a sequence point before the call, so any side effects in
*************** gimplify_call_expr (tree *expr_p, tree *
*** 1861,1884 ****
         arglist = TREE_CHAIN (arglist))
      {
        enum gimplify_status t;
-       bool (*test) (tree);
-       fallback_t fb;
- 
-       /* In general, we allow lvalues for function arguments to avoid
- 	 extra overhead of copying large aggregates out of even larger
- 	 aggregates into temporaries only to copy the temporaries to
- 	 the argument list.  Make optimizers happy by pulling out to
- 	 temporaries those types that fit in registers.  */
-       if (is_gimple_reg_type (TREE_TYPE (TREE_VALUE (arglist))))
- 	test = is_gimple_val, fb = fb_rvalue;
-       else
- 	test = is_gimple_lvalue, fb = fb_either;
  
!       /* There is a sequence point before a function call.  Side effects in
! 	 the argument list must occur before the actual call. So, when
! 	 gimplifying arguments, force gimplify_expr to use an internal
! 	 post queue which is then appended to the end of PRE_P.  */
!       t = gimplify_expr (&TREE_VALUE (arglist), pre_p, NULL, test, fb);
  
        if (t == GS_ERROR)
  	ret = GS_ERROR;
--- 1891,1898 ----
         arglist = TREE_CHAIN (arglist))
      {
        enum gimplify_status t;
  
!       t = gimplify_arg (&TREE_VALUE (arglist), pre_p);
  
        if (t == GS_ERROR)
  	ret = GS_ERROR;

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