Is store_expr(e,t,v!=m) safe?

Roger Sayle roger@www.eyesopen.com
Mon Apr 7 22:52:00 GMT 2003


On Mon, 7 Apr 2003, Richard Henderson wrote:
> I disagree.  Indeed, even my patch does not totally fix
> the problem.  There are additional examples in
>
>   http://gcc.gnu.org/ml/gcc-patches/2002-12/msg00533.html
>
> that continue to fail.


I was wondering, for yet another work-around for PR opt/8634, when
is it safe to turn the the local variable "const foo = ..." into the
almost equivalent "static const foo = ..."?

It turns out that should we change the const variable from auto to
static, (i) we layout the struct/array at compile-time, (ii) we
avoid the issues with initializing fields unchanging memory twice
and (iii) often actually reduce the size of the executable, as
the pre-initialized array is much shorter than the sequence of
instructions used to construct it at run-time.


Perhaps it would be possible for the front-ends to determine that
all of the fields/entries of an initializer are dense compile time
constants, and set TREE_STATIC on the DECL prior to calling the
middle-end.


This would work for all the examples given in the posting cited
above, provided of course that I haven't overlooked some requirement
that the address of an const auto variable be on the stack.

Just a thought.

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc mailing list