diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -176,7 +176,7 @@ // If we have ${:foo}, then this is not a real operand reference, it is a // "magic" string reference, just like in .td files. Arrange to call // PrintSpecial. - if (HasCurlyBraces && LastEmitted[0] == ':') { + if (HasCurlyBraces && *LastEmitted == ':') { ++LastEmitted; const char *StrStart = LastEmitted; const char *StrEnd = strchr(StrStart, '}'); @@ -200,7 +200,7 @@ Twine(AsmStr) + "'"); LastEmitted = IDEnd; - if (Val >= NumOperands-1) + if (Val >= NumOperands - 1) report_fatal_error("Invalid $ operand number in inline asm string: '" + Twine(AsmStr) + "'"); @@ -367,6 +367,10 @@ Twine(AsmStr) + "'"); LastEmitted = IDEnd; + if (Val >= NumOperands - 1) + report_fatal_error("Invalid $ operand number in inline asm string: '" + + Twine(AsmStr) + "'"); + char Modifier[2] = { 0, 0 }; if (HasCurlyBraces) { @@ -388,10 +392,6 @@ ++LastEmitted; // Consume '}' character. } - if (Val >= NumOperands-1) - report_fatal_error("Invalid $ operand number in inline asm string: '" + - Twine(AsmStr) + "'"); - // Okay, we finally have a value number. Ask the target to print this // operand! if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {