Author: Hans Wennborg Date: 2020-07-01T09:43:45+02:00 New Revision: a8e582c8307ba1d33c05d272b5c1b755fa809b51
URL: https://github.com/llvm/llvm-project/commit/a8e582c8307ba1d33c05d272b5c1b755fa809b51 DIFF: https://github.com/llvm/llvm-project/commit/a8e582c8307ba1d33c05d272b5c1b755fa809b51.diff LOG: [ThinLTO] Always parse module level inline asm with At&t dialect (PR46503) clang-cl passes -x86-asm-syntax=intel to the cc1 invocation so that assembly listings produced by the /FA flag are printed in Intel dialect. That flag however should not affect the *parsing* of inline assembly in the program. (See r322652) When compiling normally, AsmPrinter::emitInlineAsm is used for assembling and defaults to At&t dialect. However, when compiling for ThinLTO, the code which parses module level inline asm to find symbols for the symbol table was failing to set the dialect. This patch fixes that. (See the bug for more details.) Differential revision: https://reviews.llvm.org/D82862 Added: clang/test/CodeGen/thinlto-inline-asm.c Modified: llvm/lib/Object/ModuleSymbolTable.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/thinlto-inline-asm.c b/clang/test/CodeGen/thinlto-inline-asm.c new file mode 100644 index 000000000000..a41cba6fadc1 --- /dev/null +++ b/clang/test/CodeGen/thinlto-inline-asm.c @@ -0,0 +1,21 @@ +// REQUIRES: x86-registered-target + +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.11.0 -emit-llvm-bc \ +// RUN: -flto=thin -mllvm -x86-asm-syntax=intel -v \ +// RUN: -o %t.obj %s 2>&1 | FileCheck --check-prefix=CLANG %s +// +// RUN: llvm-lto2 dump-symtab %t.obj | FileCheck --check-prefix=SYMTAB %s + +// Module-level inline asm is parsed with At&t syntax. Test that the +// -x86-asm-syntax flag does not affect this. + +// CLANG-NOT: unknown token in expression +// SYMTAB: D------X foo +// SYMTAB: D------X bar + +void foo() {} + +asm(".globl bar \n" + "bar: \n" + " xor %eax, %eax\n" + " ret \n"); diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp index 45bcf7481890..7f3055b5dcfa 100644 --- a/llvm/lib/Object/ModuleSymbolTable.cpp +++ b/llvm/lib/Object/ModuleSymbolTable.cpp @@ -23,6 +23,7 @@ #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/InlineAsm.h" #include "llvm/IR/Module.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" @@ -116,6 +117,10 @@ initializeRecordStreamer(const Module &M, if (!TAP) return; + // Module-level inline asm is assumed to use At&t syntax (see + // AsmPrinter::doInitialization()). + Parser->setAssemblerDialect(InlineAsm::AD_ATT); + Parser->setTargetParser(*TAP); if (Parser->Run(false)) return; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits