Patchwork use XALLOCAVEC in Fortran FE

login
register
mail settings
Submitter Nathan Froyd
Date Aug. 7, 2010, 8:22 p.m.
Message ID <20100807202233.GM17362@codesourcery.com>
Download mbox | patch
Permalink /patch/61193/
State New
Headers show

Comments

Nathan Froyd - Aug. 7, 2010, 8:22 p.m.
This patch converts several alloca calls to their XALLOCAVEC
equivalents.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

	* interface.c (compare_actual_formal): Use XALLOCAVEC instead of
	alloca.
	(check_some_aliasing): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_conversion): Likewise.
	(gfc_conv_intrinsic_int): Likewise.
	(gfc_conv_intrinsic_lib_function): Likewise.
	(gfc_conv_intrinsic_cmplx): Likewise.
	(gfc_conv_intrinsic_ctime): Likewise.
	(gfc_conv_intrinsic_fdate): Likewise.
	(gfc_conv_intrinsic_ttynam): Likewise.
	(gfc_conv_intrinsic_minmax): Likewise.
	(gfc_conv_intrinsic_minmax_char): Likewise.
	(gfc_conv_intrinsic_ishftc): Likewise.
	(gfc_conv_intrinsic_index_scan_verify): Likewise.
	(gfc_conv_intrinsic_merge): Likewise.
	(gfc_conv_intrinsic_trim): Likewise.
	* trans.c (gfc_trans_runtime_error_vararg): Likewise.
Nathan Froyd - Aug. 7, 2010, 9:11 p.m.
On Sun, Aug 08, 2010 at 02:34:22AM +0200, Mikael Morin wrote:
> Le 07.08.2010 22:22, Nathan Froyd a écrit :
>> This patch converts several alloca calls to their XALLOCAVEC
>> equivalents.
>>
>> Tested on x86_64-unknown-linux-gnu.  OK to commit?
>>
> Yes. Thanks.

Thanks, commited as r162984.

-Nathan
Mikael Morin - Aug. 8, 2010, 12:34 a.m.
Le 07.08.2010 22:22, Nathan Froyd a écrit :
>
> This patch converts several alloca calls to their XALLOCAVEC
> equivalents.
>
> Tested on x86_64-unknown-linux-gnu.  OK to commit?
>
Yes. Thanks.

Mikael.

Patch

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index f37f1bd..1e72a90 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1931,7 +1931,7 @@  compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
   for (f = formal; f; f = f->next)
     n++;
 
-  new_arg = (gfc_actual_arglist **) alloca (n * sizeof (gfc_actual_arglist *));
+  new_arg = XALLOCAVEC (gfc_actual_arglist *, n);
 
   for (i = 0; i < n; i++)
     new_arg[i] = NULL;
@@ -2439,7 +2439,7 @@  check_some_aliasing (gfc_formal_arglist *f, gfc_actual_arglist *a)
     }
   if (n == 0)
     return t;
-  p = (argpair *) alloca (n * sizeof (argpair));
+  p = XALLOCAVEC (argpair, n);
 
   for (i = 0, f1 = f, a1 = a; i < n; i++, f1 = f1->next, a1 = a1->next)
     {
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index a576076..589e9df 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -259,7 +259,7 @@  gfc_conv_intrinsic_conversion (gfc_se * se, gfc_expr * expr)
   int nargs;
 
   nargs = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * nargs);
+  args = XALLOCAVEC (tree, nargs);
 
   /* Evaluate all the arguments passed. Whilst we're only interested in the 
      first one here, there are other parts of the front-end that assume this 
@@ -502,7 +502,7 @@  gfc_conv_intrinsic_int (gfc_se * se, gfc_expr * expr, enum rounding_mode op)
   int nargs;
 
   nargs = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * nargs);
+  args = XALLOCAVEC (tree, nargs);
 
   /* Evaluate the argument, we process all arguments even though we only 
      use the first one for code generation purposes.  */
@@ -732,7 +732,7 @@  gfc_conv_intrinsic_lib_function (gfc_se * se, gfc_expr * expr)
 
   /* Get the decl and generate the call.  */
   num_args = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   gfc_conv_intrinsic_function_args (se, expr, args, num_args);
   fndecl = gfc_get_intrinsic_lib_fndecl (m, expr);
@@ -1003,7 +1003,7 @@  gfc_conv_intrinsic_cmplx (gfc_se * se, gfc_expr * expr, int both)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   type = gfc_typenode_for_spec (&expr->ts);
   gfc_conv_intrinsic_function_args (se, expr, args, num_args);
@@ -1288,7 +1288,7 @@  gfc_conv_intrinsic_ctime (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr) + 2;
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   var = gfc_create_var (pchar_type_node, "pstr");
   len = gfc_create_var (gfc_get_int_type (8), "len");
@@ -1327,7 +1327,7 @@  gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr) + 2;
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   var = gfc_create_var (pchar_type_node, "pstr");
   len = gfc_create_var (gfc_charlen_type_node, "len");
@@ -1368,7 +1368,7 @@  gfc_conv_intrinsic_ttynam (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr) + 2;
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   var = gfc_create_var (pchar_type_node, "pstr");
   len = gfc_create_var (gfc_charlen_type_node, "len");
@@ -1423,7 +1423,7 @@  gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op)
   unsigned int i, nargs;
 
   nargs = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * nargs);
+  args = XALLOCAVEC (tree, nargs);
 
   gfc_conv_intrinsic_function_args (se, expr, args, nargs);
   type = gfc_typenode_for_spec (&expr->ts);
@@ -1498,7 +1498,7 @@  gfc_conv_intrinsic_minmax_char (gfc_se * se, gfc_expr * expr, int op)
   unsigned int nargs;
 
   nargs = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * (nargs + 4));
+  args = XALLOCAVEC (tree, nargs + 4);
   gfc_conv_intrinsic_function_args (se, expr, &args[4], nargs);
 
   /* Create the result variables.  */
@@ -3070,7 +3070,7 @@  gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   gfc_conv_intrinsic_function_args (se, expr, args, num_args);
 
@@ -3429,7 +3429,7 @@  gfc_conv_intrinsic_index_scan_verify (gfc_se * se, gfc_expr * expr,
   tree *args;
   unsigned int num_args;
 
-  args = (tree *) alloca (sizeof (tree) * 5);
+  args = XALLOCAVEC (tree, 5);
 
   /* Get number of arguments; characters count double due to the
      string length argument. Kind= is not passed to the library
@@ -3517,7 +3517,7 @@  gfc_conv_intrinsic_merge (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr);
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   gfc_conv_intrinsic_function_args (se, expr, args, num_args);
   if (expr->ts.type != BT_CHARACTER)
@@ -4677,7 +4677,7 @@  gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr)
   unsigned int num_args;
 
   num_args = gfc_intrinsic_argument_list_length (expr) + 2;
-  args = (tree *) alloca (sizeof (tree) * num_args);
+  args = XALLOCAVEC (tree, num_args);
 
   var = gfc_create_var (gfc_get_pchar_type (expr->ts.kind), "pstr");
   addr = gfc_build_addr_expr (ppvoid_type_node, var);
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index e266be8..6fa62fb 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -405,7 +405,7 @@  gfc_trans_runtime_error_vararg (bool error, locus* where, const char* msgid,
   gfc_free(message);
 
   /* Build the argument array.  */
-  argarray = (tree *) alloca (sizeof (tree) * (nargs + 2));
+  argarray = XALLOCAVEC (tree, nargs + 2);
   argarray[0] = arg;
   argarray[1] = arg2;
   for (i = 0; i < nargs; i++)