[clang] [compiler-rt] [llvm] [SPARC] Properly handle CC for long double on sparc32 (PR #162226)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 9 23:00:27 PST 2025
s-barannikov 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).
So maybe the inreg flag can help disambiguate these two cases here?
https://github.com/llvm/llvm-project/pull/162226
More information about the llvm-commits
mailing list