<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"></head><body
 style="font-family: tt;" bgcolor="#FFFFFF" text="#000000">
<div style="font-family: tt;"><span style="font-family: monospace;">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.<br><br>```<br>extern
 void  *lookup( int a);<br><br>void   foo( void)<br>{<br>   void   *a, 
*b;<br>   <br>   a = </span><span style="font-family: monospace;">lookup</span><span
 style="font-family: monospace;">( 0x12345678);<br>   bar( a);<br><br>  
 b = </span><span style="font-family: monospace;">lookup</span><span 
style="font-family: monospace;"></span><span style="font-family: 
monospace;">( </span><span style="font-family: monospace;">0x12345678</span><span
 style="font-family: monospace;">);  // b guaranteed to be the same as 
a, no call to (slow) lookup needed<br></span><span style="font-family: 
monospace;">   baz( b);<br>
</span><span style="font-family: monospace;">}<br>```<br><br></span><span
 style="font-family: monospace;">But I don't really find anything in 
clang or llvm in terms of function attributes. </span><span 
style="font-family: monospace;">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)<br><br>Ciao<br>   Nat!<br><br></span></div>
</body>
</html>