Re: Automatic inference of const/pure function attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yang Zhang <yanghatespam@xxxxxxxxx> writes:

> Can gcc automatically determine that a function is const/pure (on a
> best-effort basis), instead of requiring the user to explicitly
> specify the attribute always?  (I realize determining this may be
> difficult for certain functions, or the user may simply wish to
> specify this anyway regardless of the true nature of the function.)

Yes, gcc can and does do this, within a single source file.  It only
works when gcc can prove that every function called by that function
is itself const or pure.  In practice that means that it works
reliably for leaf functions, but if the pure/const function calls a
function defined in another source file then that other function must
be explicitly annotated.

When gcc implements whole program optimization in the future, this
will no doubt be extended to work between source files.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux