From 19f5f71bba08e690611fa213647ac6bae814756b Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 21 May 2010 17:36:32 +0000 Subject: Revert "Use MachineInstr::readsWritesVirtualRegister to determine if a register is read." This reverts r104322. I think it was causing miscompilations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104323 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineInstr.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'lib/CodeGen/MachineInstr.cpp') diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 319059b4bb..595fddda6f 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -782,31 +782,27 @@ int MachineInstr::findRegisterUseOperandIdx(unsigned Reg, bool isKill, return -1; } -/// readsWritesVirtualRegister - Return a pair of bools (reads, writes) -/// indicating if this instruction reads or writes Reg. This also considers -/// partial defines. -std::pair -MachineInstr::readsWritesVirtualRegister(unsigned Reg, - SmallVectorImpl *Ops) const { - bool PartDef = false; // Partial redefine. - bool FullDef = false; // Full define. - bool Use = false; +/// readsVirtualRegister - Return true if the MachineInstr reads the specified +/// virtual register. Take into account that a partial define is a +/// read-modify-write operation. +bool MachineInstr::readsVirtualRegister(unsigned Reg) const { + bool PartDef = false; // Partial redefine + bool FullDef = false; // Full define for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { const MachineOperand &MO = getOperand(i); if (!MO.isReg() || MO.getReg() != Reg) continue; - if (Ops) - Ops->push_back(i); if (MO.isUse()) - Use |= !MO.isUndef(); - else if (MO.getSubReg()) + return true; + if (MO.getSubReg()) PartDef = true; else FullDef = true; } - // A partial redefine uses Reg unless there is also a full define. - return std::make_pair(Use || (PartDef && !FullDef), PartDef || FullDef); + // A partial register definition causes a read unless the full register is + // also defined. + return PartDef && !FullDef; } /// findRegisterDefOperandIdx() - Returns the operand index that is a def of -- cgit v1.2.3-70-g09d2