Patch adds roundl to a list of library calls in isF128SoftLibCall method (MipsCCState.cpp).
Test file roundl-call.ll is also added to LLVM regression tests.
Problem description:
There was a problem in LLVM backend that is triggered with next C code:
#include <math.h> int main() { long double x, y; y = roundl(x); return 0; }
With clang we generate IR code using -emit-llvm option (roundl-call.ll):
clang -static -O0 --target=mips64-img-linux-gnu -EL -mcpu=mips64r6 -mabi=64 -mhard-float -no-integrated-as --gcc-toolchain=/home/rtrk/mips-toolchain/mips-img-linux-gnu/2015.01-7 -S -emit-llvm roundl-test.c
Then we generate assembler code from roundl-call.ll with llc:
llc -march=mips64el -mcpu=mips64r3 -target-abi=n64 -O2 < roundl-call.ll
We can see that generated assembler code is using the wrong convention for roundl call.
Soft-float registers V0_64 and V1_64 are used for storing result instead of hard-float registers:
sd $3, 8($fp) sd $2, 0($fp)
After the patch is applied we generate assembler code again from the same .ll file.
Now we can see that FPU registers D0_64 and D2_64 are used as it is expected for hard-float:
sdc1 $f2, 8($fp) sdc1 $f0, 0($fp)
*This bug is also reported on bugzilla (https://dmz-portal.mips.com/bugz/show_bug.cgi?id=2303).