[llvm] 061a94e - Revert "AArch64: Fix frame record chain"
Logan Chien via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 14 14:02:50 PST 2019
Author: Logan Chien
Date: 2019-12-14T13:58:40-08:00
New Revision: 061a94e4e28551662e3c70e312475580d0c9184e
URL: https://github.com/llvm/llvm-project/commit/061a94e4e28551662e3c70e312475580d0c9184e
DIFF: https://github.com/llvm/llvm-project/commit/061a94e4e28551662e3c70e312475580d0c9184e.diff
LOG: Revert "AArch64: Fix frame record chain"
Breaks aosp-O3-polly-before-vectorizer-unprofitable with the following
error message:
void llvm::emitFrameOffset(llvm::MachineBasicBlock &,
MachineBasicBlock::iterator, const llvm::DebugLoc &, unsigned int,
unsigned int, llvm::StackOffset, const llvm::TargetInstrInfo *,
MachineInstr::MIFlag, bool, bool, bool *): Assertion `(DestReg !=
AArch64::SP || Bytes % 16 == 0) && "SP increment/decrement not 16-byte
aligned"' failed.
This reverts commit d4e10e6adb1b629b3fc1b78f7e281fbcec392edb.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
Removed:
llvm/test/CodeGen/AArch64/framelayout-frame-record.mir
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index 50d1c9869488..c732106014e6 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -832,6 +832,10 @@ static bool needsWinCFI(const MachineFunction &MF) {
F.needsUnwindTableEntry();
}
+static bool isTargetDarwin(const MachineFunction &MF) {
+ return MF.getSubtarget<AArch64Subtarget>().isTargetDarwin();
+}
+
// Convenience function to determine whether I is an SVE callee save.
bool IsSVECalleeSave(MachineBasicBlock::iterator I) {
switch (I->getOpcode()) {
@@ -1012,7 +1016,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
if (HasFP) {
// Only set up FP if we actually need to.
- int64_t FPOffset = AFI->getCalleeSaveBaseToFrameRecordOffset();
+ int64_t FPOffset = isTargetDarwin(MF) ? (AFI->getCalleeSavedStackSize() - 16) : 0;
if (CombineSPBump)
FPOffset += AFI->getLocalStackSize();
@@ -1225,6 +1229,11 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
}
if (needsFrameMoves) {
+ const DataLayout &TD = MF.getDataLayout();
+ const int StackGrowth = isTargetDarwin(MF)
+ ? (2 * -TD.getPointerSize(0))
+ : -AFI->getCalleeSavedStackSize();
+ Register FramePtr = RegInfo->getFrameRegister(MF);
// An example of the prologue:
//
// .globl __foo
@@ -1292,15 +1301,10 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
// .cfi_offset w28, -32
if (HasFP) {
- const int OffsetToFirstCalleeSaveFromFP =
- AFI->getCalleeSaveBaseToFrameRecordOffset() -
- AFI->getCalleeSavedStackSize();
- Register FramePtr = RegInfo->getFrameRegister(MF);
-
// Define the current CFA rule to use the provided FP.
unsigned Reg = RegInfo->getDwarfRegNum(FramePtr, true);
unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa(
- nullptr, Reg, OffsetToFirstCalleeSaveFromFP - FixedObject));
+ nullptr, Reg, StackGrowth - FixedObject));
BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION))
.addCFIIndex(CFIIndex)
.setMIFlags(MachineInstr::FrameSetup);
@@ -1607,8 +1611,10 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
// non-post-indexed loads for the restores if we aren't actually going to
// be able to save any instructions.
if (!IsFunclet && (MFI.hasVarSizedObjects() || AFI->isStackRealigned())) {
+ int64_t OffsetToFrameRecord =
+ isTargetDarwin(MF) ? (-(int64_t)AFI->getCalleeSavedStackSize() + 16) : 0;
emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::FP,
- {-AFI->getCalleeSaveBaseToFrameRecordOffset(), MVT::i8},
+ {OffsetToFrameRecord, MVT::i8},
TII, MachineInstr::FrameDestroy, false, NeedsWinCFI);
} else if (NumBytes)
emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::SP,
@@ -1670,8 +1676,8 @@ static StackOffset getFPOffset(const MachineFunction &MF, int64_t ObjectOffset)
bool IsWin64 =
Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv());
unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0;
- unsigned FPAdjust = AFI->getCalleeSavedStackSize(MF.getFrameInfo()) -
- AFI->getCalleeSaveBaseToFrameRecordOffset();
+ unsigned FPAdjust = isTargetDarwin(MF)
+ ? 16 : AFI->getCalleeSavedStackSize(MF.getFrameInfo());
return {ObjectOffset + FixedObject + FPAdjust, MVT::i8};
}
@@ -1928,9 +1934,6 @@ static void computeCalleeSaveRegisterPairs(
if (CSI.empty())
return;
- const bool IsTargetWindows =
- MF.getSubtarget<AArch64Subtarget>().isTargetWindows();
-
bool NeedsWinCFI = needsWinCFI(MF);
AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
MachineFrameInfo &MFI = MF.getFrameInfo();
@@ -2055,14 +2058,6 @@ static void computeCalleeSaveRegisterPairs(
(RPI.isScalable() && RPI.Offset >= -256 && RPI.Offset <= 255)) &&
"Offset out of bounds for LDP/STP immediate");
- // Save the offset to frame record so that the FP register can point to the
- // innermost frame record (spilled FP and LR registers).
- if (NeedsFrameRecord && ((!IsTargetWindows && RPI.Reg1 == AArch64::LR &&
- RPI.Reg2 == AArch64::FP) ||
- (IsTargetWindows && RPI.Reg1 == AArch64::FP &&
- RPI.Reg2 == AArch64::LR)))
- AFI->setCalleeSaveBaseToFrameRecordOffset(Offset);
-
RegPairs.push_back(RPI);
if (RPI.isPaired())
++i;
diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
index 9e80f1202628..6ddb3fdb0046 100644
--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
@@ -126,10 +126,6 @@ class AArch64FunctionInfo final : public MachineFunctionInfo {
// stack slot.
unsigned TaggedBasePointerOffset = 0;
- // Offset from SP-after-callee-saved-spills (i.e. SP-at-entry minus
- // CalleeSavedStackSize) to the address of the frame record.
- int CalleeSaveBaseToFrameRecordOffset = 0;
-
public:
AArch64FunctionInfo() = default;
@@ -329,13 +325,6 @@ class AArch64FunctionInfo final : public MachineFunctionInfo {
TaggedBasePointerOffset = Offset;
}
- int getCalleeSaveBaseToFrameRecordOffset() const {
- return CalleeSaveBaseToFrameRecordOffset;
- }
- void setCalleeSaveBaseToFrameRecordOffset(int Offset) {
- CalleeSaveBaseToFrameRecordOffset = Offset;
- }
-
private:
// Hold the lists of LOHs.
MILOHContainer LOHContainerSet;
diff --git a/llvm/test/CodeGen/AArch64/framelayout-frame-record.mir b/llvm/test/CodeGen/AArch64/framelayout-frame-record.mir
deleted file mode 100644
index ab4af04401c5..000000000000
--- a/llvm/test/CodeGen/AArch64/framelayout-frame-record.mir
+++ /dev/null
@@ -1,29 +0,0 @@
-# RUN: llc -mtriple=aarch64-linux-gnu -start-before prologepilog %s -o - | FileCheck %s
-
----
-name: TestFrameRecordLocation
-tracksRegLiveness: true
-frameInfo:
- isFrameAddressTaken: true
-body: |
- bb.0:
- $d8 = IMPLICIT_DEF
- $d9 = IMPLICIT_DEF
- $x19 = IMPLICIT_DEF
- RET_ReallyLR
-
-# CHECK-LABEL: TestFrameRecordLocation
-
-# CHECK: stp d9, d8, [sp, #-48]!
-# CHECK: stp x29, x30, [sp, #16]
-# CHECK: str x19, [sp, #32]
-
-# CHECK: add x29, sp, #16
-
-# CHECK: .cfi_def_cfa w29, 32
-# CHECK: .cfi_offset w19, -16
-# CHECK: .cfi_offset w30, -24
-# CHECK: .cfi_offset w29, -32
-# CHECK: .cfi_offset b8, -40
-# CHECK: .cfi_offset b9, -48
-...
More information about the llvm-commits
mailing list