[clang] [compiler-rt] [llvm] [SPARC] Properly handle CC for long double on sparc32 (PR #162226)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 9 19:33:57 PST 2025


koachan wrote:

> > > ```
> > > declare fp128 @fmul(fp128 %a, fp128 %b)
> > > 
> > > define fp128 @square(fp128 %num) {
> > >     %ret = call fp128 @fmul(fp128 %num, fp128 %num)
> > >     ret fp128 %ret
> > > }
> > > ```
> > 
> > 
> > I think the main issue here is that the fp128s need to be passed around as if it's a sret struct but I dunno how to declare it in (Ret)CC_Sparc32...
> 
> You need to return false for it in `CanLowerReturn`.

Ah, this one's already sorted out but I end up in an odd situation as I described in [this comment](https://github.com/llvm/llvm-project/pull/162226#issuecomment-3420461662).
clang lowers `long double _Complex` as `{f128, f128}`, so if `CanLowerReturn` is true for f128, LLVM will return it in registers (correct!) but then autogenerated LLVM calls to C functions will be wrong (see the `sinl` example above), meanwhile if I set it to false then autogenerated C calls will be correct, but then `long double _Complex` will be returned as sret (which is wrong).

https://github.com/llvm/llvm-project/pull/162226


More information about the llvm-commits mailing list