From: Chris Lattner Date: Thu, 8 Apr 2010 18:20:52 +0000 (+0000) Subject: implicit defs get added to the end of machine instrs sometimes. Scan the whole instr... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d0024fec256659b45350387289e5d4520f15dc6d;p=oota-llvm.git implicit defs get added to the end of machine instrs sometimes. Scan the whole instruction for the metadata operand instead of assuming it will be at the end of the instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100792 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index a3a408f5118..37d10e5c4cc 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -127,10 +127,15 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { // Get the !srcloc metadata node if we have it, and decode the loc cookie from // it. unsigned LocCookie = 0; - if (const MDNode *SrcLoc = MI->getOperand(NumOperands-1).getMetadata()) { - if (SrcLoc->getNumOperands() != 0) - if (const ConstantInt *CI = dyn_cast(SrcLoc->getOperand(0))) - LocCookie = CI->getZExtValue(); + for (unsigned i = MI->getNumOperands(); i != 0; --i) { + if (MI->getOperand(i-1).isMetadata()) + if (const MDNode *SrcLoc = MI->getOperand(i-1).getMetadata()) + if (SrcLoc->getNumOperands() != 0) + if (const ConstantInt *CI = + dyn_cast(SrcLoc->getOperand(0))) { + LocCookie = CI->getZExtValue(); + break; + } } // Emit the inline asm to a temporary string so we can emit it through