Skip to content

Commit e2723c2

Browse files
authored
[InitUndef] Only compute DeadLaneDetector if subreg liveness enabled (NFC) (#108279)
InitUndef currently always computes DeadLaneDetector, but only actually uses it if subreg liveness is enabled for the target. Make the calculation optional to avoid an unnecessary compile-time impact for targets that don't enable subreg liveness.
1 parent 447b32f commit e2723c2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

llvm/lib/CodeGen/InitUndef.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class InitUndef : public MachineFunctionPass {
8484

8585
private:
8686
bool processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
87-
const DeadLaneDetector &DLD);
87+
const DeadLaneDetector *DLD);
8888
bool handleSubReg(MachineFunction &MF, MachineInstr &MI,
8989
const DeadLaneDetector &DLD);
9090
bool fixupIllOperand(MachineInstr *MI, MachineOperand &MO);
@@ -210,7 +210,7 @@ bool InitUndef::fixupIllOperand(MachineInstr *MI, MachineOperand &MO) {
210210
}
211211

212212
bool InitUndef::processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
213-
const DeadLaneDetector &DLD) {
213+
const DeadLaneDetector *DLD) {
214214
bool Changed = false;
215215
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) {
216216
MachineInstr &MI = *I;
@@ -236,7 +236,7 @@ bool InitUndef::processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
236236

237237
if (isEarlyClobberMI(MI)) {
238238
if (MRI->subRegLivenessEnabled())
239-
Changed |= handleSubReg(MF, MI, DLD);
239+
Changed |= handleSubReg(MF, MI, *DLD);
240240
Changed |= handleReg(&MI);
241241
}
242242
}
@@ -260,11 +260,14 @@ bool InitUndef::runOnMachineFunction(MachineFunction &MF) {
260260
TRI = MRI->getTargetRegisterInfo();
261261

262262
bool Changed = false;
263-
DeadLaneDetector DLD(MRI, TRI);
264-
DLD.computeSubRegisterLaneBitInfo();
263+
std::unique_ptr<DeadLaneDetector> DLD;
264+
if (MRI->subRegLivenessEnabled()) {
265+
DLD = std::make_unique<DeadLaneDetector>(MRI, TRI);
266+
DLD->computeSubRegisterLaneBitInfo();
267+
}
265268

266269
for (MachineBasicBlock &BB : MF)
267-
Changed |= processBasicBlock(MF, BB, DLD);
270+
Changed |= processBasicBlock(MF, BB, DLD.get());
268271

269272
for (auto *DeadMI : DeadInsts)
270273
DeadMI->eraseFromParent();

0 commit comments

Comments
 (0)