From: Bill Wendling Date: Mon, 30 Aug 2010 01:36:05 +0000 (+0000) Subject: When adding a register, we should mark it as "def" if it can optionally define X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=25b141912ce4f5a4b8a0684e870569ece21facde;p=oota-llvm.git When adding a register, we should mark it as "def" if it can optionally define said (physical) register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112461 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp index 61c2a90e7ed..0b8a2db4f45 100644 --- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp +++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp @@ -253,7 +253,6 @@ unsigned InstrEmitter::getVR(SDValue Op, return I->second; } - /// AddRegisterOperand - Add the specified register as an operand to the /// specified machine instr. Insert register copies if the register is /// not in the required register class. @@ -337,7 +336,10 @@ void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, const ConstantFP *CFP = F->getConstantFPValue(); MI->addOperand(MachineOperand::CreateFPImm(CFP)); } else if (RegisterSDNode *R = dyn_cast(Op)) { - MI->addOperand(MachineOperand::CreateReg(R->getReg(), false)); + unsigned Reg = R->getReg(); + const TargetInstrDesc &TID = MI->getDesc(); + MI->addOperand(MachineOperand::CreateReg(Reg, + (Reg == 0 || !TID.OpInfo) ? false : TID.OpInfo[IIOpNum].isOptionalDef())); } else if (GlobalAddressSDNode *TGA = dyn_cast(Op)) { MI->addOperand(MachineOperand::CreateGA(TGA->getGlobal(), TGA->getOffset(), TGA->getTargetFlags()));