llvm-project/llvm/test/CodeGen/Mips/cconv
Simon Dardis 9d7e9032f1 [mips] Don't create nested CALLSEQ_START..CALLSEQ_END nodes.
For the MIPS O32 ABI, the current call lowering logic naively lowers each
call, creating the reserved argument area to hold the argument spill areas for
$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..end of the argument into the outgoing parameter area.
This is done within 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 a red-zone and writing below the
stack pointer and reading the values back is unpredictable, 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.

Reviewers: abeserminji, atanasyan

Differential Revision: https://reviews.llvm.org/D44296

llvm-svn: 327388
2018-03-13 12:50:03 +00:00
..
arguments-float.ll
arguments-fp128.ll
arguments-hard-float-varargs.ll
arguments-hard-float.ll
arguments-hard-fp128.ll
arguments-small-structures-bigger-than-32bits.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
arguments-struct.ll
arguments-varargs-small-structs-byte.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
arguments-varargs-small-structs-combinations.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
arguments-varargs-small-structs-multiple-args.ll
arguments-varargs.ll
arguments.ll
byval.ll [mips] Don't create nested CALLSEQ_START..CALLSEQ_END nodes. 2018-03-13 12:50:03 +00:00
callee-saved-float.ll [NFC] fix trivial typos in comments 2018-01-24 05:04:35 +00:00
callee-saved-fpxx.ll
callee-saved-fpxx1.ll
callee-saved.ll
memory-layout.ll
pr33883.ll
reserved-space.ll
return-float.ll
return-hard-float.ll
return-hard-fp128.ll
return-hard-struct-f128.ll
return-struct.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
return.ll
roundl-call.ll
stack-alignment.ll
vector.ll [SelectionDAG] Add initial implementation of TargetLowering::SimplifyDemandedVectorElts 2018-02-15 12:14:15 +00:00