Re: Telling the C optimizer that a pointer's contents won't be modified

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

 




> Did you try the access attribute?
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Oh, I didn't know about this one. But it doesn't seem to change the generated code... Maybe it is only used for diagnostic error messages?

Or for older versions of GCC using the pure attribute seems to work as
you want too.

Unfortunately, the reader function in the example is not pure. Annotating it with __attribute__((pure)) causes GCC to warn about the "void" return type and the function call is completely removed from the generated code.

But it's still a great idea! I'm sure that there we have a couple of other functions that we could annotate this way.





[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