diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 041a5d791f8790..dd15ba515002c1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -351,9 +351,10 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI, if (!StrEnd) report_fatal_error("Unterminated ${:foo} operand in inline asm" " string: '" + Twine(AsmStr) + "'"); - - std::string Val(StrStart, StrEnd); - AP->PrintSpecial(MI, OS, Val.c_str()); + if (CurVariant == -1 || CurVariant == AsmPrinterVariant) { + std::string Val(StrStart, StrEnd); + AP->PrintSpecial(MI, OS, Val.c_str()); + } LastEmitted = StrEnd+1; break; } diff --git a/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll b/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll index 5ef568863baddc..5f9f34d1e78ce2 100644 --- a/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll +++ b/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll @@ -1,6 +1,9 @@ -; RUN: llc -no-integrated-as < %s | grep "foo 0 0" +; RUN: llc -no-integrated-as < %s | FileCheck %s define void @bar() nounwind { - tail call void asm sideeffect "foo ${:uid} ${:uid}", ""() nounwind - ret void + ; CHECK: foo 0 0{{$}} + tail call void asm sideeffect "foo ${:uid} ${:uid}", ""() nounwind + ; CHECK: bar 1 x{{$}} + tail call void asm sideeffect "bar $(${:uid} x$| ${:uid} x$)", ""() nounwind + ret void }