From 44affdae265bcadbdf427891e0fd5b19482c2527 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 10 Feb 2000 18:43:55 +0100 Subject: [PATCH] function.c (assign_temp): Change zero-sized arrays to size 1. * 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. From-SVN: r31898 --- gcc/ChangeLog | 9 +++++++ gcc/config/i386/i386.c | 53 +++++++++++++++++++++--------------------- gcc/function.c | 5 ++++ gcc/integrate.c | 3 --- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef31d9af358..5be98c7f8f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Thu Feb 10 18:28:59 MET 2000 Jan Hubicka + + * 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 * flow.c (mark_regs_live_at_end): Delete unused variables. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 1e5e44ed73e..730594a9aec 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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; diff --git a/gcc/function.c b/gcc/function.c index 9f96031a0cf..117074287f6 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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 diff --git a/gcc/integrate.c b/gcc/integrate.c index 4e5d80cc2b6..cea4bda7874 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -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. */ -- 2.30.2