[PATCH] D131087: [RISCV] Implement isUsedByReturnOnly TargetLowering hook in order to tailcall more libcalls

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 11:33:27 PDT 2022


asb created this revision.
asb added reviewers: craig.topper, reames, luismarques.
Herald added subscribers: wingo, sunshaoce, pmatos, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, kristof.beyls, arichardson.
Herald added a project: All.
asb requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Prior to this patch, libcalls inserted by the SelectionDAG legalizer
could never be tailcalled. The eligibility of libcalls for tail calling
is is partly determined by checking TargetLowering::isInTailCallPosition
and comparing the return type of the libcall and the calleer.
isInTailCallPosition in turn calls TargetLowering::isUsedByReturnOnly
(which always returns false if not implemented by the target).

This patch provides a minimal implementation of
TargetLowering::isUsedByReturnOnly - enough to support tail calling
libcalls on hard float ABIs. Soft-float ABIs are left for a follow on
patch. libcall-tail-calls.ll also shows missed opportunities to tail
call integer libcalls, but this is due to issues outside of
the isUsedByReturnOnly hook.

The isUsedByReturnOnly hook is essentially the same as for X86/Arm/AArch64. I've tried to clean it up a bit, but please do check I haven't copied across any bad practices / outdated API usage.


https://reviews.llvm.org/D131087

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/test/CodeGen/RISCV/div.ll
  llvm/test/CodeGen/RISCV/double-frem.ll
  llvm/test/CodeGen/RISCV/double-intrinsics.ll
  llvm/test/CodeGen/RISCV/double-round-conv.ll
  llvm/test/CodeGen/RISCV/float-intrinsics.ll
  llvm/test/CodeGen/RISCV/float-round-conv.ll
  llvm/test/CodeGen/RISCV/fp16-promote.ll
  llvm/test/CodeGen/RISCV/libcall-tail-calls.ll
  llvm/test/CodeGen/RISCV/mul.ll
  llvm/test/CodeGen/RISCV/rem.ll
  llvm/test/CodeGen/RISCV/srem-lkk.ll
  llvm/test/CodeGen/RISCV/urem-lkk.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131087.449731.patch
Type: text/x-patch
Size: 64112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220803/3b4240a4/attachment.bin>


More information about the llvm-commits mailing list