diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineCopyPropagation.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 4d9d712..1105b8c 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -1018,18 +1018,30 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) { continue; } - LLVM_DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: "; - MaybeDead->dump()); - // Invalidate all entries in the copy map which are not preserved by // this register mask. - for (unsigned RegUnit : TRI->regunits(Reg)) + bool MIRefedinCopyInfo = false; + for (unsigned RegUnit : TRI->regunits(Reg)) { if (!PreservedRegUnits.test(RegUnit)) Tracker.clobberRegUnit(RegUnit, *TRI, *TII, UseCopyInstr); + else { + if (MaybeDead == Tracker.findCopyForUnit(RegUnit, *TRI)) { + MIRefedinCopyInfo = true; + } + } + } // erase() will return the next valid iterator pointing to the next // element after the erased one. DI = MaybeDeadCopies.erase(DI); + + // Preserved by RegMask, DO NOT remove copy + if (MIRefedinCopyInfo) + continue; + + LLVM_DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: " + << *MaybeDead); + MaybeDead->eraseFromParent(); Changed = true; ++NumDeletes; |