summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-08 18:00:47 +0000
committerChris Lattner <sabre@nondot.org>2006-06-08 18:00:47 +0000
commitfd561cded3cbaec1a4bdfae0703b4be4ea4092f3 (patch)
tree6838c4cfa54f52c7f28b18ed638155d75761dce2 /lib/CodeGen
parent393830a33a02d2f7163fcd4b27b7e5d6a46d8bac (diff)
downloadllvm-fd561cded3cbaec1a4bdfae0703b4be4ea4092f3.tar.gz
llvm-fd561cded3cbaec1a4bdfae0703b4be4ea4092f3.tar.bz2
llvm-fd561cded3cbaec1a4bdfae0703b4be4ea4092f3.tar.xz
Fix an assert-on-inline-inline-asm bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index bd25a1e893..269b958607 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -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: '"