From: Jakob Stoklund Olesen Date: Thu, 9 Feb 2012 00:19:08 +0000 (+0000) Subject: Erase dead copies that are clobbered by a call. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f56ce5312448e5876ee1822facab48385ea5c0c0;p=oota-llvm.git Erase dead copies that are clobbered by a call. This does make a difference, at least when using RABasic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150118 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineCopyPropagation.cpp b/lib/CodeGen/MachineCopyPropagation.cpp index 56be93a95bc..0e9d3a4f8b1 100644 --- a/lib/CodeGen/MachineCopyPropagation.cpp +++ b/lib/CodeGen/MachineCopyPropagation.cpp @@ -191,11 +191,11 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { // Not a copy. SmallVector 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::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();