[llvm] [MachineLateInstrsCleanup] Minor fixing (NFC). (PR #117816)
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 16:31:34 PST 2024
https://github.com/JonPsson1 created https://github.com/llvm/llvm-project/pull/117816
With cb57b7a7, MachineLateInstrsCleanup switched to using a map to keep track of kill flags to remedy compile time regressions seen with huge functions.
It seems that the comment above clearKillsForDef() became stale with that commit, and also that one of the arguments to it became unused, both of which this patch fixes.
>From 14eb0e0819916a914913aa8621c24d1ce9e4c340 Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulson1 at linux.ibm.com>
Date: Tue, 26 Nov 2024 14:43:22 -0600
Subject: [PATCH] Update comment and remove unused parameter.
---
llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp b/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
index 14a49853f68b8e..fe91bd7c6a91cb 100644
--- a/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
+++ b/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
@@ -57,7 +57,6 @@ class MachineLateInstrsCleanup : public MachineFunctionPass {
void removeRedundantDef(MachineInstr *MI);
void clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
- MachineBasicBlock::iterator I,
BitVector &VisitedPreds);
public:
@@ -110,13 +109,10 @@ bool MachineLateInstrsCleanup::runOnMachineFunction(MachineFunction &MF) {
return Changed;
}
-// Clear any previous kill flag on Reg found before I in MBB. Walk backwards
-// in MBB and if needed continue in predecessors until a use/def of Reg is
-// encountered. This seems to be faster in practice than tracking kill flags
-// in a map.
+// Clear any preceding kill flag on Reg after removing a redundant
+// definition.
void MachineLateInstrsCleanup::
clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
- MachineBasicBlock::iterator I,
BitVector &VisitedPreds) {
VisitedPreds.set(MBB->getNumber());
@@ -137,13 +133,13 @@ clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
assert(!MBB->pred_empty() && "Predecessor def not found!");
for (MachineBasicBlock *Pred : MBB->predecessors())
if (!VisitedPreds.test(Pred->getNumber()))
- clearKillsForDef(Reg, Pred, Pred->end(), VisitedPreds);
+ clearKillsForDef(Reg, Pred, VisitedPreds);
}
void MachineLateInstrsCleanup::removeRedundantDef(MachineInstr *MI) {
Register Reg = MI->getOperand(0).getReg();
BitVector VisitedPreds(MI->getMF()->getNumBlockIDs());
- clearKillsForDef(Reg, MI->getParent(), MI->getIterator(), VisitedPreds);
+ clearKillsForDef(Reg, MI->getParent(), VisitedPreds);
MI->eraseFromParent();
++NumRemoved;
}
More information about the llvm-commits
mailing list