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]

[lto] tree.c: Simplify build_function_type_list.


Hi,

Attached is a patch to simplify build_function_type_list.

Once I convert TYPE_ARG_TYPES to a TREE_VEC, I am not going to use
nreverse or the "if" statement shown in the patch.

This patch removes them and builds a linked list in the forward order
in the first run.

Tested on x86_64-pc-linux-gnu.  Committed to the LTO branch as
obvious.

Kazu Hirata

2006-06-10  Kazu Hirata  <kazu@codesourcery.com>

	* tree.c (build_function_type_list): Simplify by building the
	type list in the forward order in the first run.

Index: tree.c
===================================================================
*** tree.c	(revision 114535)
--- tree.c	(working copy)
***************
*** 5129,5151 ****
  tree
  build_function_type_list (tree return_type, ...)
  {
!   tree t, args, last;
    va_list p;
  
    va_start (p, return_type);
  
!   t = va_arg (p, tree);
!   for (args = NULL_TREE; t != NULL_TREE; t = va_arg (p, tree))
!     args = tree_cons (NULL_TREE, t, args);
! 
!   if (args == NULL_TREE)
!     args = void_list_node;
!   else
      {
!       last = args;
!       args = nreverse (args);
!       TREE_CHAIN (last) = void_list_node;
      }
    args = build_function_type (return_type, args);
  
    va_end (p);
--- 5129,5146 ----
  tree
  build_function_type_list (tree return_type, ...)
  {
!   tree t, args, *args_p = &args;
    va_list p;
  
    va_start (p, return_type);
  
!   for (t = va_arg (p, tree); t != NULL_TREE; t = va_arg (p, tree))
      {
!       *args_p = build_tree_list (NULL_TREE, t);
!       args_p = &TREE_CHAIN (*args_p);
      }
+ 
+   *args_p = void_list_node;
    args = build_function_type (return_type, args);
  
    va_end (p);


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