summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineCopyPropagation.cpp
diff options
context:
space:
mode:
authorJun Bum Lim <junbuml@codeaurora.org>2016-03-25 21:15:35 +0000
committerJun Bum Lim <junbuml@codeaurora.org>2016-03-25 21:15:35 +0000
commit36c53fe147378109ddebed3d3f62fafcccca105a (patch)
treeee0471296dbccf4b5ca314cd061447127892baf0 /llvm/lib/CodeGen/MachineCopyPropagation.cpp
parentfa250cad3715a5df114cc5916e3b6f70560f9116 (diff)
downloadbcm5719-llvm-36c53fe147378109ddebed3d3f62fafcccca105a.tar.gz
bcm5719-llvm-36c53fe147378109ddebed3d3f62fafcccca105a.zip
[MachineCopyPropagation] Expose more dead copies across instructions with regmasks
When encountering instructions with regmasks, instead of cleaning up all the elements in MaybeDeadCopies map, remove only the instructions erased. By keeping more instruction in MaybeDeadCopies, this change will expose more dead copies across instructions with regmasks. llvm-svn: 264462
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCopyPropagation.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 2bfd65019fc..3a6f2b5330e 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -285,18 +285,28 @@ void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
// defined registers.
if (RegMask) {
// Erase any MaybeDeadCopies whose destination register is clobbered.
- for (MachineInstr *MaybeDead : MaybeDeadCopies) {
+ for (SmallSetVector<MachineInstr *, 8>::iterator DI =
+ MaybeDeadCopies.begin();
+ DI != MaybeDeadCopies.end();) {
+ MachineInstr *MaybeDead = *DI;
unsigned Reg = MaybeDead->getOperand(0).getReg();
assert(!MRI->isReserved(Reg));
- if (!RegMask->clobbersPhysReg(Reg))
+
+ if (!RegMask->clobbersPhysReg(Reg)) {
+ ++DI;
continue;
+ }
+
DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: ";
MaybeDead->dump());
+
+ // erase() will return the next valid iterator pointing to the next
+ // element after the erased one.
+ DI = MaybeDeadCopies.erase(DI);
MaybeDead->eraseFromParent();
Changed = true;
++NumDeletes;
}
- MaybeDeadCopies.clear();
removeClobberedRegsFromMap(AvailCopyMap, *RegMask);
removeClobberedRegsFromMap(CopyMap, *RegMask);
@@ -348,3 +358,4 @@ bool MachineCopyPropagation::runOnMachineFunction(MachineFunction &MF) {
return Changed;
}
+
OpenPOWER on IntegriCloud