From b934fce61320b28213642f3ba9bbe873a0815274 Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Wed, 20 Feb 2019 07:01:04 +0000 Subject: [PATCH] [NFC] add/modify wrapper function for findRegisterDefOperand(). llvm-svn: 354438 --- llvm/include/llvm/CodeGen/MachineInstr.h | 16 +++++++++++++--- llvm/lib/CodeGen/LiveVariables.cpp | 2 +- llvm/lib/CodeGen/MachineInstr.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index 4cb39c5f0a6a..0a1b927d2e9c 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/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/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp index fd0ea35aadac..aaff982ef1b0 100644 --- a/llvm/lib/CodeGen/LiveVariables.cpp +++ b/llvm/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/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 0b8e9caa09b7..95f5eb91ee1e 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/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/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp index 5cbc9e2a88b0..059e5f7c8dd3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp +++ b/llvm/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); }