[PATCH] D44296: [mips] Don't create nested CALLSEQ_START..CALLSEQ_END nodes.

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 03:21:42 PST 2018


sdardis created this revision.
sdardis added reviewers: abeserminji, atanasyan.
Herald added a subscriber: arichardson.

For the MIPS O32 ABI, the current call lowering logic naively lowers each
call, creating the reserved argument area to hold the spill areas a0..a3 and
the outgoing parameter area if one is required at each call site.

In the case of a sufficently large byval argument, a call to memcpy is used
to write the start+16 to end into the outgoing parameter area. This is done
with the CALLSEQ_START..CALLSEQ_END of the callee. The CALLSEQ nodes are
responsible for performing the necessary stack adjustments.

Since the O32/N32/N64 MIPS ABIs do not have red-zone and writing below the
stack pointer and reading the back is unpredicatible, the call to memcpy
cannot be hoisted out of the callee's CALLSEQ nodes.

However, for the O32 ABI requires the reserved argument area for functions
which have parameters. The naive lowering of calls will then create nested
CALLSEQ sequences. For N32 and N64 these nodes are also created, but with
zero stack adjustments as those ABIs do not have a reserved argument area.

This patch addresses the correctness issue by recognizing the special case
of lowering a byval argument that uses memcpy. By recognizing that the
incoming chain already has a CALLSEQ_START node on it when calling memcpy,
the CALLSEQ nodes are not created. For the N32 and N64 ABIs, this is not an
issue, as no stack adjustment has to be performed.

For the O32 ABI, the correctness reasoning is different. In the case of a
sufficently large byval argument, registers a0..a3 are going to be used for
the callee's arguments, mandating the creation of the reserved argument area.
The call to memcpy in the naive case will also create its own reserved
argument area. However, since the reserved argument area consists of undefined
values, both calls can use the same reserved argument area.


Repository:
  rL LLVM

https://reviews.llvm.org/D44296

Files:
  lib/Target/Mips/MipsISelLowering.cpp
  test/CodeGen/Mips/cconv/byval.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44296.137719.patch
Type: text/x-patch
Size: 21381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/638b1c97/attachment.bin>


More information about the llvm-commits mailing list