This is the mail archive of the 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]

Re: system.h and system header include cleanup - ORTHOGONAL POINTS

On Sat, 27 Nov 2010, N.M. Maclaren wrote:

> > fortran/gfortran.h had a pile of definitions related to alloca.  If
> > such were needed, system.h would be the right place for them, but
> > since the rest of GCC uses alloca without needing such definitions I
> > just removed them.
> Do you know if any of those rely on function-scope lifetime rather than
> block-scope lifetime and are in code that is needed for bootstrapping?
> I am still trying to find out where the world is going in this respect,
> and it is most unclear.

It does appear some rely on function-scope lifetime, e.g. in reg-stack.c:

static int
check_asm_stack_operands (rtx insn)
  rtx *clobber_reg = 0;
[...]  if (GET_CODE (body) == PARALLEL)
      clobber_reg = XALLOCAVEC (rtx, XVECLEN (body, 0));
              if (REGNO (recog_data.operand[i]) == REGNO (clobber_reg[j]))

I hadn't checked carefully enough before for portability code relating to 
alloca; actually it's in libiberty.h, where it arranges for libiberty's C 
implementation of alloca to be used if not building with GCC.  So that 
might in fact avoid portability issues with any bootstrap implementations 
using a different lifetime for their built-in alloca - if the C alloca is 
actually portable enough.

I don't think anything (at least anything built for the host) in GCC, 
whether needed for bootstrapping or not, should be using VLAs; it's the 
combination of the two that is documented as reducing the lifetime of 
memory from alloca when building with GCC:

    There are other differences between these two methods.  Space allocated
    with @code{alloca} exists until the containing @emph{function} returns.
    The space for a variable-length array is deallocated as soon as the array
    name's scope ends.  (If you use both variable-length arrays and
    @code{alloca} in the same function, deallocation of a variable-length array
    will also deallocate anything more recently allocated with @code{alloca}.)

Bootstrapping with non-GCC compilers is supposed to work but isn't often 
tested.  The documented requirement on a bootstrap compiler is that it 
supports ISO C90; the undocumented requirements beyond that include at 
least "long long" support for configurations with 32-bit long that set 
need_64bit_hwint in config.gcc.

Joseph S. Myers

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