[llvm] 3191c78 - [SPIR-V] Reject module-level inline assembly with a diagnostic (#199992)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 2 04:14:47 PDT 2026
Author: Arseniy Obolenskiy
Date: 2026-06-02T13:14:42+02:00
New Revision: 3191c78697c8b499a108e917a9590811db723969
URL: https://github.com/llvm/llvm-project/commit/3191c78697c8b499a108e917a9590811db723969
DIFF: https://github.com/llvm/llvm-project/commit/3191c78697c8b499a108e917a9590811db723969.diff
LOG: [SPIR-V] Reject module-level inline assembly with a diagnostic (#199992)
Module level inline asm is unsupported, even with extension
Added:
llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/module_asm_unsupported.ll
Modified:
llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp b/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
index fa2a356521a9b..1b825698be2b3 100644
--- a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
@@ -916,6 +916,12 @@ void SPIRVAsmPrinter::outputModuleSections() {
bool SPIRVAsmPrinter::doInitialization(Module &M) {
ModuleSectionsEmitted = false;
+ if (!M.getModuleInlineAsm().empty()) {
+ M.getContext().emitError(
+ "SPIR-V does not support module-level inline assembly");
+ M.setModuleInlineAsm("");
+ }
+
// Register the NSDI handler before calling the base class so that
// AsmPrinter::doInitialization() calls Handler->beginModule(M) for it.
if (M.getNamedMetadata("llvm.dbg.cu")) {
diff --git a/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/module_asm_unsupported.ll b/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/module_asm_unsupported.ll
new file mode 100644
index 0000000000000..53dd362962bdb
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/module_asm_unsupported.ll
@@ -0,0 +1,15 @@
+; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
+
+; SPIR-V has no binary analog for module-level inline assembly.
+; The backend must reject it with a clean diagnostic
+; rather than reach the unimplemented MC asm parser path.
+
+; CHECK: error: SPIR-V does not support module-level inline assembly
+
+module asm "foo"
+
+define void @main() {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list