OSDN Git Service

[AArch64] Rewrite stack frame handling for win64 vararg functions
authorMartin Storsjo <martin@martin.st>
Tue, 1 Aug 2017 21:13:54 +0000 (21:13 +0000)
committerMartin Storsjo <martin@martin.st>
Tue, 1 Aug 2017 21:13:54 +0000 (21:13 +0000)
commit39bec211f05ca28c8b61d70fd5d9c030fd92d156
tree3a20ad1c9149cfb1ff4a8ffcb53b7b084c9d4cba
parentf9a65f9c7e982fb2a6ce7211fe38f105c8e2868c
[AArch64] Rewrite stack frame handling for win64 vararg functions

The previous attempt, which made do with a single offset in
computeCalleeSaveRegisterPairs, wasn't quite enough. The previous
attempt only worked as long as CombineSPBump == true (since the
offset would be adjusted later in fixupCalleeSaveRestoreStackOffset).

Instead include the size for the fixed stack area used for win64
varargs in calculations in emitPrologue/emitEpilogue. The stack
consists of mainly three parts;
- AFI->getLocalStackSize()
- AFI->getCalleeSavedStackSize()
- FixedObject

Most of the places in the code which previously used the CSStackSize
now use PrologueSaveSize instead, which is the sum of the latter
two, while some cases which need exactly the middle one use
AFI->getCalleeSavedStackSize() explicitly instead of a local variable.

In addition to moving the offsetting into emitPrologue/emitEpilogue
(which fixes functions with CombineSPBump == false), also set the
frame pointer to point to the right location, where the frame pointer
and link register actually are stored. In addition to the prologue/epilogue,
this also requires changes to resolveFrameIndexReference.

Add tests for a function that keeps a frame pointer and another one
that uses a VLA.

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

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