diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index a90f1333a58..65d5ccae70a 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -197,6 +197,13 @@ public: /// MachineOperandType getType() const { return opType; } + /// getUseType - Returns the MachineOperandUseType of this operand. + /// + MOTy::UseType getUseType() const { + return isUse() ^ isDef() ? MOTy::UseAndDef : + (isUse() ? MOTy::Use : MOTy::Def); + } + /// isPCRelative - This returns the value of the PCRELATIVE flag, which /// indicates whether this operand should be emitted as a PC relative value /// instead of a global address. This is used for operands of the forms: diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index 6479ad56a7e..d97b5295315 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -112,13 +112,15 @@ static MachineInstr *MakeMIInst(unsigned Opcode, unsigned FrameIndex, static MachineInstr *MakeRMInst(unsigned Opcode, unsigned FrameIndex, MachineInstr *MI) { - return addFrameReference(BuildMI(Opcode, 5, MI->getOperand(0).getReg()), + const MachineOperand& op = MI->getOperand(0); + return addFrameReference(BuildMI(Opcode, 5, op.getReg(), op.getUseType()), FrameIndex); } static MachineInstr *MakeRMIInst(unsigned Opcode, unsigned FrameIndex, MachineInstr *MI) { - return addFrameReference(BuildMI(Opcode, 5, MI->getOperand(0).getReg()), + const MachineOperand& op = MI->getOperand(0); + return addFrameReference(BuildMI(Opcode, 5, op.getReg(), op.getUseType()), FrameIndex).addZImm(MI->getOperand(2).getImmedValue()); }