@@ -179,11 +179,6 @@ static cl::opt<bool> OrderFrameObjects("aarch64-order-frame-objects",
179
179
cl::desc (" sort stack allocations" ),
180
180
cl::init(true ), cl::Hidden);
181
181
182
- cl::opt<bool > EnableHomogeneousPrologEpilog (
183
- " homogeneous-prolog-epilog" , cl::init(false ), cl::ZeroOrMore, cl::Hidden,
184
- cl::desc(" Emit homogeneous prologue and epilogue for the size "
185
- " optimization (default = off)" ));
186
-
187
182
STATISTIC (NumRedZoneFunctions, " Number of functions using red zone" );
188
183
189
184
// / Returns the argument pop size.
@@ -218,47 +213,6 @@ static uint64_t getArgumentPopSize(MachineFunction &MF,
218
213
return ArgumentPopSize;
219
214
}
220
215
221
- static bool produceCompactUnwindFrame (MachineFunction &MF);
222
- static bool needsWinCFI (const MachineFunction &MF);
223
- static StackOffset getSVEStackSize (const MachineFunction &MF);
224
-
225
- // / Returns true if a homogeneous prolog or epilog code can be emitted
226
- // / for the size optimization. If possible, a frame helper call is injected.
227
- // / When Exit block is given, this check is for epilog.
228
- bool AArch64FrameLowering::homogeneousPrologEpilog (
229
- MachineFunction &MF, MachineBasicBlock *Exit) const {
230
- if (!MF.getFunction ().hasMinSize ())
231
- return false ;
232
- if (!EnableHomogeneousPrologEpilog)
233
- return false ;
234
- if (ReverseCSRRestoreSeq)
235
- return false ;
236
- if (EnableRedZone)
237
- return false ;
238
-
239
- // TODO: Window is supported yet.
240
- if (needsWinCFI (MF))
241
- return false ;
242
- // TODO: SVE is not supported yet.
243
- if (getSVEStackSize (MF))
244
- return false ;
245
-
246
- // Bail on stack adjustment needed on return for simplicity.
247
- const MachineFrameInfo &MFI = MF.getFrameInfo ();
248
- const TargetRegisterInfo *RegInfo = MF.getSubtarget ().getRegisterInfo ();
249
- if (MFI.hasVarSizedObjects () || RegInfo->needsStackRealignment (MF))
250
- return false ;
251
- if (Exit && getArgumentPopSize (MF, *Exit))
252
- return false ;
253
-
254
- return true ;
255
- }
256
-
257
- // / Returns true if CSRs should be paired.
258
- bool AArch64FrameLowering::producePairRegisters (MachineFunction &MF) const {
259
- return produceCompactUnwindFrame (MF) || homogeneousPrologEpilog (MF);
260
- }
261
-
262
216
// / This is the biggest offset to the stack pointer we can encode in aarch64
263
217
// / instructions (without using a separate calculation and a temp register).
264
218
// / Note that the exception here are vector stores/loads which cannot encode any
@@ -651,8 +605,6 @@ bool AArch64FrameLowering::shouldCombineCSRLocalStackBump(
651
605
const MachineFrameInfo &MFI = MF.getFrameInfo ();
652
606
const AArch64Subtarget &Subtarget = MF.getSubtarget <AArch64Subtarget>();
653
607
const AArch64RegisterInfo *RegInfo = Subtarget.getRegisterInfo ();
654
- if (homogeneousPrologEpilog (MF))
655
- return false ;
656
608
657
609
if (AFI->getLocalStackSize () == 0 )
658
610
return false ;
@@ -1196,16 +1148,12 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1196
1148
// All of the remaining stack allocations are for locals.
1197
1149
AFI->setLocalStackSize (NumBytes - PrologueSaveSize);
1198
1150
bool CombineSPBump = shouldCombineCSRLocalStackBump (MF, NumBytes);
1199
- bool HomPrologEpilog = homogeneousPrologEpilog (MF);
1200
1151
if (CombineSPBump) {
1201
1152
assert (!SVEStackSize && " Cannot combine SP bump with SVE" );
1202
1153
emitFrameOffset (MBB, MBBI, DL, AArch64::SP, AArch64::SP,
1203
1154
StackOffset::getFixed (-NumBytes), TII,
1204
1155
MachineInstr::FrameSetup, false , NeedsWinCFI, &HasWinCFI);
1205
1156
NumBytes = 0 ;
1206
- } else if (HomPrologEpilog) {
1207
- // Stack has been already adjusted.
1208
- NumBytes -= PrologueSaveSize;
1209
1157
} else if (PrologueSaveSize != 0 ) {
1210
1158
MBBI = convertCalleeSaveRestoreToSPPrePostIncDec (
1211
1159
MBB, MBBI, DL, TII, -PrologueSaveSize, NeedsWinCFI, &HasWinCFI);
@@ -1233,20 +1181,13 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1233
1181
if (CombineSPBump)
1234
1182
FPOffset += AFI->getLocalStackSize ();
1235
1183
1236
- if (HomPrologEpilog) {
1237
- auto Prolog = MBBI;
1238
- --Prolog;
1239
- assert (Prolog->getOpcode () == AArch64::HOM_Prolog);
1240
- Prolog->addOperand (MachineOperand::CreateImm (FPOffset));
1241
- } else {
1242
- // Issue sub fp, sp, FPOffset or
1243
- // mov fp,sp when FPOffset is zero.
1244
- // Note: All stores of callee-saved registers are marked as "FrameSetup".
1245
- // This code marks the instruction(s) that set the FP also.
1246
- emitFrameOffset (MBB, MBBI, DL, AArch64::FP, AArch64::SP,
1247
- StackOffset::getFixed (FPOffset), TII,
1248
- MachineInstr::FrameSetup, false , NeedsWinCFI, &HasWinCFI);
1249
- }
1184
+ // Issue sub fp, sp, FPOffset or
1185
+ // mov fp,sp when FPOffset is zero.
1186
+ // Note: All stores of callee-saved registers are marked as "FrameSetup".
1187
+ // This code marks the instruction(s) that set the FP also.
1188
+ emitFrameOffset (MBB, MBBI, DL, AArch64::FP, AArch64::SP,
1189
+ StackOffset::getFixed (FPOffset), TII,
1190
+ MachineInstr::FrameSetup, false , NeedsWinCFI, &HasWinCFI);
1250
1191
}
1251
1192
1252
1193
if (windowsRequiresStackProbe (MF, NumBytes)) {
@@ -1674,25 +1615,6 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
1674
1615
// function.
1675
1616
if (MF.hasEHFunclets ())
1676
1617
AFI->setLocalStackSize (NumBytes - PrologueSaveSize);
1677
- if (homogeneousPrologEpilog (MF, &MBB)) {
1678
- assert (!NeedsWinCFI);
1679
- auto LastPopI = MBB.getFirstTerminator ();
1680
- if (LastPopI != MBB.begin ()) {
1681
- auto HomogeneousEpilog = std::prev (LastPopI);
1682
- if (HomogeneousEpilog->getOpcode () == AArch64::HOM_Epilog)
1683
- LastPopI = HomogeneousEpilog;
1684
- }
1685
-
1686
- // Adjust local stack
1687
- emitFrameOffset (MBB, LastPopI, DL, AArch64::SP, AArch64::SP,
1688
- StackOffset::getFixed (-AFI->getLocalStackSize ()), TII,
1689
- MachineInstr::FrameDestroy, false , NeedsWinCFI);
1690
-
1691
- // SP has been already adjusted while restoring callee save regs.
1692
- // We've bailed-out the case with adjusting SP for arguments.
1693
- assert (AfterCSRPopSize == 0 );
1694
- return ;
1695
- }
1696
1618
bool CombineSPBump = shouldCombineCSRLocalStackBumpInEpilogue (MBB, NumBytes);
1697
1619
// Assume we can't combine the last pop with the sp restore.
1698
1620
@@ -2411,22 +2333,6 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
2411
2333
MBB.addLiveIn (AArch64::X18);
2412
2334
}
2413
2335
2414
- if (homogeneousPrologEpilog (MF)) {
2415
- auto MIB = BuildMI (MBB, MI, DL, TII.get (AArch64::HOM_Prolog))
2416
- .setMIFlag (MachineInstr::FrameSetup);
2417
-
2418
- for (auto &RPI : RegPairs) {
2419
- MIB.addReg (RPI.Reg1 );
2420
- MIB.addReg (RPI.Reg2 );
2421
-
2422
- // Update register live in.
2423
- if (!MRI.isReserved (RPI.Reg1 ))
2424
- MBB.addLiveIn (RPI.Reg1 );
2425
- if (!MRI.isReserved (RPI.Reg2 ))
2426
- MBB.addLiveIn (RPI.Reg2 );
2427
- }
2428
- return true ;
2429
- }
2430
2336
for (auto RPII = RegPairs.rbegin (), RPIE = RegPairs.rend (); RPII != RPIE;
2431
2337
++RPII) {
2432
2338
RegPairInfo RPI = *RPII;
@@ -2622,14 +2528,6 @@ bool AArch64FrameLowering::restoreCalleeSavedRegisters(
2622
2528
for (const RegPairInfo &RPI : reverse (RegPairs))
2623
2529
if (!RPI.isScalable ())
2624
2530
EmitMI (RPI);
2625
- } else if (homogeneousPrologEpilog (MF, &MBB)) {
2626
- auto MIB = BuildMI (MBB, MI, DL, TII.get (AArch64::HOM_Epilog))
2627
- .setMIFlag (MachineInstr::FrameDestroy);
2628
- for (auto &RPI : RegPairs) {
2629
- MIB.addReg (RPI.Reg1 , RegState::Define);
2630
- MIB.addReg (RPI.Reg2 , RegState::Define);
2631
- }
2632
- return true ;
2633
2531
} else
2634
2532
for (const RegPairInfo &RPI : RegPairs)
2635
2533
if (!RPI.isScalable ())
@@ -2699,7 +2597,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
2699
2597
// MachO's compact unwind format relies on all registers being stored in
2700
2598
// pairs.
2701
2599
// FIXME: the usual format is actually better if unwinding isn't needed.
2702
- if (producePairRegisters (MF) && PairedReg != AArch64::NoRegister &&
2600
+ if (produceCompactUnwindFrame (MF) && PairedReg != AArch64::NoRegister &&
2703
2601
!SavedRegs.test (PairedReg)) {
2704
2602
SavedRegs.set (PairedReg);
2705
2603
if (AArch64::GPR64RegClass.contains (PairedReg) &&
@@ -2778,7 +2676,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
2778
2676
// MachO's compact unwind format relies on all registers being stored in
2779
2677
// pairs, so if we need to spill one extra for BigStack, then we need to
2780
2678
// store the pair.
2781
- if (producePairRegisters (MF))
2679
+ if (produceCompactUnwindFrame (MF))
2782
2680
SavedRegs.set (UnspilledCSGPRPaired);
2783
2681
ExtraCSSpill = UnspilledCSGPR;
2784
2682
}
0 commit comments