https://github.com/dtellenbach updated https://github.com/llvm/llvm-project/pull/98097
>From 46e32d1156e38653c79682600fbf63d964277dba Mon Sep 17 00:00:00 2001 From: David Tellenbach <dtellenb...@apple.com> Date: Mon, 8 Jul 2024 16:04:18 -0700 Subject: [PATCH 1/2] [AsmPrinter] Don't check for inlineasm dialect on non-X86 platforms AArch64 uses MCAsmInfo::AssemblerDialect to control the style of emitted Neon assembly. E.g. Apple platforms use AsmWriterVariantTy::Apple by default which collides with InlineAsm::AD_Intel (both value 1). Checking for inlineasm dialects on non-X86 platforms can thus lead to problems. --- clang/test/CodeGen/AArch64/inline-asm-ios.c | 23 +++++++++++++++++++ .../AsmPrinter/AsmPrinterInlineAsm.cpp | 14 +++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 clang/test/CodeGen/AArch64/inline-asm-ios.c diff --git a/clang/test/CodeGen/AArch64/inline-asm-ios.c b/clang/test/CodeGen/AArch64/inline-asm-ios.c new file mode 100644 index 0000000000000..5e7328a15f69d --- /dev/null +++ b/clang/test/CodeGen/AArch64/inline-asm-ios.c @@ -0,0 +1,23 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple arm64-apple-ios -S -o - %s | FileCheck %s + +// CHECK: _restartable_function: +// CHECK-NEXT: ldr x11, [x0] +// CHECK-NEXT: add x11, x11, #1 +// CHECK-NEXT: str x11, [x0] +// CHECK-NEXT: Ltmp0: +// CHECK-NEXT: b Ltmp0 +// CHECK-NEXT: LExit_restartable_function: +// CHECK-NEXT: ret +asm(".align 4\n" + " .text\n" + " .private_extern _restartable_function\n" + "_restartable_function:\n" + " ldr x11, [x0]\n" + " add x11, x11, #1\n" + " str x11, [x0]\n" + "1:\n" + " b 1b\n" + "LExit_restartable_function:\n" + " ret\n" +); diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 5a7013c964cb4..6fe8d0e0af995 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -113,12 +113,16 @@ void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI, if (!TAP) report_fatal_error("Inline asm not supported by this streamer because" " we don't have an asm parser for this target\n"); - Parser->setAssemblerDialect(Dialect); + + // Respect inlineasm dialect on X86 targets only + if (TM.getTargetTriple().isX86()) { + Parser->setAssemblerDialect(Dialect); + // Enable lexing Masm binary and hex integer literals in intel inline + // assembly. + if (Dialect == InlineAsm::AD_Intel) + Parser->getLexer().setLexMasmIntegers(true); + } Parser->setTargetParser(*TAP); - // Enable lexing Masm binary and hex integer literals in intel inline - // assembly. - if (Dialect == InlineAsm::AD_Intel) - Parser->getLexer().setLexMasmIntegers(true); emitInlineAsmStart(); // Don't implicitly switch to the text section before the asm. >From ca81fa117841a551702d678a6402a3bd98e85f2b Mon Sep 17 00:00:00 2001 From: David Tellenbach <dtellenb...@apple.com> Date: Mon, 8 Jul 2024 18:38:32 -0700 Subject: [PATCH 2/2] Move test up into clang/test/CodeGen instead of target specific folder --- .../CodeGen/{AArch64/inline-asm-ios.c => aarch64-inlineasm-ios.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename clang/test/CodeGen/{AArch64/inline-asm-ios.c => aarch64-inlineasm-ios.c} (100%) diff --git a/clang/test/CodeGen/AArch64/inline-asm-ios.c b/clang/test/CodeGen/aarch64-inlineasm-ios.c similarity index 100% rename from clang/test/CodeGen/AArch64/inline-asm-ios.c rename to clang/test/CodeGen/aarch64-inlineasm-ios.c _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits