[llvm-dev] Attribute for a invariant function ?
Nat! via llvm-dev
llvm-dev at lists.llvm.org
Sat Jan 9 06:40:52 PST 2016
I have a read-only lookup table, which takes integer arguments.
Optimally I would like to indicate in the C source, that the function is
invariant (?), so that the superflous calls can be optimized away.
```
extern void *lookup( int a);
void foo( void)
{
void *a, *b;
a = lookup( 0x12345678);
bar( a);
b = lookup( 0x12345678); // b guaranteed to be the same as a, no
call to (slow) lookup needed
baz( b);
}
```
But I don't really find anything in clang or llvm in terms of function
attributes. The best I could come up with is in the llvm code to use
attributes "argmemonly=true" readonly=true". But still two calls did
happen. (I am on 3.7)
Ciao
Nat!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160109/b58cd3b6/attachment.html>
More information about the llvm-dev
mailing list