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 PR32493, bring back inlining of varargs functions


This brings back the most wanted feature(TM) by simply delaying the
decision on whether to inline varargs functions or not to the callee
(which sets it based on whether we use the variable arguments).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to mainline.
(if it's only for the testcase)

Richard.


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

	PR middle-end/32493
	* gimplify.c (gimplify_call_expr): Ignore variable argument parts
	during type verification.

	* gcc.dg/inline-23.c: New testcase.

Index: gimplify.c
===================================================================
*** gimplify.c	(revision 126110)
--- gimplify.c	(working copy)
*************** gimplify_call_expr (tree *expr_p, tree *
*** 2138,2151 ****
    if (parms)
      {
        for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
! 	if (!p
! 	    || TREE_VALUE (p) == error_mark_node
! 	    || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
! 	    || !fold_convertible_p (TREE_VALUE (p), CALL_EXPR_ARG (*expr_p, i)))
! 	  {
! 	    CALL_CANNOT_INLINE_P (*expr_p) = 1;
  	    break;
! 	  }
      }
    else if (decl && DECL_ARGUMENTS (decl))
      {
--- 2138,2158 ----
    if (parms)
      {
        for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
! 	{
! 	  /* If this is a varargs function defer inlining decision
! 	     to callee.  */
! 	  if (!p)
  	    break;
! 	  if (TREE_VALUE (p) == error_mark_node
! 	      || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
! 	      || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
! 	      || !fold_convertible_p (TREE_VALUE (p),
! 				      CALL_EXPR_ARG (*expr_p, i)))
! 	    {
! 	      CALL_CANNOT_INLINE_P (*expr_p) = 1;
! 	      break;
! 	    }
! 	}
      }
    else if (decl && DECL_ARGUMENTS (decl))
      {
Index: testsuite/gcc.dg/inline-23.c
===================================================================
*** testsuite/gcc.dg/inline-23.c	(revision 0)
--- testsuite/gcc.dg/inline-23.c	(revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile } */
+ /* { dg-options "-std=gnu89" } */
+ /* Make sure we can inline a varargs function whose variable arguments
+    are not used.  See PR32493.  */
+ static inline __attribute__((always_inline)) void __check_printsym_format(const
+ char *fmt, ...)
+ {
+ }
+ static inline __attribute__((always_inline)) void print_symbol(const char *fmt,
+ unsigned long addr)
+ {
+  __check_printsym_format(fmt, "");
+ }
+ void do_initcalls(void **call)
+ {
+    print_symbol(": %s()", (unsigned long) *call);
+ }


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