OSDN Git Service

* function.c (assign_temp): Change zero-sized arrays to size 1.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2000 17:43:55 +0000 (17:43 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2000 17:43:55 +0000 (17:43 +0000)
* integrate.c (expand_inline_function): Do not update
stack_alignment_needed
* i386.c (compute_frame_size): Remove #ifdef PREFERRED_FRAME_BOUNDARY,
add some sanity checking, remove optimization for function with
zero frame size.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31898 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/function.c
gcc/integrate.c

index ef31d9a..5be98c7 100644 (file)
@@ -1,3 +1,12 @@
+Thu Feb 10 18:28:59 MET 2000  Jan Hubicka  <jh@suse.cz>
+
+       * function.c (assign_temp): Change zero-sized arrays to size 1.
+       * integrate.c (expand_inline_function): Do not update
+       stack_alignment_needed
+       * i386.c (compute_frame_size): Remove #ifdef PREFERRED_FRAME_BOUNDARY,
+       add some sanity checking, remove optimization for function with
+       zero frame size.
+
 2000-02-10  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * flow.c (mark_regs_live_at_end): Delete unused variables.
index 1e5e44e..730594a 100644 (file)
@@ -1769,44 +1769,43 @@ ix86_compute_frame_size (size, nregs_on_stack, rpadding1, rpadding2)
   int padding2 = 0;
   HOST_WIDE_INT total_size;
   int stack_alignment_needed = cfun->stack_alignment_needed / BITS_PER_UNIT;
+  int offset;
+  int preferred_alignment = cfun->preferred_stack_boundary / BITS_PER_UNIT;
 
   nregs = ix86_nsaved_regs ();
   total_size = size;
 
-#ifdef PREFERRED_STACK_BOUNDARY
-  {
-    int offset;
-    int preferred_alignment = cfun->preferred_stack_boundary / BITS_PER_UNIT;
-
-    offset = frame_pointer_needed ? 8 : 4;
+  offset = frame_pointer_needed ? 8 : 4;
 
-    /* When frame is not empty we ought to have recorded the alignment.  */
-    if (size && !stack_alignment_needed)
-      abort ();
+  /* Do some sanity checking of stack_alignment_needed and preferred_alignment,
+     since i386 port is the only using those features that may break easilly.  */
 
-    if (stack_alignment_needed < 4)
-      stack_alignment_needed = 4;
+  if (size && !stack_alignment_needed)
+    abort ();
+  if (!size && stack_alignment_needed)
+    abort ();
+  if (preferred_alignment < STACK_BOUNDARY / BITS_PER_UNIT)
+    abort ();
+  if (preferred_alignment > PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
+    abort ();
+  if (stack_alignment_needed > PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
+    abort ();
 
-    if (stack_alignment_needed > PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
-      abort ();
+  if (stack_alignment_needed < 4)
+    stack_alignment_needed = 4;
 
-    offset += nregs * UNITS_PER_WORD;
+  offset += nregs * UNITS_PER_WORD;
 
-    total_size += offset;
+  total_size += offset;
 
-    /* Align start of frame for local function.  */
-    if (size > 0)
-      {
-        padding1 = ((offset + stack_alignment_needed - 1)
-                   & -stack_alignment_needed) - offset;
-        total_size += padding1;
-      }
+  /* Align start of frame for local function.  */
+  padding1 = ((offset + stack_alignment_needed - 1)
+             & -stack_alignment_needed) - offset;
+  total_size += padding1;
 
-    /* Align stack boundary. */
-    padding2 = ((total_size + preferred_alignment - 1)
-               & -preferred_alignment) - total_size;
-  }
-#endif
+  /* Align stack boundary. */
+  padding2 = ((total_size + preferred_alignment - 1)
+             & -preferred_alignment) - total_size;
 
   if (nregs_on_stack)
     *nregs_on_stack = nregs;
index 9f96031..1170742 100644 (file)
@@ -837,6 +837,11 @@ assign_temp (type, keep, memory_required, dont_promote)
       HOST_WIDE_INT size = int_size_in_bytes (type);
       rtx tmp;
 
+      /* Zero sized arrays are GNU C extension.  Set size to 1 to avoid
+        problems with allocating the stack space.  */
+      if (size == 0)
+       size = 1;
+
       /* Unfortunately, we don't yet know how to allocate variable-sized
         temporaries.  However, sometimes we have a fixed upper limit on
         the size (which is stored in TYPE_ARRAY_MAX_SIZE) and can use that
index 4e5d80c..cea4bda 100644 (file)
@@ -605,9 +605,6 @@ expand_inline_function (fndecl, parms, target, ignore, type,
   if (cfun->preferred_stack_boundary < inl_f->preferred_stack_boundary)
     cfun->preferred_stack_boundary = inl_f->preferred_stack_boundary;
 
-  if (cfun->stack_alignment_needed < inl_f->stack_alignment_needed)
-    cfun->stack_alignment_needed = inl_f->stack_alignment_needed;
-
   /* Check that the parms type match and that sufficient arguments were
      passed.  Since the appropriate conversions or default promotions have
      already been applied, the machine modes should match exactly.  */