[llvm-dev] Attribute for a invariant function ?

Nat! via llvm-dev llvm-dev at lists.llvm.org
Sat Jan 9 07:22:46 PST 2016


Martin J. O'Riordan schrieb:
>
>
> extern void *lookup(int) __attribute__((pure));
>
> might do what you need though.
>



Good, that's pretty much what I was looking for. With that I was able to 
google for

https://stackoverflow.com/questions/29117836/attribute-const-vs-attribute-pure-in-gnu-c

which leads me to:

__attribute__((const)) function attribute
Many functions examine only the arguments passed to them, and have no 
effects except for the return value. This is a much stricter class than 
__attribute__((pure)), because a function is not permitted to read 
global memory. If a function is known to operate only on its arguments 
then it can be subject to common sub-expression elimination and loop 
optimizations.

The last sentence is what I am after. :) Unfortunately at least in clang 
3.7 it does not seem to do anything.

Thanks for the help.

Ciao
Nat!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160109/f78af49c/attachment.html>


More information about the llvm-dev mailing list