Skip to content

Commit 3245248

Browse files
committedJul 12, 2019
Factor out resolveFrameOffsetReference (NFC).
Split AArch64FrameLowering::resolveFrameIndexReference in two parts * Finding frame offset for the index. * Finding base register and offset to that register. The second part will be used to implement a virtual frame pointer in armv8.5 MTE stack instrumentation lowering. Reviewers: pcc, vitalybuka, hctim, ostannard Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64171 llvm-svn: 365958
1 parent a205ebb commit 3245248

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed
 

‎llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

+23-12
Original file line numberDiff line numberDiff line change
@@ -1508,43 +1508,54 @@ int AArch64FrameLowering::getNonLocalFrameIndexReference(
15081508
return getSEHFrameIndexOffset(MF, FI);
15091509
}
15101510

1511-
static int getFPOffset(const MachineFunction &MF, int FI) {
1512-
const auto &MFI = MF.getFrameInfo();
1511+
static int getFPOffset(const MachineFunction &MF, int ObjectOffset) {
15131512
const auto *AFI = MF.getInfo<AArch64FunctionInfo>();
15141513
const auto &Subtarget = MF.getSubtarget<AArch64Subtarget>();
15151514
bool IsWin64 =
15161515
Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv());
15171516
unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0;
1518-
return MFI.getObjectOffset(FI) + FixedObject + 16;
1517+
return ObjectOffset + FixedObject + 16;
15191518
}
15201519

1521-
static int getStackOffset(const MachineFunction &MF, int FI) {
1520+
static int getStackOffset(const MachineFunction &MF, int ObjectOffset) {
15221521
const auto &MFI = MF.getFrameInfo();
1523-
return MFI.getObjectOffset(FI) + MFI.getStackSize();
1522+
return ObjectOffset + MFI.getStackSize();
15241523
}
15251524

15261525
int AArch64FrameLowering::getSEHFrameIndexOffset(const MachineFunction &MF,
15271526
int FI) const {
15281527
const auto *RegInfo = static_cast<const AArch64RegisterInfo *>(
15291528
MF.getSubtarget().getRegisterInfo());
1530-
return RegInfo->getLocalAddressRegister(MF) == AArch64::FP ?
1531-
getFPOffset(MF, FI) : getStackOffset(MF, FI);
1529+
int ObjectOffset = MF.getFrameInfo().getObjectOffset(FI);
1530+
return RegInfo->getLocalAddressRegister(MF) == AArch64::FP
1531+
? getFPOffset(MF, ObjectOffset)
1532+
: getStackOffset(MF, ObjectOffset);
15321533
}
15331534

15341535
int AArch64FrameLowering::resolveFrameIndexReference(const MachineFunction &MF,
15351536
int FI, unsigned &FrameReg,
15361537
bool PreferFP,
15371538
bool ForSimm) const {
15381539
const auto &MFI = MF.getFrameInfo();
1540+
int ObjectOffset = MFI.getObjectOffset(FI);
1541+
bool isFixed = MFI.isFixedObjectIndex(FI);
1542+
return resolveFrameOffsetReference(MF, ObjectOffset, isFixed, FrameReg,
1543+
PreferFP, ForSimm);
1544+
}
1545+
1546+
int AArch64FrameLowering::resolveFrameOffsetReference(
1547+
const MachineFunction &MF, int ObjectOffset, bool isFixed,
1548+
unsigned &FrameReg, bool PreferFP, bool ForSimm) const {
1549+
const auto &MFI = MF.getFrameInfo();
15391550
const auto *RegInfo = static_cast<const AArch64RegisterInfo *>(
15401551
MF.getSubtarget().getRegisterInfo());
15411552
const auto *AFI = MF.getInfo<AArch64FunctionInfo>();
15421553
const auto &Subtarget = MF.getSubtarget<AArch64Subtarget>();
1543-
int FPOffset = getFPOffset(MF, FI);
1544-
int Offset = getStackOffset(MF, FI);
1545-
bool isFixed = MFI.isFixedObjectIndex(FI);
1546-
bool isCSR = !isFixed && MFI.getObjectOffset(FI) >=
1547-
-((int)AFI->getCalleeSavedStackSize());
1554+
1555+
int FPOffset = getFPOffset(MF, ObjectOffset);
1556+
int Offset = getStackOffset(MF, ObjectOffset);
1557+
bool isCSR =
1558+
!isFixed && ObjectOffset >= -((int)AFI->getCalleeSavedStackSize());
15481559

15491560
// Use frame pointer to reference fixed objects. Use it for locals if
15501561
// there are VLAs or a dynamically realigned SP (and thus the SP isn't

‎llvm/lib/Target/AArch64/AArch64FrameLowering.h

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class AArch64FrameLowering : public TargetFrameLowering {
4242
int resolveFrameIndexReference(const MachineFunction &MF, int FI,
4343
unsigned &FrameReg, bool PreferFP,
4444
bool ForSimm) const;
45+
int resolveFrameOffsetReference(const MachineFunction &MF, int ObjectOffset,
46+
bool isFixed, unsigned &FrameReg,
47+
bool PreferFP, bool ForSimm) const;
4548
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
4649
MachineBasicBlock::iterator MI,
4750
const std::vector<CalleeSavedInfo> &CSI,

0 commit comments

Comments
 (0)
Please sign in to comment.