diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-02-09 00:19:08 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-02-09 00:19:08 +0000 |
commit | 938b4d26f132e601d86ca0466d217dafdcd7f0b3 (patch) | |
tree | 1177f95eedbf11be01d74ccb2c2975b5377ab391 /llvm/lib/CodeGen/MachineCopyPropagation.cpp | |
parent | 4519fd0b21b71af0cdec5c4c89ca8bf9a757930c (diff) | |
download | bcm5719-llvm-938b4d26f132e601d86ca0466d217dafdcd7f0b3.tar.gz bcm5719-llvm-938b4d26f132e601d86ca0466d217dafdcd7f0b3.zip |
Erase dead copies that are clobbered by a call.
This does make a difference, at least when using RABasic.
llvm-svn: 150118
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineCopyPropagation.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 56be93a95bc..0e9d3a4f8b1 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -191,11 +191,11 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { // Not a copy. SmallVector<unsigned, 2> Defs; - bool HasRegMask = false; + int RegMaskOpNum = -1; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); if (MO.isRegMask()) - HasRegMask = true; + RegMaskOpNum = i; if (!MO.isReg()) continue; unsigned Reg = MO.getReg(); @@ -227,9 +227,21 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { // a large set of registers. It is possible to use the register mask to // prune the available copies, but treat it like a basic block boundary for // now. - if (HasRegMask) { - // FIXME: We could possibly erase some MaybeDeadCopies if their registers - // are clobbered by the mask. + if (RegMaskOpNum >= 0) { + // Erase any MaybeDeadCopies whose destination register is clobbered. + const MachineOperand &MaskMO = MI->getOperand(RegMaskOpNum); + for (SmallSetVector<MachineInstr*, 8>::iterator + DI = MaybeDeadCopies.begin(), DE = MaybeDeadCopies.end(); + DI != DE; ++DI) { + unsigned Reg = (*DI)->getOperand(0).getReg(); + if (ReservedRegs.test(Reg) || !MaskMO.clobbersPhysReg(Reg)) + continue; + (*DI)->eraseFromParent(); + Changed = true; + ++NumDeletes; + } + + // Clear all data structures as if we were beginning a new basic block. MaybeDeadCopies.clear(); AvailCopyMap.clear(); CopyMap.clear(); |