From e2723c2a8af69677d68e9c11a394f08e6c205153 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 12 Sep 2024 09:00:47 +0200 Subject: [PATCH] [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. --- llvm/lib/CodeGen/InitUndef.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/llvm/lib/CodeGen/InitUndef.cpp b/llvm/lib/CodeGen/InitUndef.cpp index 1613e413712d..d6f7c0d7cf0f 100644 --- a/llvm/lib/CodeGen/InitUndef.cpp +++ b/llvm/lib/CodeGen/InitUndef.cpp @@ -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); @@ -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; @@ -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); } } @@ -260,11 +260,14 @@ bool InitUndef::runOnMachineFunction(MachineFunction &MF) { TRI = MRI->getTargetRegisterInfo(); bool Changed = false; - DeadLaneDetector DLD(MRI, TRI); - DLD.computeSubRegisterLaneBitInfo(); + std::unique_ptr DLD; + if (MRI->subRegLivenessEnabled()) { + DLD = std::make_unique(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();