diff options
author | Hari Limaye <hari.limaye@arm.com> | 2024-07-25 09:03:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 09:03:48 +0100 |
commit | dc1c00f6b13f724154f9883990f8b21fb8dcccef (patch) | |
tree | a87b34157f3555ef86b84de05477bd53bdcdbf6a /llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp | |
parent | 91450f1b57b34034376662dae5452af8c992c103 (diff) | |
download | llvm-dc1c00f6b13f724154f9883990f8b21fb8dcccef.zip llvm-dc1c00f6b13f724154f9883990f8b21fb8dcccef.tar.gz llvm-dc1c00f6b13f724154f9883990f8b21fb8dcccef.tar.bz2 |
[StackFrameLayoutAnalysis] Use target-specific hook for SP offsets (#100386)
StackFrameLayoutAnalysis currently calculates SP-relative offsets in a
target-independent way via MachineFrameInfo offsets. This is incorrect
for some Targets, e.g. AArch64, when there are scalable vector stack
slots.
This patch adds a virtual function to TargetFrameLowering to provide
offsets from SP, with a default implementation matching what is
currently used in StackFrameLayoutAnalysis, and refactors
StackFrameLayoutAnalysis to use this function. Only non-zero scalable
offsets are output by the analysis pass.
An implementation of this function is added for AArch64 targets, which
aims to provide correct SP offsets in most cases.
Diffstat (limited to 'llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp b/llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp index 48a2094..7d054cb 100644 --- a/llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp +++ b/llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp @@ -61,6 +61,20 @@ TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI, MFI.getOffsetAdjustment()); } +/// Returns the offset from the stack pointer to the slot of the specified +/// index. This function serves to provide a comparable offset from a single +/// reference point (the value of the stack-pointer at function entry) that can +/// be used for analysis. This is the default implementation using +/// MachineFrameInfo offsets. +StackOffset +TargetFrameLowering::getFrameIndexReferenceFromSP(const MachineFunction &MF, + int FI) const { + // To display the true offset from SP, we need to subtract the offset to the + // local area from MFI's ObjectOffset. + return StackOffset::getFixed(MF.getFrameInfo().getObjectOffset(FI) - + getOffsetOfLocalArea()); +} + bool TargetFrameLowering::needsFrameIndexResolution( const MachineFunction &MF) const { return MF.getFrameInfo().hasStackObjects(); |