Skip to content

Commit d4c86e7

Browse files
authored
[AArch64][SME] Fix frame lowering not using a base pointer for SME functions. (#91643)
The existing code is checking for the presence of the +sve subtarget feature when deciding to use a base pointer for the function, but this check doesn't work when only +sme is used. rdar://126878490
1 parent 4cfe347 commit d4c86e7

File tree

3 files changed

+1081
-2
lines changed

3 files changed

+1081
-2
lines changed

llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ bool AArch64RegisterInfo::hasBasePointer(const MachineFunction &MF) const {
552552
if (hasStackRealignment(MF))
553553
return true;
554554

555-
if (MF.getSubtarget<AArch64Subtarget>().hasSVE()) {
555+
auto &ST = MF.getSubtarget<AArch64Subtarget>();
556+
if (ST.hasSVE() || ST.isStreaming()) {
556557
const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
557558
// Frames that have variable sized objects and scalable SVE objects,
558559
// should always use a basepointer.

llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass=prologepilog -mattr=+sve %s -o - | FileCheck %s
1+
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass=prologepilog %s -o - | FileCheck %s
2+
--- |
3+
define void @hasBasepointer() #0 { ret void }
4+
define void @hasBasepointer_sme_streaming() #1 { ret void }
5+
6+
attributes #0 = { "target-features"="+sve" }
7+
attributes #1 = { "target-features"="+sme" "aarch64_pstate_sm_enabled" }
8+
...
29
---
310
# This test verifies that the basepointer is available in presence of SVE stack objects.
411
name: hasBasepointer
@@ -21,3 +28,25 @@ body: |
2128
STRXui $x0, %stack.1, 0
2229
RET_ReallyLR
2330
...
31+
---
32+
# Likewise with only SME with a streaming function.
33+
name: hasBasepointer_sme_streaming
34+
# CHECK-LABEL: name: hasBasepointer_sme_streaming
35+
# CHECK: bb.0:
36+
# CHECK: $sp = frame-setup SUBXri $sp, 16, 0
37+
# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1
38+
# CHECK-NEXT: $x19 = ADDXri $sp, 0, 0
39+
# CHECK: STRXui $x0, $x19, 0
40+
tracksRegLiveness: true
41+
frameInfo:
42+
isFrameAddressTaken: true
43+
stack:
44+
- { id: 0, type: variable-sized, alignment: 1 }
45+
- { id: 1, name: '', size: 16, alignment: 8 }
46+
- { id: 2, stack-id: scalable-vector, size: 16, alignment: 16 }
47+
body: |
48+
bb.0:
49+
liveins: $x0
50+
STRXui $x0, %stack.1, 0
51+
RET_ReallyLR
52+
...

0 commit comments

Comments
 (0)