This is an archive of the discontinued LLVM Phabricator instance.

[mips] Mark fmaxl as a long double emulation routine
ClosedPublic

Authored by smaksimovic on Sep 28 2018, 7:19 AM.

Details

Summary

Failure was discovered upon running projects/compiler-rt/test/builtins/Unit/divtc3_test.c in a stage2 compiler build.
When compiling projects/compiler-rt/lib/builtins/divtc3.c, a call to fmaxl within the divtc3 implementation had its
return values read from registers $2 and $3 instead of $f0 and $f2.
Include fmaxl in the list of long double emulation routines to have its return value correctly interpreted as f128.

Almost exact issue here: https://reviews.llvm.org/D17760

Diff Detail

Repository
rL LLVM

Event Timeline

smaksimovic created this revision.Sep 28 2018, 7:19 AM
This revision is now accepted and ready to land.Oct 2 2018, 7:08 AM

I'm kind of confused by what you're doing here... fmaxl is a C library function; C code is allowed to take its address and call it indirectly. So changing the lowering based on the name of the callee seems wrong.

If the issue is specifically with intrinsic lowering, maybe the MIPS backend should be using setLibcallCallingConv?

My only goal was to correct the return value of fmaxl to be interpreted as a 128bit float.
As it stands the return value is being interpreted as an i128 and fetched from the wrong registers.

I've observed the lowering go as so: crt_fmaxl (called in projects/compiler-rt/lib/builtins/divtc3.c`) -> @llvm.maxnum.f128 -> fmaxl

Is there a side effect to the change apart from what I described as my intention above?

I don't think anything will go wrong in this case, specifically... I'm more generally worried about the keeping a list of float routines in the MIPS backend which is essentially copy-pasted from RuntimeLibcalls.def.

In that case I'll commit this patch, the issue with float routine names being kept in the MIPS backend can be deferred to a separate patch since it does not pertain to fmaxl only.

This revision was automatically updated to reflect the committed changes.