aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/PrologEpilogInserter.cpp
diff options
context:
space:
mode:
authorTim Northover <t.p.northover@gmail.com>2021-01-20 10:14:03 +0000
committerTim Northover <t.p.northover@gmail.com>2021-05-14 11:43:58 +0100
commitea0eec69f16e0f1b00fec413986e4e44f6f627fa (patch)
tree4fdaa3d71b5910e637de6d7ecce32ea37bdedb83 /llvm/lib/CodeGen/PrologEpilogInserter.cpp
parent079bbea2b20dbfd24e4df654bae1c4324dcde754 (diff)
downloadllvm-ea0eec69f16e0f1b00fec413986e4e44f6f627fa.zip
llvm-ea0eec69f16e0f1b00fec413986e4e44f6f627fa.tar.gz
llvm-ea0eec69f16e0f1b00fec413986e4e44f6f627fa.tar.bz2
IR+AArch64: add a "swiftasync" argument attribute.
This extends any frame record created in the function to include that parameter, passed in X22. The new record looks like [X22, FP, LR] in memory, and FP is stored with 0b0001 in bits 63:60 (CodeGen assumes they are 0b0000 in normal operation). The effect of this is that tools walking the stack should expect to see one of three values there: * 0b0000 => a normal, non-extended record with just [FP, LR] * 0b0001 => the extended record [X22, FP, LR] * 0b1111 => kernel space, and a non-extended record. All other values are currently reserved. If compiling for arm64e this context pointer is address-discriminated with the discriminator 0xc31a and the DB (process-specific) key. There is also an "i8** @llvm.swift.async.context.addr()" intrinsic providing front-ends access to this slot (and forcing its creation initialized to nullptr if necessary).
Diffstat (limited to 'llvm/lib/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r--llvm/lib/CodeGen/PrologEpilogInserter.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index cccab5f..c12417a 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -399,7 +399,8 @@ static void assignCalleeSavedSpillSlots(MachineFunction &F,
const TargetFrameLowering *TFI = F.getSubtarget().getFrameLowering();
MachineFrameInfo &MFI = F.getFrameInfo();
- if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI)) {
+ if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI, MinCSFrameIndex,
+ MaxCSFrameIndex)) {
// If target doesn't implement this, use generic code.
if (CSI.empty())
@@ -677,10 +678,12 @@ computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown,
// StackSlot scavenging is only implemented for the default stack.
if (MFI.getStackID(i) == TargetStackID::Default)
AllocatedFrameSlots.push_back(i);
- // Add callee-save objects.
- for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
- if (MFI.getStackID(i) == TargetStackID::Default)
- AllocatedFrameSlots.push_back(i);
+ // Add callee-save objects if there are any.
+ if (MinCSFrameIndex <= MaxCSFrameIndex) {
+ for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
+ if (MFI.getStackID(i) == TargetStackID::Default)
+ AllocatedFrameSlots.push_back(i);
+ }
for (int i : AllocatedFrameSlots) {
// These are converted from int64_t, but they should always fit in int
@@ -833,7 +836,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
// First assign frame offsets to stack objects that are used to spill
// callee saved registers.
- if (StackGrowsDown) {
+ if (StackGrowsDown && MaxCSFrameIndex >= MinCSFrameIndex) {
for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
if (MFI.getStackID(i) !=
TargetStackID::Default) // Only allocate objects on the default stack.