* Automatic inference of const/pure function attributes
@ 2009-01-24 10:28 Yang Zhang
2009-01-24 18:52 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Yang Zhang @ 2009-01-24 10:28 UTC (permalink / raw)
To: GCC-help
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.)
--
Yang Zhang
http://www.mit.edu/~y_z/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Automatic inference of const/pure function attributes
2009-01-24 10:28 Automatic inference of const/pure function attributes Yang Zhang
@ 2009-01-24 18:52 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2009-01-24 18:52 UTC (permalink / raw)
To: Yang Zhang; +Cc: GCC-help
Yang Zhang <yanghatespam@gmail.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-24 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-24 10:28 Automatic inference of const/pure function attributes Yang Zhang
2009-01-24 18:52 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).