[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [PATCH] Trivial cleanup
From:       Jeff Law <law () redhat ! com>
Date:       2013-09-30 16:48:19
Message-ID: 5249AB53.3020804 () redhat ! com
[Download RAW message or body]

On 09/28/13 08:31, Andrew MacLeod wrote:
>
> temps would be OK with me, but there are a couple of concerns.
>   - I'd want to be able to declare the temps at the point of use, not
> the top of the function. this would actually help with clarity I think.
> Not sure what the current coding standard says about that.
Point of use is fine for GCC now.   From our coding conventions:

Variable Definitions

Variables should be defined at the point of first use, rather than at 
the top of the function. The existing code obviously does not follow 
that rule, so variables may be defined at the top of the function, as in 
C90.

Variables may be simultaneously defined and tested in control expressions.





>   - the compiler better do an awesome job of sharing stack  space for
> user variables in a function... I wouldn't want to blow up the stack
> with a bazillion unrelatd temps each wit their own location.
If the objects have the same type and disjoint lifetimes, they can be 
easily shared.

Things are more difficult if the types are different -- IIRC, the root 
of the problem is the optimizers can interchange a load of one type with 
a later store of the other -- the aliasing code says "hey, they're 
different types, so they don't alias, feel free to move them around as 
desired" and all hell breaks loose.

Jeff
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic