[llvm] e2723c2 - [InitUndef] Only compute DeadLaneDetector if subreg liveness enabled (NFC) (#108279)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 00:00:51 PDT 2024
Author: Nikita Popov
Date: 2024-09-12T09:00:47+02:00
New Revision: e2723c2a8af69677d68e9c11a394f08e6c205153
URL: https://github.com/llvm/llvm-project/commit/e2723c2a8af69677d68e9c11a394f08e6c205153
DIFF: https://github.com/llvm/llvm-project/commit/e2723c2a8af69677d68e9c11a394f08e6c205153.diff
LOG: [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.
Added:
Modified:
llvm/lib/CodeGen/InitUndef.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/InitUndef.cpp b/llvm/lib/CodeGen/InitUndef.cpp
index 1613e413712d26..d6f7c0d7cf0f5f 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<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();
More information about the llvm-commits
mailing list