[PATCH] D71097: [X86] Don't setup and teardown memory for a musttail call

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 16:14:26 PST 2019


rnk created this revision.
rnk added a reviewer: hans.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

musttail calls should not require allocating extra stack for arguments.
Updates to arguments passed in memory should happen in place before the
epilogue.

This bug was mostly a missed optimization, unless inalloca was used and
store to push conversion fired.

If a reserved call frame was used for an inalloca musttail call, the
call setup and teardown instructions would be deleted, and SP
adjustments would be inserted in the prologue and epilogue. You can see
these are removed from several test cases in this change.

In the case where the stack frame was not reserved, i.e. call frame
optimization fires and turns argument stores into pushes, then the
imbalanced call frame setup instructions created for inalloca calls
become a problem. They remain in the instruction stream, resulting in a
call setup that allocates zero bytes (expected for inalloca), and a call
teardown that deallocates the inalloca pack. This deallocation was
unbalanced, leading to subsequent crashes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71097

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/cfguard-checks.ll
  llvm/test/CodeGen/X86/musttail-inalloca.ll
  llvm/test/CodeGen/X86/musttail-tailcc.ll
  llvm/test/CodeGen/X86/musttail-varargs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71097.232466.patch
Type: text/x-patch
Size: 12208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191206/0becc22e/attachment.bin>


More information about the llvm-commits mailing list