[PATCH][mem-ref2] Fixup ABI va-args some more

Richard Guenther rguenther@suse.de
Mon Jun 7 13:15:00 GMT 2010


This tries to work around the implementation issues of multiple
va-arg types some more.  Just make sure to present the backends
with a properly typed va-list.

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

Richard.

2010-06-07  Richard Guenther  <rguenther@suse.de>

	* builtins.c (stabilize_va_list_loc): Use the function ABI
	valist type if we couldn't canonicalize the argument type.
	Always dereference with the canonical va-list type.

Index: gcc/builtins.c
===================================================================
*** gcc/builtins.c	(revision 160359)
--- gcc/builtins.c	(working copy)
*************** stabilize_va_list_loc (location_t loc, t
*** 4452,4464 ****
    tree vatype = targetm.canonical_va_list_type (TREE_TYPE (valist));
  
    /* The current way of determining the type of valist is completely
!      bogus.  We should have the information on the current function
!      declaration instead.  */
! #if 0
!   gcc_assert (vatype != NULL_TREE);
! #endif
    if (!vatype)
!     vatype = va_list_type_node;
  
    if (TREE_CODE (vatype) == ARRAY_TYPE)
      {
--- 4452,4460 ----
    tree vatype = targetm.canonical_va_list_type (TREE_TYPE (valist));
  
    /* The current way of determining the type of valist is completely
!      bogus.  We should have the information on the va builtin instead.  */
    if (!vatype)
!     vatype = targetm.fn_abi_va_list (cfun->decl);
  
    if (TREE_CODE (vatype) == ARRAY_TYPE)
      {
*************** stabilize_va_list_loc (location_t loc, t
*** 4477,4497 ****
      }
    else
      {
!       tree pt;
  
        if (! needs_lvalue)
  	{
  	  if (! TREE_SIDE_EFFECTS (valist))
  	    return valist;
  
- 	  pt = build_pointer_type (vatype);
  	  valist = fold_build1_loc (loc, ADDR_EXPR, pt, valist);
  	  TREE_SIDE_EFFECTS (valist) = 1;
  	}
  
        if (TREE_SIDE_EFFECTS (valist))
  	valist = save_expr (valist);
!       valist = build_fold_indirect_ref_loc (loc, valist);
      }
  
    return valist;
--- 4473,4493 ----
      }
    else
      {
!       tree pt = build_pointer_type (vatype);
  
        if (! needs_lvalue)
  	{
  	  if (! TREE_SIDE_EFFECTS (valist))
  	    return valist;
  
  	  valist = fold_build1_loc (loc, ADDR_EXPR, pt, valist);
  	  TREE_SIDE_EFFECTS (valist) = 1;
  	}
  
        if (TREE_SIDE_EFFECTS (valist))
  	valist = save_expr (valist);
!       valist = fold_build2_loc (loc, MEM_REF,
! 				vatype, valist, build_int_cst (pt, 0));
      }
  
    return valist;



More information about the Gcc-patches mailing list