[PATCH] D120668: [CodeGen] Use AdjustStackOffset for Callee Saved Registers in PEI::calculateFrameObjectOffsets
Daniel McIntosh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 10:22:11 PST 2022
DanielMcIntosh-IBM created this revision.
DanielMcIntosh-IBM added reviewers: void, arsenm, sdesmalen, MatzeB, thegameg.
Herald added a subscriber: hiraditya.
DanielMcIntosh-IBM requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120668
Files:
llvm/lib/CodeGen/PrologEpilogInserter.cpp
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
===================================================================
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -856,47 +856,34 @@
if (FixedOff > Offset) Offset = FixedOff;
}
+ Align MaxAlign = MFI.getMaxAlign();
// First assign frame offsets to stack objects that are used to spill
// callee saved registers.
- if (StackGrowsDown && MaxCSFrameIndex >= MinCSFrameIndex) {
- for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
- if (MFI.getStackID(i) !=
- TargetStackID::Default) // Only allocate objects on the default stack.
- continue;
+ if (MaxCSFrameIndex >= MinCSFrameIndex) {
+ for (unsigned i = 0; i <= MaxCSFrameIndex - MinCSFrameIndex; ++i) {
+ unsigned FrameIndex =
+ StackGrowsDown ? MinCSFrameIndex + i : MaxCSFrameIndex - i;
- // If the stack grows down, we need to add the size to find the lowest
- // address of the object.
- Offset += MFI.getObjectSize(i);
-
- // Adjust to alignment boundary
- Offset = alignTo(Offset, MFI.getObjectAlign(i), Skew);
-
- LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << -Offset << "]\n");
- MFI.setObjectOffset(i, -Offset); // Set the computed offset
- }
- } else if (MaxCSFrameIndex >= MinCSFrameIndex) {
- // Be careful about underflow in comparisons agains MinCSFrameIndex.
- for (unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
- if (MFI.getStackID(i) !=
- TargetStackID::Default) // Only allocate objects on the default stack.
+ // Only allocate objects on the default stack.
+ if (MFI.getStackID(FrameIndex) != TargetStackID::Default)
continue;
- if (MFI.isDeadObjectIndex(i))
+ // TODO: should this just be if (MFI.isDeadObjectIndex(FrameIndex))
+ if (!StackGrowsDown && MFI.isDeadObjectIndex(FrameIndex))
continue;
- // Adjust to alignment boundary
- Offset = alignTo(Offset, MFI.getObjectAlign(i), Skew);
-
- LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << Offset << "]\n");
- MFI.setObjectOffset(i, Offset);
- Offset += MFI.getObjectSize(i);
+ AdjustStackOffset(MFI, FrameIndex, StackGrowsDown, Offset, MaxAlign,
+ Skew);
}
}
+ assert(MaxAlign == MFI.getMaxAlign() &&
+ "MFI.getMaxAlign should already account for all callee-saved "
+ "registers without a fixed stack slot");
+
// FixedCSEnd is the stack offset to the end of the fixed and callee-save
// stack area.
int64_t FixedCSEnd = Offset;
- Align MaxAlign = MFI.getMaxAlign();
// Make sure the special register scavenging spill slot is closest to the
// incoming stack pointer if a frame pointer is required and is closer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120668.411836.patch
Type: text/x-patch
Size: 2851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220228/7624d450/attachment.bin>
More information about the llvm-commits
mailing list