OSDN Git Service

[AArch64] Reserve a 16 byte aligned amount of fixed stack for win64 varargs
authorMartin Storsjo <martin@martin.st>
Tue, 25 Jul 2017 05:20:01 +0000 (05:20 +0000)
committerMartin Storsjo <martin@martin.st>
Tue, 25 Jul 2017 05:20:01 +0000 (05:20 +0000)
commita663d7321b10767e45834ac96da94fd958e4934d
tree0398e686aaaa1d3fbca9e846f6dfa09fd7c0b748
parent2250b309ad7610ab82e4c28f0d9a0f565420a79f
[AArch64] Reserve a 16 byte aligned amount of fixed stack for win64 varargs

Create a dummy 8 byte fixed object for the unused slot below the first
stored vararg.

Alternative ideas tested but skipped: One could try to align the whole
fixed object to 16, but I haven't found how to add an offset to the stack
frame used in LowerWin64_VASTART.

If only the size of the fixed stack object size is padded but not the offset, via
MFI.CreateFixedObject(alignTo(GPRSaveSize, 16), -(int)GPRSaveSize, false),
PrologEpilogInserter crashes due to "Attempted to reset backwards range!".

This fixes misconceptions about where registers are spilled, since
AArch64FrameLowering.cpp assumes the offset from fixed objects is
aligned to 16 bytes (and the Win64 case there already manually aligns
the offset to 16 bytes).

This fixes cases where local stack allocations could overwrite callee
saved registers on the stack.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308950 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64ISelLowering.cpp
test/CodeGen/AArch64/aarch64_win64cc_vararg.ll
test/CodeGen/AArch64/win64_vararg.ll