Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6263,6 +6263,11 @@ void llvm::emitFrameOffset(MachineBasicBlock &MBB,
AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
Offset, Bytes, NumPredicateVectors, NumDataVectors);

// Insert ADDSXri for scalable offset at the end.
bool NeedInsertADDS = SetNZCV && (NumPredicateVectors || NumDataVectors);
if (NeedInsertADDS)
SetNZCV = false;

// First emit non-scalable frame offsets, or a simple 'mov'.
if (Bytes || (!Offset && SrcReg != DestReg)) {
assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
Expand All @@ -6282,8 +6287,6 @@ void llvm::emitFrameOffset(MachineBasicBlock &MBB,
FrameReg = DestReg;
}

assert(!(SetNZCV && (NumPredicateVectors || NumDataVectors)) &&
"SetNZCV not supported with SVE vectors");
assert(!(NeedsWinCFI && NumPredicateVectors) &&
"WinCFI can't allocate fractions of an SVE data vector");

Expand All @@ -6303,6 +6306,12 @@ void llvm::emitFrameOffset(MachineBasicBlock &MBB,
Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
FrameReg);
}

if (NeedInsertADDS)
BuildMI(MBB, MBBI, DL, TII->get(AArch64::ADDSXri), DestReg)
.addReg(DestReg)
.addImm(0)
.addImm(0);
}

MachineInstr *AArch64InstrInfo::foldMemoryOperandImpl(
Expand Down
103 changes: 103 additions & 0 deletions llvm/test/CodeGen/AArch64/pr157252.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass prologepilog -o - %s | FileCheck %s
--- |
define void @i(ptr %ad, ptr %0) #0 {
entry:
ret void
}
declare i32 @g(...)
attributes #0 = { "frame-pointer"="non-leaf" "target-features"="+sve" }
...
---
name: i
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
failedISel: false
tracksRegLiveness: true
hasWinCFI: false
noPhis: true
isSSA: false
noVRegs: true
hasFakeUses: false
callsEHReturn: false
callsUnwindInit: false
hasEHContTarget: false
hasEHScopes: false
hasEHFunclets: false
isOutlined: false
debugInstrRef: false
failsVerification: false
tracksDebugUserValues: true
registers: []
liveins: []
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 16
adjustsStack: true
hasCalls: true
stackProtector: ''
functionContext: ''
maxCallFrameSize: 0
cvBytesOfCalleeSavedRegisters: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
hasTailCall: false
isCalleeSavedInfoValid: false
localFrameSize: 0
fixedStack: []
stack:
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
local-offset: -4, debug-info-variable: '', debug-info-expression: '',
debug-info-location: '' }
- { id: 3, name: '', type: spill-slot, offset: 0, size: 16, alignment: 16,
stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true,
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
entry_values: []
callSites: []
debugValueSubstitutions: []
constants: []
machineFunctionInfo: {}
body: |
bb.0:
; CHECK-LABEL: name: i
; CHECK: liveins: $d11, $lr, $x20, $x28
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: early-clobber $sp = frame-setup STRDpre killed $d11, $sp, -48 :: (store (s64) into %stack.6)
; CHECK-NEXT: frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.5), (store (s64) into %stack.4)
; CHECK-NEXT: frame-setup STPXi killed $x28, killed $x20, $sp, 4 :: (store (s64) into %stack.3), (store (s64) into %stack.2)
; CHECK-NEXT: $fp = frame-setup ADDXri $sp, 16, 0
; CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1, implicit $vg
; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa $w29, 32
; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w20, -8
; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w28, -16
; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -24
; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -32
; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $b11, -48
; CHECK-NEXT: $w20 = MOVi32imm 1
; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def dead early-clobber $q11
; CHECK-NEXT: BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $w0
; CHECK-NEXT: $x8 = ADDXri $sp, 12, 0
; CHECK-NEXT: $x8 = ADDVL_XXI $x8, 1, implicit $vg
; CHECK-NEXT: $x8 = ADDSXri $x8, 0, 0, implicit-def $nzcv
; CHECK-NEXT: $sp = frame-destroy ADDVL_XXI $sp, 1, implicit $vg
; CHECK-NEXT: $x28, $x20 = frame-destroy LDPXi $sp, 4 :: (load (s64) from %stack.3), (load (s64) from %stack.2)
; CHECK-NEXT: $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.5), (load (s64) from %stack.4)
; CHECK-NEXT: early-clobber $sp, $d11 = frame-destroy LDRDpost $sp, 48 :: (load (s64) from %stack.6)
; CHECK-NEXT: RET_ReallyLR
$w20 = MOVi32imm 1
INLINEASM &"", 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def dead early-clobber $q11
BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $w0
$x8 = ADDSXri %stack.0, 0, 0, implicit-def $nzcv
RET_ReallyLR
...

Loading