@@ -2548,15 +2548,15 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2548
2548
AFI->setLocalStackSize (NumBytes - PrologueSaveSize);
2549
2549
if (homogeneousPrologEpilog (MF, &MBB)) {
2550
2550
assert (!NeedsWinCFI);
2551
- auto LastPopI = MBB.getFirstTerminator ();
2552
- if (LastPopI != MBB.begin ()) {
2553
- auto HomogeneousEpilog = std::prev (LastPopI );
2551
+ auto FirstHomogenousEpilogI = MBB.getFirstTerminator ();
2552
+ if (FirstHomogenousEpilogI != MBB.begin ()) {
2553
+ auto HomogeneousEpilog = std::prev (FirstHomogenousEpilogI );
2554
2554
if (HomogeneousEpilog->getOpcode () == AArch64::HOM_Epilog)
2555
- LastPopI = HomogeneousEpilog;
2555
+ FirstHomogenousEpilogI = HomogeneousEpilog;
2556
2556
}
2557
2557
2558
2558
// Adjust local stack
2559
- emitFrameOffset (MBB, LastPopI , DL, AArch64::SP, AArch64::SP,
2559
+ emitFrameOffset (MBB, FirstHomogenousEpilogI , DL, AArch64::SP, AArch64::SP,
2560
2560
StackOffset::getFixed (AFI->getLocalStackSize ()), TII,
2561
2561
MachineInstr::FrameDestroy, false , NeedsWinCFI, &HasWinCFI);
2562
2562
@@ -2602,17 +2602,17 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2602
2602
// Move past the restores of the callee-saved registers.
2603
2603
// If we plan on combining the sp bump of the local stack size and the callee
2604
2604
// save stack size, we might need to adjust the CSR save and restore offsets.
2605
- MachineBasicBlock::iterator LastPopI = MBB.getFirstTerminator ();
2605
+ MachineBasicBlock::iterator FirstGPRRestoreI = MBB.getFirstTerminator ();
2606
2606
MachineBasicBlock::iterator Begin = MBB.begin ();
2607
- while (LastPopI != Begin) {
2608
- --LastPopI ;
2609
- if (!LastPopI ->getFlag (MachineInstr::FrameDestroy) ||
2610
- (!FPAfterSVECalleeSaves && IsSVECalleeSave (LastPopI ))) {
2611
- ++LastPopI ;
2607
+ while (FirstGPRRestoreI != Begin) {
2608
+ --FirstGPRRestoreI ;
2609
+ if (!FirstGPRRestoreI ->getFlag (MachineInstr::FrameDestroy) ||
2610
+ (!FPAfterSVECalleeSaves && IsSVECalleeSave (FirstGPRRestoreI ))) {
2611
+ ++FirstGPRRestoreI ;
2612
2612
break ;
2613
2613
} else if (CombineSPBump)
2614
- fixupCalleeSaveRestoreStackOffset (*LastPopI, AFI-> getLocalStackSize (),
2615
- NeedsWinCFI, &HasWinCFI);
2614
+ fixupCalleeSaveRestoreStackOffset (
2615
+ *FirstGPRRestoreI, AFI-> getLocalStackSize (), NeedsWinCFI, &HasWinCFI);
2616
2616
}
2617
2617
2618
2618
if (NeedsWinCFI) {
@@ -2622,9 +2622,9 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2622
2622
// arguments. Insert the SEH_EpilogStart and remove it later if it
2623
2623
// we didn't emit any SEH opcodes to avoid generating WinCFI for
2624
2624
// functions that don't need it.
2625
- BuildMI (MBB, LastPopI , DL, TII->get (AArch64::SEH_EpilogStart))
2625
+ BuildMI (MBB, FirstGPRRestoreI , DL, TII->get (AArch64::SEH_EpilogStart))
2626
2626
.setMIFlag (MachineInstr::FrameDestroy);
2627
- EpilogStartI = LastPopI ;
2627
+ EpilogStartI = FirstGPRRestoreI ;
2628
2628
--EpilogStartI;
2629
2629
}
2630
2630
@@ -2665,7 +2665,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2665
2665
2666
2666
// When we are about to restore the CSRs, the CFA register is SP again.
2667
2667
if (EmitCFI && hasFP (MF))
2668
- CFIInstBuilder (MBB, LastPopI , MachineInstr::FrameDestroy)
2668
+ CFIInstBuilder (MBB, FirstGPRRestoreI , MachineInstr::FrameDestroy)
2669
2669
.buildDefCFA (AArch64::SP, NumBytes);
2670
2670
2671
2671
emitFrameOffset (MBB, MBB.getFirstTerminator (), DL, AArch64::SP, AArch64::SP,
@@ -2681,7 +2681,8 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2681
2681
// Process the SVE callee-saves to determine what space needs to be
2682
2682
// deallocated.
2683
2683
StackOffset DeallocateBefore = {}, DeallocateAfter = SVEStackSize;
2684
- MachineBasicBlock::iterator RestoreBegin = LastPopI, RestoreEnd = LastPopI;
2684
+ MachineBasicBlock::iterator RestoreBegin = FirstGPRRestoreI,
2685
+ RestoreEnd = FirstGPRRestoreI;
2685
2686
if (int64_t CalleeSavedSize = AFI->getSVECalleeSavedStackSize ()) {
2686
2687
if (FPAfterSVECalleeSaves)
2687
2688
RestoreEnd = MBB.getFirstTerminator ();
@@ -2706,7 +2707,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2706
2707
// deallocates non-callee-save SVE allocations. Otherwise, deallocate
2707
2708
// them explicitly.
2708
2709
if (!AFI->isStackRealigned () && !MFI.hasVarSizedObjects ()) {
2709
- emitFrameOffset (MBB, LastPopI , DL, AArch64::SP, AArch64::SP,
2710
+ emitFrameOffset (MBB, FirstGPRRestoreI , DL, AArch64::SP, AArch64::SP,
2710
2711
DeallocateBefore, TII, MachineInstr::FrameDestroy, false ,
2711
2712
NeedsWinCFI, &HasWinCFI);
2712
2713
}
@@ -2796,7 +2797,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2796
2797
StackRestoreBytes += AfterCSRPopSize;
2797
2798
2798
2799
emitFrameOffset (
2799
- MBB, LastPopI , DL, AArch64::SP, AArch64::SP,
2800
+ MBB, FirstGPRRestoreI , DL, AArch64::SP, AArch64::SP,
2800
2801
StackOffset::getFixed (StackRestoreBytes), TII,
2801
2802
MachineInstr::FrameDestroy, false , NeedsWinCFI, &HasWinCFI, EmitCFI,
2802
2803
StackOffset::getFixed ((RedZone ? 0 : NumBytes) + PrologueSaveSize));
@@ -2816,17 +2817,17 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
2816
2817
// be able to save any instructions.
2817
2818
if (!IsFunclet && (MFI.hasVarSizedObjects () || AFI->isStackRealigned ())) {
2818
2819
emitFrameOffset (
2819
- MBB, LastPopI , DL, AArch64::SP, AArch64::FP,
2820
+ MBB, FirstGPRRestoreI , DL, AArch64::SP, AArch64::FP,
2820
2821
StackOffset::getFixed (-AFI->getCalleeSaveBaseToFrameRecordOffset ()),
2821
2822
TII, MachineInstr::FrameDestroy, false , NeedsWinCFI, &HasWinCFI);
2822
2823
} else if (NumBytes)
2823
- emitFrameOffset (MBB, LastPopI , DL, AArch64::SP, AArch64::SP,
2824
+ emitFrameOffset (MBB, FirstGPRRestoreI , DL, AArch64::SP, AArch64::SP,
2824
2825
StackOffset::getFixed (NumBytes), TII,
2825
2826
MachineInstr::FrameDestroy, false , NeedsWinCFI, &HasWinCFI);
2826
2827
2827
2828
// When we are about to restore the CSRs, the CFA register is SP again.
2828
2829
if (EmitCFI && hasFP (MF))
2829
- CFIInstBuilder (MBB, LastPopI , MachineInstr::FrameDestroy)
2830
+ CFIInstBuilder (MBB, FirstGPRRestoreI , MachineInstr::FrameDestroy)
2830
2831
.buildDefCFA (AArch64::SP, PrologueSaveSize);
2831
2832
2832
2833
// This must be placed after the callee-save restore code because that code
0 commit comments