[llvm] [AArch64][SME] Fix accessing the emergency spill slot with hazard padding (PR #142190)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Fri May 30 11:16:52 PDT 2025
================
@@ -632,14 +633,26 @@ bool AArch64RegisterInfo::hasBasePointer(const MachineFunction &MF) const {
return true;
auto &ST = MF.getSubtarget<AArch64Subtarget>();
+ const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
if (ST.hasSVE() || ST.isStreaming()) {
- const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
// Frames that have variable sized objects and scalable SVE objects,
// should always use a basepointer.
if (!AFI->hasCalculatedStackSizeSVE() || AFI->getStackSizeSVE())
return true;
}
+ // Frames with hazard padding can have a large offset between the frame
+ // pointer and GPR locals, which includes the emergency spill slot. If the
+ // emergency spill slot is not within range of the load/store instructions
+ // (which have a signed 9-bit range), we will fail to compile if it is used.
+ // Since hasBasePointer() is called before we know if we have hazard padding
+ // or an emergency spill slot we need to enable the basepointer
+ // conservatively.
+ if (AFI->hasStackHazardSlotIndex() ||
----------------
MacDue wrote:
It's a much cheaper check than parsing all the SME attributes and `hasBasePointer()` is called again repeatedly after we know we have hazard padding (e.g. when resolving frame indexes).
https://github.com/llvm/llvm-project/pull/142190
More information about the llvm-commits
mailing list