@@ -321,7 +321,7 @@ bool AArch64FrameLowering::homogeneousPrologEpilog(
321
321
return false ;
322
322
323
323
auto *AFI = MF.getInfo <AArch64FunctionInfo>();
324
- if (AFI->hasSwiftAsyncContext () || AFI->hasStreamingModeChanges ( ))
324
+ if (AFI->hasSwiftAsyncContext () || AFI->requiresVGSpill (MF ))
325
325
return false ;
326
326
327
327
// If there are an odd number of GPRs before LR and FP in the CSRs list,
@@ -567,7 +567,7 @@ void AArch64FrameLowering::emitCalleeSavedGPRLocations(
567
567
continue ;
568
568
569
569
assert (!Info.isSpilledToReg () && " Spilling to registers not implemented" );
570
- unsigned DwarfReg = TRI.getDwarfRegNum (Info.getReg (), true );
570
+ int64_t DwarfReg = TRI.getDwarfRegNum (Info.getReg (), true );
571
571
int64_t Offset = MFI.getObjectOffset (FrameIdx) - getOffsetOfLocalArea ();
572
572
573
573
// Locally streaming functions save two values for VG, but we should only
@@ -1361,8 +1361,9 @@ static MachineBasicBlock::iterator convertCalleeSaveRestoreToSPPrePostIncDec(
1361
1361
// vector length. Move past these instructions if necessary.
1362
1362
unsigned Opc = MBBI->getOpcode ();
1363
1363
if (Opc == AArch64::CNTD_XPiI || Opc == AArch64::RDSVLI_XI) {
1364
- AArch64FunctionInfo AFI = *MBB.getParent ()->getInfo <AArch64FunctionInfo>();
1365
- assert (AFI.hasStreamingModeChanges () &&
1364
+ MachineFunction &MF = *MBB.getParent ();
1365
+ AArch64FunctionInfo *AFI = MF.getInfo <AArch64FunctionInfo>();
1366
+ assert (AFI->requiresVGSpill (MF) &&
1366
1367
" Unexpected callee-save save/restore opcode!" );
1367
1368
++MBBI;
1368
1369
if (MBBI->getOpcode () == AArch64::UBFMXri)
@@ -1862,10 +1863,11 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1862
1863
!IsSVECalleeSave (MBBI)) {
1863
1864
unsigned Opc = MBBI->getOpcode ();
1864
1865
// Move past instructions generated to calculate VG
1865
- if (Opc == AArch64::CNTD_XPiI || Opc == AArch64::RDSVLI_XI ||
1866
- Opc == AArch64::UBFMXri) {
1867
- assert (AFI->hasStreamingModeChanges () && " Unexpected opcode!" );
1866
+ if (Opc == AArch64::CNTD_XPiI || Opc == AArch64::RDSVLI_XI) {
1867
+ assert (AFI->requiresVGSpill (MF) && " Unexpected opcode!" );
1868
1868
++MBBI;
1869
+ if (MBBI->getOpcode () == AArch64::UBFMXri)
1870
+ ++MBBI;
1869
1871
}
1870
1872
if (CombineSPBump)
1871
1873
fixupCalleeSaveRestoreStackOffset (*MBBI, AFI->getLocalStackSize (),
@@ -3017,11 +3019,10 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
3017
3019
ArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const {
3018
3020
MachineFunction &MF = *MBB.getParent ();
3019
3021
const TargetInstrInfo &TII = *MF.getSubtarget ().getInstrInfo ();
3022
+ AArch64FunctionInfo *AFI = MF.getInfo <AArch64FunctionInfo>();
3020
3023
bool NeedsWinCFI = needsWinCFI (MF);
3021
3024
DebugLoc DL;
3022
3025
SmallVector<RegPairInfo, 8 > RegPairs;
3023
- bool SpilledStreamingVG = false ;
3024
- MachineFrameInfo &MFI = MF.getFrameInfo ();
3025
3026
3026
3027
computeCalleeSaveRegisterPairs (MF, CSI, TRI, RegPairs, hasFP (MF));
3027
3028
@@ -3099,7 +3100,7 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
3099
3100
SMEAttrs Attrs (MF.getFunction ());
3100
3101
3101
3102
if (Attrs.hasStreamingBody () && !Attrs.hasStreamingInterface () &&
3102
- !SpilledStreamingVG ) {
3103
+ AFI-> getStreamingVGIdx () == std::numeric_limits< int >:: max () ) {
3103
3104
// For locally-streaming functions, we need to store both the streaming
3104
3105
// & non-streaming VG. Spill the streaming value first.
3105
3106
BuildMI (MBB, MI, DL, TII.get (AArch64::RDSVLI_XI), Reg1)
@@ -3111,9 +3112,7 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
3111
3112
.addImm (63 )
3112
3113
.setMIFlag (MachineInstr::FrameSetup);
3113
3114
3114
- AArch64FunctionInfo *AFI = MF.getInfo <AArch64FunctionInfo>();
3115
3115
AFI->setStreamingVGIdx (RPI.FrameIdx );
3116
- SpilledStreamingVG = true ;
3117
3116
} else {
3118
3117
BuildMI (MBB, MI, DL, TII.get (AArch64::CNTD_XPiI), Reg1)
3119
3118
.addImm (31 )
@@ -3394,7 +3393,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
3394
3393
// non-streaming VG value.
3395
3394
const Function &F = MF.getFunction ();
3396
3395
SMEAttrs Attrs (F);
3397
- if (AFI->hasStreamingModeChanges () && F. needsUnwindTableEntry ( )) {
3396
+ if (AFI->requiresVGSpill (MF )) {
3398
3397
if (Attrs.hasStreamingBody () && !Attrs.hasStreamingInterface ())
3399
3398
CSStackSize += 16 ;
3400
3399
else
@@ -3538,8 +3537,7 @@ bool AArch64FrameLowering::assignCalleeSavedSpillSlots(
3538
3537
}
3539
3538
3540
3539
// Insert VG into the list of CSRs, immediately before LR if saved.
3541
- const Function &F = MF.getFunction ();
3542
- if (AFI->hasStreamingModeChanges () && F.needsUnwindTableEntry ()) {
3540
+ if (AFI->requiresVGSpill (MF)) {
3543
3541
std::vector<CalleeSavedInfo> VGSaves;
3544
3542
SMEAttrs Attrs (MF.getFunction ());
3545
3543
0 commit comments