Skip to content

Commit

Permalink
[InitUndef] Only compute DeadLaneDetector if subreg liveness enabled …
Browse files Browse the repository at this point in the history
…(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.
  • Loading branch information
nikic authored Sep 12, 2024
1 parent 447b32f commit e2723c2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions llvm/lib/CodeGen/InitUndef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class InitUndef : public MachineFunctionPass {

private:
bool processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
const DeadLaneDetector &DLD);
const DeadLaneDetector *DLD);
bool handleSubReg(MachineFunction &MF, MachineInstr &MI,
const DeadLaneDetector &DLD);
bool fixupIllOperand(MachineInstr *MI, MachineOperand &MO);
Expand Down Expand Up @@ -210,7 +210,7 @@ bool InitUndef::fixupIllOperand(MachineInstr *MI, MachineOperand &MO) {
}

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

if (isEarlyClobberMI(MI)) {
if (MRI->subRegLivenessEnabled())
Changed |= handleSubReg(MF, MI, DLD);
Changed |= handleSubReg(MF, MI, *DLD);
Changed |= handleReg(&MI);
}
}
Expand All @@ -260,11 +260,14 @@ bool InitUndef::runOnMachineFunction(MachineFunction &MF) {
TRI = MRI->getTargetRegisterInfo();

bool Changed = false;
DeadLaneDetector DLD(MRI, TRI);
DLD.computeSubRegisterLaneBitInfo();
std::unique_ptr<DeadLaneDetector> DLD;
if (MRI->subRegLivenessEnabled()) {
DLD = std::make_unique<DeadLaneDetector>(MRI, TRI);
DLD->computeSubRegisterLaneBitInfo();
}

for (MachineBasicBlock &BB : MF)
Changed |= processBasicBlock(MF, BB, DLD);
Changed |= processBasicBlock(MF, BB, DLD.get());

for (auto *DeadMI : DeadInsts)
DeadMI->eraseFromParent();
Expand Down

0 comments on commit e2723c2

Please sign in to comment.