[PATCH] D40876: AArch64: Fix emergency spillslot being out of reach for large callframes

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 18:12:05 PST 2017


MatzeB created this revision.
Herald added subscribers: kristof.beyls, javed.absar, mcrosier.

Large callframes (calls with several hundreds or thousands or
parameters) could lead to situations in which the emergency spillslot is
out of range to be addressed relative to the stack pointer.
This commit forces the use of a frame pointer in the presence of large
callframes.

This commit does several things:

- Compute max callframe size at the end of instruction selection.
- Add mirFileLoaded target callback. Use it to compute the max callframe size after loading a .mir file when the size wasn't specified in the file.
- Let TargetFrameLowering::hasFP() return true if there exists a callframe > 255 bytes.
- Always place the emergency spillslot close to FP if we have a frame pointer.
- Note that `useFPForScavengingIndex()` would previously return false when a base pointer was available leading to the emergency spillslot getting allocated late (that's the whole effect of this callback). Which made no sense to me so I took this case out: Even though the emergency spillslot is technically not referenced by FP in this case we still want it allocated early.

I'm still in the process of coming up with a reliable and good testcase. As testcases with hundred of arguments are unwieldy I will probably end up placing a correctness test into the llvm test-suite for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D40876

Files:
  include/llvm/CodeGen/TargetSubtargetInfo.h
  lib/CodeGen/MIRParser/MIRParser.cpp
  lib/CodeGen/TargetSubtargetInfo.cpp
  lib/Target/AArch64/AArch64FrameLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.h
  lib/Target/AArch64/AArch64RegisterInfo.cpp
  lib/Target/AArch64/AArch64Subtarget.cpp
  lib/Target/AArch64/AArch64Subtarget.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40876.125663.patch
Type: text/x-patch
Size: 6483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171206/a922a3f2/attachment.bin>


More information about the llvm-commits mailing list