[PATCH] D108834: [X86] [pr51000] sret pointer tailcalling

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 27 11:12:51 PDT 2021


urnathan created this revision.
Herald added subscribers: pengfei, hiraditya, kristof.beyls.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch implements tailcalling from an sret-pointer-returning function.  Such functions can only tailcall sret-pointer-returning functions that we pass our own sret pointer to.  When lowering the formal parameters we record the SDValue holding our incoming sret.  When tail calling we check if we're passing that DAG value as the outgoing sret SDValue.  We still have to copy the incoming sret to a virtual register when lowering parms, as (at least with FastISel), the DAG is no longer valid at the point we generate the move to the physical register on an actual return.

We need to #include SelectionDAGNodes.h into Target/X86/X86MachineFunctionInfo.h in order to hold the SDValue.  An alternative would be to extract the SDNode from the value and record it as a void *, but that seems less clean.

sibcall.ll contains one test where the incoming sret parameter is no the first, which we then pass to a tail call as its sret argument.  This patch will tail call that now, which is correct, but I can't help feeling that sibcall test is invalid -- are there real cases where the sret argument is not first?

While this patch does not contain an integration test from C++ to assembler, to make sure we actually resolve pr51000, I do have one available.  It would be unpleasant to regress the bug report at some point.


https://reviews.llvm.org/D108834

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86MachineFunctionInfo.h
  llvm/test/CodeGen/X86/sibcall.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108834.369145.patch
Type: text/x-patch
Size: 8919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210827/84e838bc/attachment.bin>


More information about the llvm-commits mailing list