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 @@ -351,9 +351,10 @@ 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 --- 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 }