OSDN Git Service

Fix an assert-on-inline-inline-asm bug.
authorChris Lattner <sabre@nondot.org>
Thu, 8 Jun 2006 18:00:47 +0000 (18:00 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 8 Jun 2006 18:00:47 +0000 (18:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28727 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp

index bd25a1e..269b958 100644 (file)
@@ -656,24 +656,30 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
       // operand!
       if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
         unsigned OpNo = 1;
-        
+
+        bool Error = false;
+
         // Scan to find the machine operand number for the operand.
         for (; Val; --Val) {
+          if (OpNo >= MI->getNumOperands()) break;
           unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
           OpNo += (OpFlags >> 3) + 1;
         }
-        
-        unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
-        ++OpNo;  // Skip over the ID number.
-
-        bool Error;
-        AsmPrinter *AP = const_cast<AsmPrinter*>(this);
-        if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
-          Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
-                                            Modifier[0] ? Modifier : 0);
+
+        if (OpNo >= MI->getNumOperands()) {
+          Error = true;
         } else {
-          Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
-                                      Modifier[0] ? Modifier : 0);
+          unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
+          ++OpNo;  // Skip over the ID number.
+
+          AsmPrinter *AP = const_cast<AsmPrinter*>(this);
+          if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
+            Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
+                                              Modifier[0] ? Modifier : 0);
+          } else {
+            Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
+                                        Modifier[0] ? Modifier : 0);
+          }
         }
         if (Error) {
           std::cerr << "Invalid operand found in inline asm: '"