[llvm-commits] [llvm] r82701 - /llvm/trunk/docs/LangRef.html

Török Edwin edwintorok at gmail.com
Thu Sep 24 15:49:18 CDT 2009

On 2009-09-24 21:38, Dale Johannesen wrote:
> Author: johannes
> Date: Thu Sep 24 13:38:21 2009
> New Revision: 82701
> URL: http://llvm.org/viewvc/llvm-project?rev=82701&view=rev
> Log:
> Clarify that llvm attaches C language semantics to
> functions with names that match the C library.
> Modified:
>     llvm/trunk/docs/LangRef.html
> Modified: llvm/trunk/docs/LangRef.html
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=82701&r1=82700&r2=82701&view=diff
> ==============================================================================
> --- llvm/trunk/docs/LangRef.html (original)
> +++ llvm/trunk/docs/LangRef.html Thu Sep 24 13:38:21 2009
> @@ -5045,6 +5045,13 @@
>    %ZZ = call zeroext i32 @bar()                     <i>; Return value is %zero extended</i>
>  </pre>
> +<p>llvm treats calls to some functions with names and arguments that match the
> +standard C library as being the C library functions, and may perform
> +optimizations or generate code for them under that assumption.  These
> +functions currently include:
> +acos, asin, atan, atan2, ceil, cos, cosf, cosh, exp, fabs, floor, fmod, log,
> +log10, malloc, pow, sin, sinh, sqrt, sqrtf, sin, sinf, tan, tanh.</p>
> +

In fact this list is longer [1], it includes (excluding Andersens.cpp
and SimplifyLibcalls)
abs, absf, absl, atexit, calloc, ceil, copysign, copysignf, cosl,
exit, fabsf, fabsl, free, __half_powr4, __main, main, memcpy, realloc,
_setjmp, setjmp,
sinf, sinl.

Although it is very good that LLVM handles these for C/C++, it is not
necesarely good for Java/Python/some other language.

Suggestion: could we have all these special function names in one place,
and an enum?
Then all the analysis/transforms that need special function names can call:

enum SpecialFunctions KnownFunctions::classifySpecialFunction(StringRef
name, Module &M);
bool KnownFunctions::isKnown(StringRef name, Module &M);
Function *KnownFunctions::getSpecial(StringRef name, Module &M);
Function *KnownFunctions::getOrInsertSpecial(StringRef name, Module
&M);//allowed to return null for failure

If you don't want these special functions there could be a command-line
flag and an llvm:: variable default true that could be set to false.

[1] I generated this list with these, which is not entirely accurate so
there may be more:
cd lib
git grep getFunction\(\"|grep -v Andersens|grep -v SimplifyLibCalls|grep
-E -o \"[^\"]+\"|grep -v llvm|sort -u
git grep getName\(\)|grep -v Andersen|grep -v SimplifyLibCalls|grep -E
==.+\"|grep -E -o \"[^\"]+\"|grep -v llvm |sort -u
git grep -E Name.+==.+\"|grep -v Andersen|grep -v SimplifyLibCalls|grep
-E -o \"[^\"]+\"|grep -v llvm|sort -u

Best regards,

More information about the llvm-commits mailing list