From: Chen Zheng Date: Wed, 20 Feb 2019 07:01:04 +0000 (+0000) Subject: [NFC] add/modify wrapper function for findRegisterDefOperand(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c67948988f4cf1d96071ab2acfa7f124a0eac124;p=llvm [NFC] add/modify wrapper function for findRegisterDefOperand(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354438 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 4cb39c5f0a6..0a1b927d2e9 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -1199,12 +1199,22 @@ public: /// Wrapper for findRegisterDefOperandIdx, it returns /// a pointer to the MachineOperand rather than an index. - MachineOperand *findRegisterDefOperand(unsigned Reg, bool isDead = false, - const TargetRegisterInfo *TRI = nullptr) { - int Idx = findRegisterDefOperandIdx(Reg, isDead, false, TRI); + MachineOperand * + findRegisterDefOperand(unsigned Reg, bool isDead = false, + bool Overlap = false, + const TargetRegisterInfo *TRI = nullptr) { + int Idx = findRegisterDefOperandIdx(Reg, isDead, Overlap, TRI); return (Idx == -1) ? nullptr : &getOperand(Idx); } + const MachineOperand * + findRegisterDefOperand(unsigned Reg, bool isDead = false, + bool Overlap = false, + const TargetRegisterInfo *TRI = nullptr) const { + return const_cast(this)->findRegisterDefOperand( + Reg, isDead, Overlap, TRI); + } + /// Find the index of the first operand in the /// operand list that is used to represent the predicate. It returns -1 if /// none is found. diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index fd0ea35aada..aaff982ef1b 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -400,7 +400,7 @@ bool LiveVariables::HandlePhysRegKill(unsigned Reg, MachineInstr *MI) { true/*IsImp*/, true/*IsKill*/)); else { MachineOperand *MO = - LastRefOrPartRef->findRegisterDefOperand(Reg, false, TRI); + LastRefOrPartRef->findRegisterDefOperand(Reg, false, false, TRI); bool NeedEC = MO->isEarlyClobber() && MO->getReg() != Reg; // If the last reference is the last def, then it's not used at all. // That is, unless we are currently processing the last reference itself. diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 0b8e9caa09b..95f5eb91ee1 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -1917,7 +1917,7 @@ void MachineInstr::setRegisterDefReadUndef(unsigned Reg, bool IsUndef) { void MachineInstr::addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo) { if (TargetRegisterInfo::isPhysicalRegister(Reg)) { - MachineOperand *MO = findRegisterDefOperand(Reg, false, RegInfo); + MachineOperand *MO = findRegisterDefOperand(Reg, false, false, RegInfo); if (MO) return; } else { diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp index 5cbc9e2a88b..059e5f7c8dd 100644 --- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp +++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp @@ -1140,7 +1140,8 @@ EmitSpecialNode(SDNode *Node, bool IsClone, bool IsCloned, // then remove the early-clobber flag. for (unsigned Reg : ECRegs) { if (MIB->readsRegister(Reg, TRI)) { - MachineOperand *MO = MIB->findRegisterDefOperand(Reg, false, TRI); + MachineOperand *MO = + MIB->findRegisterDefOperand(Reg, false, false, TRI); assert(MO && "No def operand for clobbered register?"); MO->setIsEarlyClobber(false); }