Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -277,7 +277,13 @@ int CurVariant = -1; // The number of the {.|.|.} region we are in. const char *LastEmitted = AsmStr; // One past the last character emitted. unsigned NumOperands = MI->getNumOperands(); - int AsmPrinterVariant = MAI->getAssemblerDialect(); + + // Matches X86MCAsmInfo.cpp's AsmWriterFlavorTy::ATT. + // This function processes inline asm in AT&T style, so $(v0$|v1$) variant + // selection has to pick v0, the AT&T variant, since the input is AT&T. + // If MAI->getAssemblerDialect() returns 1, the output is Intel-style + // asm, but here we care about the input style. + int AsmPrinterVariant = 0; if (MAI->getEmitGNUAsmStartIndentationMarker()) OS << '\t'; Index: llvm/test/CodeGen/X86/asm-dialect.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/asm-dialect.ll @@ -0,0 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - \ +; RUN: | FileCheck --check-prefix=OUTPUT_ATT %s +; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -x86-asm-syntax=intel -o - \ +; RUN: | FileCheck --check-prefix=OUTPUT_INTEL %s + +define void @f() { +; OUTPUT_ATT-LABEL: f: +; OUTPUT_ATT: # %bb.0: +; OUTPUT_ATT-NEXT: #APP +; OUTPUT_ATT-NEXT: movq %rbx, %rax +; OUTPUT_ATT-NEXT: #NO_APP +; OUTPUT_ATT-NEXT: retq +; +; OUTPUT_INTEL-LABEL: f: +; OUTPUT_INTEL: # %bb.0: +; OUTPUT_INTEL-NEXT: #APP +; OUTPUT_INTEL-NEXT: mov rax, rbx +; OUTPUT_INTEL-NEXT: #NO_APP +; OUTPUT_INTEL-NEXT: ret + call void asm sideeffect "$(movq %rbx, %rax $| mov rax, rbx$)", "~{dirflag},~{fpsr},~{flags}"() + + ret void +}