Skip to content

Commit 8316bf3

Browse files
committed
Revert "[RegisterCoalescer] Clear instructions not recorded in ErasedInstrs but erased (#79820)"
This reverts commit 95b14da.
1 parent 0079136 commit 8316bf3

File tree

3 files changed

+5
-338
lines changed

3 files changed

+5
-338
lines changed

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ namespace {
236236
/// was successfully coalesced away. If it is not currently possible to
237237
/// coalesce this interval, but it may be possible if other things get
238238
/// coalesced, then it returns true by reference in 'Again'.
239-
bool joinCopy(MachineInstr *CopyMI, bool &Again,
240-
SmallPtrSetImpl<MachineInstr *> &CurrentErasedInstrs);
239+
bool joinCopy(MachineInstr *CopyMI, bool &Again);
241240

242241
/// Attempt to join these two intervals. On failure, this
243242
/// returns false. The output "SrcInt" will not have been modified, so we
@@ -1965,9 +1964,7 @@ void RegisterCoalescer::setUndefOnPrunedSubRegUses(LiveInterval &LI,
19651964
LIS->shrinkToUses(&LI);
19661965
}
19671966

1968-
bool RegisterCoalescer::joinCopy(
1969-
MachineInstr *CopyMI, bool &Again,
1970-
SmallPtrSetImpl<MachineInstr *> &CurrentErasedInstrs) {
1967+
bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
19711968
Again = false;
19721969
LLVM_DEBUG(dbgs() << LIS->getInstructionIndex(*CopyMI) << '\t' << *CopyMI);
19731970

@@ -2159,9 +2156,7 @@ bool RegisterCoalescer::joinCopy(
21592156
// CopyMI has been erased by joinIntervals at this point. Remove it from
21602157
// ErasedInstrs since copyCoalesceWorkList() won't add a successful join back
21612158
// to the work list. This keeps ErasedInstrs from growing needlessly.
2162-
if (ErasedInstrs.erase(CopyMI))
2163-
// But we may encounter the instruction again in this iteration.
2164-
CurrentErasedInstrs.insert(CopyMI);
2159+
ErasedInstrs.erase(CopyMI);
21652160

21662161
// Rewrite all SrcReg operands to DstReg.
21672162
// Also update DstReg operands to include DstIdx if it is set.
@@ -3987,33 +3982,21 @@ void RegisterCoalescer::lateLiveIntervalUpdate() {
39873982
bool RegisterCoalescer::
39883983
copyCoalesceWorkList(MutableArrayRef<MachineInstr*> CurrList) {
39893984
bool Progress = false;
3990-
SmallPtrSet<MachineInstr *, 4> CurrentErasedInstrs;
39913985
for (MachineInstr *&MI : CurrList) {
39923986
if (!MI)
39933987
continue;
39943988
// Skip instruction pointers that have already been erased, for example by
39953989
// dead code elimination.
3996-
if (ErasedInstrs.count(MI) || CurrentErasedInstrs.count(MI)) {
3990+
if (ErasedInstrs.count(MI)) {
39973991
MI = nullptr;
39983992
continue;
39993993
}
40003994
bool Again = false;
4001-
bool Success = joinCopy(MI, Again, CurrentErasedInstrs);
3995+
bool Success = joinCopy(MI, Again);
40023996
Progress |= Success;
40033997
if (Success || !Again)
40043998
MI = nullptr;
40053999
}
4006-
// Clear instructions not recorded in `ErasedInstrs` but erased.
4007-
if (!CurrentErasedInstrs.empty()) {
4008-
for (MachineInstr *&MI : CurrList) {
4009-
if (MI && CurrentErasedInstrs.count(MI))
4010-
MI = nullptr;
4011-
}
4012-
for (MachineInstr *&MI : WorkList) {
4013-
if (MI && CurrentErasedInstrs.count(MI))
4014-
MI = nullptr;
4015-
}
4016-
}
40174000
return Progress;
40184001
}
40194002

llvm/test/CodeGen/LoongArch/register-coalescer-crash-pr79718.mir

Lines changed: 0 additions & 213 deletions
This file was deleted.

llvm/test/CodeGen/X86/PR71178-register-coalescer-crash.ll

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)