[llvm-dev] llvm intrinsics/libc/libm question

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 7 08:03:31 PDT 2016


I'm trying to figure out exactly how the intrinsics/libc/libm work in llvm.

For example, this code return user defined function:


float acos(float x, float y)
{
    return x+y;
}

float a;
void foo(float b, float c)
{
 a = acos(b, c);
}


But this code returns llvm.intrinsic:


float acos(float, float);

float a;
void foo(float b, float c)
{
 a = acos(b, c);
}

float acos(float x, float y)
{
 return x+y;
}

What is the expected behavior here?

Also, there are certain "standard C library functions" included in LLVM
that I'd like to remove without modifying core code, is this possible?

I'm also curious how LLVM handles pure functions in regards to
optimizations. For example, libm functions such as acos. It appears that
X86 doesn't have acos as an intrinsic and instead just calls a function
"tail call @acos...", is this still able to be optimized. I see the
hardcoded 'name' lookup for 'acos' in ConstantFolding.cpp. It doesn't
appear that if you slightly change the name from 'acos' to say 'XXX_acos'
in your libm it'll still be optimized?

Thanks,

Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160607/dc0548f5/attachment.html>


More information about the llvm-dev mailing list