When folding memory operands in machine instructions be careful to
authorAlkis Evlogimenos <alkis@evlogimenos.com>
Sun, 22 Feb 2004 06:54:26 +0000 (06:54 +0000)
committerAlkis Evlogimenos <alkis@evlogimenos.com>
Sun, 22 Feb 2004 06:54:26 +0000 (06:54 +0000)
leave register operands with the same use/def flags as the original
instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11709 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstr.h
lib/Target/X86/X86RegisterInfo.cpp

index a90f1333a588b648b44bf8a353dc37b665b498cc..65d5ccae70a7f37c4d40c92daa26f00c83a15357 100644 (file)
@@ -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:
index 6479ad56a7ec25eb877fa7929e5dc5f2531c1aea..d97b52953153fffb8219dd2498172e94189c87c1 100644 (file)
@@ -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());
 }