I've looked into more aggresive use of attributes pure/const on gcc
functions. The problem I recall running into is that for whatever
function you want to start with, you have to perform a depth-first
conversion of all sub-functions it calls and they must be marked
pure/const also or GCC will complain (warn) during bootstrap.
That part is actually a "good thing" if you do the grunt work.
However I
specifically recall running into problems with certain functions using
switch statements that had a default clause with abort or
gcc_unreachable.
Such functions aren't technically pure since aborting is a side-
effect and
GCC won't allow you to mark these with the attribute. Another way
aborting sneaks in big-time is because of "checking" macros which
introduce lots of noreturn calls.
This was discussed a while back, and some solutions were thrown
around but
I don't have the relevant URLs handy. I think one of the ideas was
introducing a new function attribute that meant "I'm sort of pure
but I
might not return". I don't know how much that would help for
performance.