This is the mail archive of the gcc@gcc.gnu.org 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]

Re: Code motion around labels


Richard Kenner wrote:
> If I have two labels whose address is taken in static data, the most likely
> purpose is that some "external" entity is going to be using those
> labels to see if it is executing the code between them.

(1) The most likely purpose is probably to use those labels in a jump
    table, as shown in the examples in the GNU C manual.

(2) The GNU C manual does not guarantee (and AFAIK has never guaranteed)
    that code as you describe will work.  Code which assumes anything
    about the comparison ordering between different label addresses,
    or between label addresses and program counter values is relying on
    things which the GNU C manual does not guarantee.  The only thing
    you can safely do with a label whose address you've taken, other than
    passing it around and storing it in variables, is to jump to it using
    `goto *'.

    Now, *maybe* it would be a good idea to make some guarantees along
    those lines, but you haven't really provided any argument for it.
    The counter-argument is fairly straight-forward:
    - Ensuring that such guarantees hold in the presence of all the
      different optimizations that gcc does might be difficult,
      and this is an area which is unlikely to get much testing,
      so it could be a fertile source of obscure bugs that don't
      get fixed.
    - This feature adds "distributed fat": providing such guarantees
      would inhibit some optimizations, thus hurting code which doesn't
      make use of the guarantees.  If guarantees like that are required,
      then to avoid distributed fat a different syntax should be used.
      For example, the guarantees could only be supported for labels
      declared `volatile', perhaps using the syntax `volatile foo: ...')

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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