mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 17:32:49 +00:00
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
This commit is contained in:
parent
450b3850ce
commit
f56ce53124
@ -191,11 +191,11 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
|
|||||||
|
|
||||||
// Not a copy.
|
// Not a copy.
|
||||||
SmallVector<unsigned, 2> Defs;
|
SmallVector<unsigned, 2> Defs;
|
||||||
bool HasRegMask = false;
|
int RegMaskOpNum = -1;
|
||||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MI->getOperand(i);
|
MachineOperand &MO = MI->getOperand(i);
|
||||||
if (MO.isRegMask())
|
if (MO.isRegMask())
|
||||||
HasRegMask = true;
|
RegMaskOpNum = i;
|
||||||
if (!MO.isReg())
|
if (!MO.isReg())
|
||||||
continue;
|
continue;
|
||||||
unsigned Reg = MO.getReg();
|
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
|
// 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
|
// prune the available copies, but treat it like a basic block boundary for
|
||||||
// now.
|
// now.
|
||||||
if (HasRegMask) {
|
if (RegMaskOpNum >= 0) {
|
||||||
// FIXME: We could possibly erase some MaybeDeadCopies if their registers
|
// Erase any MaybeDeadCopies whose destination register is clobbered.
|
||||||
// are clobbered by the mask.
|
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();
|
MaybeDeadCopies.clear();
|
||||||
AvailCopyMap.clear();
|
AvailCopyMap.clear();
|
||||||
CopyMap.clear();
|
CopyMap.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user