Skip to content

Commit 101e8ff

Browse files
committed
Reapply "[AArch64][NFC] Switch to LiveRegUnits (#87313)"
This reverts commit 84314d0.
1 parent c63eadd commit 101e8ff

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"
@@ -1011,7 +1012,7 @@ void AArch64FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
10111012
}
10121013
}
10131014

1014-
static void getLiveRegsForEntryMBB(LivePhysRegs &LiveRegs,
1015+
static void getLiveRegsForEntryMBB(LiveRegUnits &LiveRegs,
10151016
const MachineBasicBlock &MBB) {
10161017
const MachineFunction *MF = MBB.getParent();
10171018
LiveRegs.addLiveIns(MBB);
@@ -1044,16 +1045,18 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB) {
10441045

10451046
const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>();
10461047
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1047-
LivePhysRegs LiveRegs(TRI);
1048+
LiveRegUnits LiveRegs(TRI);
10481049
getLiveRegsForEntryMBB(LiveRegs, *MBB);
10491050

10501051
// Prefer X9 since it was historically used for the prologue scratch reg.
1051-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1052-
if (LiveRegs.available(MRI, AArch64::X9))
1052+
if (LiveRegs.available(AArch64::X9))
10531053
return AArch64::X9;
10541054

1055-
for (unsigned Reg : AArch64::GPR64RegClass) {
1056-
if (LiveRegs.available(MRI, Reg))
1055+
BitVector Allocatable =
1056+
TRI.getAllocatableSet(*MF, TRI.getRegClass(AArch64::GPR64RegClassID));
1057+
1058+
for (unsigned Reg : Allocatable.set_bits()) {
1059+
if (LiveRegs.available(Reg))
10571060
return Reg;
10581061
}
10591062
return AArch64::NoRegister;
@@ -1069,14 +1072,11 @@ bool AArch64FrameLowering::canUseAsPrologue(
10691072
const AArch64FunctionInfo *AFI = MF->getInfo<AArch64FunctionInfo>();
10701073

10711074
if (AFI->hasSwiftAsyncContext()) {
1072-
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1073-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1074-
LivePhysRegs LiveRegs(TRI);
1075+
LiveRegUnits LiveRegs(*RegInfo);
10751076
getLiveRegsForEntryMBB(LiveRegs, MBB);
10761077
// The StoreSwiftAsyncContext clobbers X16 and X17. Make sure they are
10771078
// available.
1078-
if (!LiveRegs.available(MRI, AArch64::X16) ||
1079-
!LiveRegs.available(MRI, AArch64::X17))
1079+
if (!LiveRegs.available(AArch64::X16) || !LiveRegs.available(AArch64::X17))
10801080
return false;
10811081
}
10821082

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

16731673
MachineBasicBlock &MBB = *MI.getParent();
16741674
LiveRegs.addLiveOuts(MBB);
@@ -1706,7 +1706,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
17061706
NonFrameStart->getFlag(MachineInstr::FrameSetup))
17071707
++NonFrameStart;
17081708

1709-
LivePhysRegs LiveRegs(*TRI);
1709+
LiveRegUnits LiveRegs(*TRI);
17101710
if (NonFrameStart != MBB.end()) {
17111711
getLivePhysRegsUpTo(*NonFrameStart, *TRI, LiveRegs);
17121712
// Ignore registers used for stack management for now.
@@ -1730,7 +1730,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
17301730
make_range(MBB.instr_begin(), NonFrameStart->getIterator())) {
17311731
for (auto &Op : MI.operands())
17321732
if (Op.isReg() && Op.isDef())
1733-
assert(!LiveRegs.contains(Op.getReg()) &&
1733+
assert(LiveRegs.available(Op.getReg()) &&
17341734
"live register clobbered by inserted prologue instructions");
17351735
}
17361736
});
@@ -4324,7 +4324,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
43244324
// FIXME : This approach of bailing out from merge is conservative in
43254325
// some ways like even if stg loops are not present after merge the
43264326
// insert list, this liveness check is done (which is not needed).
4327-
LivePhysRegs LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
4327+
LiveRegUnits LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
43284328
LiveRegs.addLiveOuts(*MBB);
43294329
for (auto I = MBB->rbegin();; ++I) {
43304330
MachineInstr &MI = *I;
@@ -4333,7 +4333,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
43334333
LiveRegs.stepBackward(*I);
43344334
}
43354335
InsertI++;
4336-
if (LiveRegs.contains(AArch64::NZCV))
4336+
if (!LiveRegs.available(AArch64::NZCV))
43374337
return InsertI;
43384338

43394339
llvm::stable_sort(Instrs,

0 commit comments

Comments
 (0)