Skip to content

Commit 5921b59

Browse files
committed
Reapply "[AArch64][NFC] Switch to LiveRegUnits (#87313)"
This reverts commit 84314d0.
1 parent 7775be4 commit 5921b59

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
#include "llvm/ADT/SmallVector.h"
198198
#include "llvm/ADT/Statistic.h"
199199
#include "llvm/CodeGen/LivePhysRegs.h"
200+
#include "llvm/CodeGen/LiveRegUnits.h"
200201
#include "llvm/CodeGen/MachineBasicBlock.h"
201202
#include "llvm/CodeGen/MachineFrameInfo.h"
202203
#include "llvm/CodeGen/MachineFunction.h"
@@ -1007,7 +1008,7 @@ void AArch64FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
10071008
}
10081009
}
10091010

1010-
static void getLiveRegsForEntryMBB(LivePhysRegs &LiveRegs,
1011+
static void getLiveRegsForEntryMBB(LiveRegUnits &LiveRegs,
10111012
const MachineBasicBlock &MBB) {
10121013
const MachineFunction *MF = MBB.getParent();
10131014
LiveRegs.addLiveIns(MBB);
@@ -1040,16 +1041,18 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB) {
10401041

10411042
const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>();
10421043
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1043-
LivePhysRegs LiveRegs(TRI);
1044+
LiveRegUnits LiveRegs(TRI);
10441045
getLiveRegsForEntryMBB(LiveRegs, *MBB);
10451046

10461047
// Prefer X9 since it was historically used for the prologue scratch reg.
1047-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1048-
if (LiveRegs.available(MRI, AArch64::X9))
1048+
if (LiveRegs.available(AArch64::X9))
10491049
return AArch64::X9;
10501050

1051-
for (unsigned Reg : AArch64::GPR64RegClass) {
1052-
if (LiveRegs.available(MRI, Reg))
1051+
BitVector Allocatable =
1052+
TRI.getAllocatableSet(*MF, TRI.getRegClass(AArch64::GPR64RegClassID));
1053+
1054+
for (unsigned Reg : Allocatable.set_bits()) {
1055+
if (LiveRegs.available(Reg))
10531056
return Reg;
10541057
}
10551058
return AArch64::NoRegister;
@@ -1065,14 +1068,11 @@ bool AArch64FrameLowering::canUseAsPrologue(
10651068
const AArch64FunctionInfo *AFI = MF->getInfo<AArch64FunctionInfo>();
10661069

10671070
if (AFI->hasSwiftAsyncContext()) {
1068-
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1069-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1070-
LivePhysRegs LiveRegs(TRI);
1071+
LiveRegUnits LiveRegs(*RegInfo);
10711072
getLiveRegsForEntryMBB(LiveRegs, MBB);
10721073
// The StoreSwiftAsyncContext clobbers X16 and X17. Make sure they are
10731074
// available.
1074-
if (!LiveRegs.available(MRI, AArch64::X16) ||
1075-
!LiveRegs.available(MRI, AArch64::X17))
1075+
if (!LiveRegs.available(AArch64::X16) || !LiveRegs.available(AArch64::X17))
10761076
return false;
10771077
}
10781078

@@ -1664,7 +1664,7 @@ static void emitDefineCFAWithFP(MachineFunction &MF, MachineBasicBlock &MBB,
16641664
/// Collect live registers from the end of \p MI's parent up to (including) \p
16651665
/// MI in \p LiveRegs.
16661666
static void getLivePhysRegsUpTo(MachineInstr &MI, const TargetRegisterInfo &TRI,
1667-
LivePhysRegs &LiveRegs) {
1667+
LiveRegUnits &LiveRegs) {
16681668

16691669
MachineBasicBlock &MBB = *MI.getParent();
16701670
LiveRegs.addLiveOuts(MBB);
@@ -1702,7 +1702,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
17021702
NonFrameStart->getFlag(MachineInstr::FrameSetup))
17031703
++NonFrameStart;
17041704

1705-
LivePhysRegs LiveRegs(*TRI);
1705+
LiveRegUnits LiveRegs(*TRI);
17061706
if (NonFrameStart != MBB.end()) {
17071707
getLivePhysRegsUpTo(*NonFrameStart, *TRI, LiveRegs);
17081708
// Ignore registers used for stack management for now.
@@ -1726,7 +1726,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
17261726
make_range(MBB.instr_begin(), NonFrameStart->getIterator())) {
17271727
for (auto &Op : MI.operands())
17281728
if (Op.isReg() && Op.isDef())
1729-
assert(!LiveRegs.contains(Op.getReg()) &&
1729+
assert(LiveRegs.available(Op.getReg()) &&
17301730
"live register clobbered by inserted prologue instructions");
17311731
}
17321732
});
@@ -4333,7 +4333,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
43334333
// FIXME : This approach of bailing out from merge is conservative in
43344334
// some ways like even if stg loops are not present after merge the
43354335
// insert list, this liveness check is done (which is not needed).
4336-
LivePhysRegs LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
4336+
LiveRegUnits LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
43374337
LiveRegs.addLiveOuts(*MBB);
43384338
for (auto I = MBB->rbegin();; ++I) {
43394339
MachineInstr &MI = *I;
@@ -4342,7 +4342,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
43424342
LiveRegs.stepBackward(*I);
43434343
}
43444344
InsertI++;
4345-
if (LiveRegs.contains(AArch64::NZCV))
4345+
if (!LiveRegs.available(AArch64::NZCV))
43464346
return InsertI;
43474347

43484348
llvm::stable_sort(Instrs,

0 commit comments

Comments
 (0)