Skip to content

Commit 175e0dd

Browse files
authored
[MachineLateInstrsCleanup] Minor fixing (NFC). (#117816)
With cb57b7a, 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.
1 parent c8ee1ee commit 175e0dd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class MachineLateInstrsCleanup : public MachineFunctionPass {
5757

5858
void removeRedundantDef(MachineInstr *MI);
5959
void clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
60-
MachineBasicBlock::iterator I,
6160
BitVector &VisitedPreds);
6261

6362
public:
@@ -110,14 +109,11 @@ bool MachineLateInstrsCleanup::runOnMachineFunction(MachineFunction &MF) {
110109
return Changed;
111110
}
112111

113-
// Clear any previous kill flag on Reg found before I in MBB. Walk backwards
114-
// in MBB and if needed continue in predecessors until a use/def of Reg is
115-
// encountered. This seems to be faster in practice than tracking kill flags
116-
// in a map.
117-
void MachineLateInstrsCleanup::
118-
clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
119-
MachineBasicBlock::iterator I,
120-
BitVector &VisitedPreds) {
112+
// Clear any preceding kill flag on Reg after removing a redundant
113+
// definition.
114+
void MachineLateInstrsCleanup::clearKillsForDef(Register Reg,
115+
MachineBasicBlock *MBB,
116+
BitVector &VisitedPreds) {
121117
VisitedPreds.set(MBB->getNumber());
122118

123119
// Kill flag in MBB
@@ -137,13 +133,13 @@ clearKillsForDef(Register Reg, MachineBasicBlock *MBB,
137133
assert(!MBB->pred_empty() && "Predecessor def not found!");
138134
for (MachineBasicBlock *Pred : MBB->predecessors())
139135
if (!VisitedPreds.test(Pred->getNumber()))
140-
clearKillsForDef(Reg, Pred, Pred->end(), VisitedPreds);
136+
clearKillsForDef(Reg, Pred, VisitedPreds);
141137
}
142138

143139
void MachineLateInstrsCleanup::removeRedundantDef(MachineInstr *MI) {
144140
Register Reg = MI->getOperand(0).getReg();
145141
BitVector VisitedPreds(MI->getMF()->getNumBlockIDs());
146-
clearKillsForDef(Reg, MI->getParent(), MI->getIterator(), VisitedPreds);
142+
clearKillsForDef(Reg, MI->getParent(), VisitedPreds);
147143
MI->eraseFromParent();
148144
++NumRemoved;
149145
}

0 commit comments

Comments
 (0)