re PR middle-end/17965 (ice in expand_call)
authorJakub Jelinek <jakub@redhat.com>
Sun, 26 Jun 2005 05:27:14 +0000 (07:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 26 Jun 2005 05:27:14 +0000 (07:27 +0200)
PR middle-end/17965
* calls.c (expand_call, emit_library_call_value_1): Use xmalloc/free
instead of alloca for really big argument sizes.

* gcc.c-torture/compile/20050622-1.c: New test.

From-SVN: r101333

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20050622-1.c [new file with mode: 0644]

index 751cc70..f6ff44e 100644 (file)
@@ -1,5 +1,9 @@
 2005-06-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/17965
+       * calls.c (expand_call, emit_library_call_value_1): Use xmalloc/free
+       instead of alloca for really big argument sizes.
+
        PR middle-end/22028
        * gimplify.c (gimplify_type_sizes): Check for type == error_mark_node
        earlier in the function.
index b06830d..1613e88 100644 (file)
@@ -1864,6 +1864,7 @@ expand_call (tree exp, rtx target, int ignore)
 
   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
   char *initial_stack_usage_map = stack_usage_map;
+  char *stack_usage_map_buf = NULL;
 
   int old_stack_allocated;
 
@@ -2350,7 +2351,10 @@ expand_call (tree exp, rtx target, int ignore)
                  highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
                                                     needed);
 #endif
-                 stack_usage_map = alloca (highest_outgoing_arg_in_use);
+                 if (stack_usage_map_buf)
+                   free (stack_usage_map_buf);
+                 stack_usage_map_buf = xmalloc (highest_outgoing_arg_in_use);
+                 stack_usage_map = stack_usage_map_buf;
 
                  if (initial_highest_arg_in_use)
                    memcpy (stack_usage_map, initial_stack_usage_map,
@@ -2455,7 +2459,10 @@ expand_call (tree exp, rtx target, int ignore)
                    = stack_arg_under_construction;
                  stack_arg_under_construction = 0;
                  /* Make a new map for the new argument list.  */
-                 stack_usage_map = alloca (highest_outgoing_arg_in_use);
+                 if (stack_usage_map_buf)
+                   free (stack_usage_map_buf);
+                 stack_usage_map_buf = xmalloc (highest_outgoing_arg_in_use);
+                 stack_usage_map = stack_usage_map_buf;
                  memset (stack_usage_map, 0, highest_outgoing_arg_in_use);
                  highest_outgoing_arg_in_use = 0;
                }
@@ -3009,6 +3016,9 @@ expand_call (tree exp, rtx target, int ignore)
       emit_move_insn (virtual_stack_dynamic_rtx, stack_pointer_rtx);
     }
 
+  if (stack_usage_map_buf)
+    free (stack_usage_map_buf);
+
   return target;
 }
 
@@ -3203,6 +3213,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
   /* Size of the stack reserved for parameter registers.  */
   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
   char *initial_stack_usage_map = stack_usage_map;
+  char *stack_usage_map_buf = NULL;
 
   rtx struct_value = targetm.calls.struct_value_rtx (0, 0);
 
@@ -3481,7 +3492,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
                                         needed);
 #endif
-      stack_usage_map = alloca (highest_outgoing_arg_in_use);
+      stack_usage_map_buf = xmalloc (highest_outgoing_arg_in_use);
+      stack_usage_map = stack_usage_map_buf;
 
       if (initial_highest_arg_in_use)
        memcpy (stack_usage_map, initial_stack_usage_map,
@@ -3835,6 +3847,9 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
       stack_usage_map = initial_stack_usage_map;
     }
 
+  if (stack_usage_map_buf)
+    free (stack_usage_map_buf);
+
   return value;
 
 }
index a8ca329..e0a2ce5 100644 (file)
@@ -1,5 +1,8 @@
 2005-06-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/17965
+       * gcc.c-torture/compile/20050622-1.c: New test.
+
        PR middle-end/22028
        * gcc.dg/20050620-1.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050622-1.c b/gcc/testsuite/gcc.c-torture/compile/20050622-1.c
new file mode 100644 (file)
index 0000000..db18390
--- /dev/null
@@ -0,0 +1,16 @@
+#if __SCHAR_MAX__ == 127 && __INT_MAX__ >= 2147483647
+struct S { char buf[72*1024*1024]; };
+#else
+struct S { char buf[64]; };
+#endif
+
+extern void bar (struct S);
+
+struct S s;
+
+int
+foo (void)
+{
+  bar (s);
+  return 0;
+}