Skip to content

Commit 976aac2

Browse files
committed
[LiveDebugValues] Use getNumSupportedRegs to reduce compile time, NFCI
3rd try to fix compile regression by #113532
1 parent c72a751 commit 976aac2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ MLocTracker::MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
10221022
const TargetLowering &TLI)
10231023
: MF(MF), TII(TII), TRI(TRI), TLI(TLI),
10241024
LocIdxToIDNum(ValueIDNum::EmptyValue), LocIdxToLocID(0) {
1025-
NumRegs = TRI.getNumRegs();
1025+
NumRegs = TRI.getNumSupportedRegs(MF);
10261026
reset();
10271027
LocIDToLocIdx.resize(NumRegs, LocIdx::MakeIllegalLoc());
10281028
assert(NumRegs < (1u << NUM_LOC_BITS)); // Detect bit packing failure
@@ -1878,7 +1878,8 @@ void InstrRefBasedLDV::transferRegisterDef(MachineInstr &MI) {
18781878
if (MO.isReg() && MO.isDef() && MO.getReg() && MO.getReg().isPhysical() &&
18791879
!IgnoreSPAlias(MO.getReg())) {
18801880
// Remove ranges of all aliased registers.
1881-
for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI)
1881+
for (MCRegAliasIterator RAI(MO.getReg(), TRI, true);
1882+
RAI.isValid() && *RAI < NumRegs; ++RAI)
18821883
// FIXME: Can we break out of this loop early if no insertion occurs?
18831884
DeadRegs.insert(*RAI);
18841885
} else if (MO.isRegMask()) {
@@ -1952,7 +1953,8 @@ void InstrRefBasedLDV::transferRegisterDef(MachineInstr &MI) {
19521953

19531954
void InstrRefBasedLDV::performCopy(Register SrcRegNum, Register DstRegNum) {
19541955
// In all circumstances, re-def all aliases. It's definitely a new value now.
1955-
for (MCRegAliasIterator RAI(DstRegNum, TRI, true); RAI.isValid(); ++RAI)
1956+
for (MCRegAliasIterator RAI(DstRegNum, TRI, true);
1957+
RAI.isValid() && *RAI < NumRegs; ++RAI)
19561958
MTracker->defReg(*RAI, CurBB, CurInst);
19571959

19581960
ValueIDNum SrcValue = MTracker->readReg(SrcRegNum);
@@ -2117,7 +2119,8 @@ bool InstrRefBasedLDV::transferSpillOrRestoreInst(MachineInstr &MI) {
21172119
// stack slot.
21182120

21192121
// Def all registers that alias the destination.
2120-
for (MCRegAliasIterator RAI(Reg, TRI, true); RAI.isValid(); ++RAI)
2122+
for (MCRegAliasIterator RAI(Reg, TRI, true);
2123+
RAI.isValid() && *RAI < NumRegs; ++RAI)
21212124
MTracker->defReg(*RAI, CurBB, CurInst);
21222125

21232126
// Now find subregisters within the destination register, and load values
@@ -2302,11 +2305,12 @@ void InstrRefBasedLDV::produceMLocTransferFunction(
23022305
// appropriate clobbers.
23032306
SmallVector<BitVector, 32> BlockMasks;
23042307
BlockMasks.resize(MaxNumBlocks);
2308+
NumRegs = TRI->getNumSupportedRegs(MF);
23052309

23062310
// Reserve one bit per register for the masks described above.
2307-
unsigned BVWords = MachineOperand::getRegMaskSize(TRI->getNumRegs());
2311+
unsigned BVWords = MachineOperand::getRegMaskSize(NumRegs);
23082312
for (auto &BV : BlockMasks)
2309-
BV.resize(TRI->getNumRegs(), true);
2313+
BV.resize(NumRegs, true);
23102314

23112315
// Step through all instructions and inhale the transfer function.
23122316
for (auto &MBB : MF) {
@@ -2370,11 +2374,11 @@ void InstrRefBasedLDV::produceMLocTransferFunction(
23702374
}
23712375

23722376
// Compute a bitvector of all the registers that are tracked in this block.
2373-
BitVector UsedRegs(TRI->getNumRegs());
2377+
BitVector UsedRegs(NumRegs);
23742378
for (auto Location : MTracker->locations()) {
23752379
unsigned ID = MTracker->LocIdxToLocID[Location.Idx];
23762380
// Ignore stack slots, and aliases of the stack pointer.
2377-
if (ID >= TRI->getNumRegs() || MTracker->SPAliases.count(ID))
2381+
if (ID >= NumRegs || MTracker->SPAliases.count(ID))
23782382
continue;
23792383
UsedRegs.set(ID);
23802384
}

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,8 @@ class InstrRefBasedLDV : public LDVImpl {
12531253
/// pointer.
12541254
StringRef StackProbeSymbolName;
12551255

1256+
unsigned NumRegs = 0;
1257+
12561258
/// Tests whether this instruction is a spill to a stack slot.
12571259
std::optional<SpillLocationNo> isSpillInstruction(const MachineInstr &MI,
12581260
MachineFunction *MF);

0 commit comments

Comments
 (0)