Don't forget to update the current operand when getting the size of an instruction.
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>
Sun, 20 Apr 2008 23:36:47 +0000 (23:36 +0000)
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>
Sun, 20 Apr 2008 23:36:47 +0000 (23:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50007 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.cpp

index 280809dc471ea16c83b9a3408908d4906c424c66..8b31f5d5f0984de0e62d5d605878713d73d3cf78 100644 (file)
@@ -2670,6 +2670,7 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
 
   case X86II::AddRegFrm:
     ++FinalSize;
+    ++CurOp;
     
     if (CurOp != NumOps) {
       const MachineOperand &MO1 = MI.getOperand(CurOp++);
@@ -2696,16 +2697,20 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
     ++FinalSize; 
     FinalSize += sizeRegModRMByte();
     CurOp += 2;
-    if (CurOp != NumOps)
+    if (CurOp != NumOps) {
+      ++CurOp;
       FinalSize += sizeConstant(X86InstrInfo::sizeOfImm(Desc));
+    }
     break;
   }
   case X86II::MRMDestMem: {
     ++FinalSize;
     FinalSize += getMemModRMByteSize(MI, CurOp, IsPIC, Is64BitMode);
     CurOp += 5;
-    if (CurOp != NumOps)
+    if (CurOp != NumOps) {
+      ++CurOp;
       FinalSize += sizeConstant(X86InstrInfo::sizeOfImm(Desc));
+    }
     break;
   }
 
@@ -2713,8 +2718,10 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
     ++FinalSize;
     FinalSize += sizeRegModRMByte();
     CurOp += 2;
-    if (CurOp != NumOps)
+    if (CurOp != NumOps) {
+      ++CurOp;
       FinalSize += sizeConstant(X86InstrInfo::sizeOfImm(Desc));
+    }
     break;
 
   case X86II::MRMSrcMem: {
@@ -2722,8 +2729,10 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
     ++FinalSize;
     FinalSize += getMemModRMByteSize(MI, CurOp+1, IsPIC, Is64BitMode);
     CurOp += 5;
-    if (CurOp != NumOps)
+    if (CurOp != NumOps) {
+      ++CurOp;
       FinalSize += sizeConstant(X86InstrInfo::sizeOfImm(Desc));
+    }
     break;
   }
 
@@ -2732,6 +2741,7 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
   case X86II::MRM4r: case X86II::MRM5r:
   case X86II::MRM6r: case X86II::MRM7r:
     ++FinalSize;
+    ++CurOp;
     FinalSize += sizeRegModRMByte();
 
     if (CurOp != NumOps) {