[Mlir-commits] [mlir] [MLIR][XeVM] Revert PR179557 (PR #182373)

Sang Ik Lee llvmlistbot at llvm.org
Thu Feb 19 13:11:24 PST 2026


https://github.com/silee2 created https://github.com/llvm/llvm-project/pull/182373

Revert #179557 as the change relies on private non export API.

>From cb9a0d595e2d4a97dd5e4d023cab0995b1bd4723 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" <sang.ik.lee at intel.com>
Date: Thu, 19 Feb 2026 21:08:06 +0000
Subject: [PATCH 1/2] Revert "[MLIR][XeVM] Fix build issue caused by PR179557.
 (#182156)"

This reverts commit 11a13be40086319c1b6a824f6539ffed5aa2c524.
---
 mlir/lib/Target/LLVM/XeVM/Target.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mlir/lib/Target/LLVM/XeVM/Target.cpp b/mlir/lib/Target/LLVM/XeVM/Target.cpp
index 868409cae7451..de69dd84d8f6e 100644
--- a/mlir/lib/Target/LLVM/XeVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/XeVM/Target.cpp
@@ -13,6 +13,7 @@
 
 #include "mlir/Target/LLVM/XeVM/Target.h"
 
+#include "MCTargetDesc/SPIRVBaseInfo.h"
 #include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
 #include "mlir/Dialect/GPU/IR/GPUDialect.h"
 #include "mlir/Dialect/LLVMIR/XeVMDialect.h"
@@ -41,7 +42,6 @@
 #include "llvm/Support/raw_ostream.h"
 // From llvm/lib/Target/SPIRV
 #if LLVM_HAS_SPIRV_TARGET
-#include "MCTargetDesc/SPIRVBaseInfo.h"
 #include "SPIRVCommandLine.h"
 #include "SPIRVSubtarget.h"
 #include "SPIRVTargetMachine.h"
@@ -276,7 +276,6 @@ void SPIRVSerializer::init() {
   });
 }
 
-#if LLVM_HAS_SPIRV_TARGET
 static const std::vector<std::string> getDefaultSPIRVExtensions() {
   return {
       "SPV_EXT_relaxed_printf_string_address_space",
@@ -284,7 +283,6 @@ static const std::vector<std::string> getDefaultSPIRVExtensions() {
       "SPV_INTEL_variable_length_array",
   };
 }
-#endif
 
 std::optional<SmallVector<char, 0>> SPIRVSerializer::run() {
   // Translate the module to LLVM IR.

>From d55ab9cbcf4de43db6f0883d317061d5396cda16 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" <sang.ik.lee at intel.com>
Date: Thu, 19 Feb 2026 21:09:07 +0000
Subject: [PATCH 2/2] Revert "[MLIR][XeVM] Update XeVM target (#179557)"

This reverts commit faff38c4215a177087936703f1556234d624f1fe.
---
 mlir/lib/Target/LLVM/CMakeLists.txt  |  7 --
 mlir/lib/Target/LLVM/XeVM/Target.cpp | 99 +++-------------------------
 2 files changed, 8 insertions(+), 98 deletions(-)

diff --git a/mlir/lib/Target/LLVM/CMakeLists.txt b/mlir/lib/Target/LLVM/CMakeLists.txt
index 2a16160267174..9a0e4d45693b8 100644
--- a/mlir/lib/Target/LLVM/CMakeLists.txt
+++ b/mlir/lib/Target/LLVM/CMakeLists.txt
@@ -234,10 +234,3 @@ add_mlir_dialect_library(MLIRXeVMTarget
   MLIRTargetLLVM
   MLIRXeVMToLLVMIRTranslation
 )
-
-target_include_directories(MLIRXeVMTarget
-  PRIVATE
-    ${PROJECT_SOURCE_DIR}/lib/Target/SPIRV
-    ${PROJECT_BINARY_DIR}/lib/Target/SPIRV
-)
-
diff --git a/mlir/lib/Target/LLVM/XeVM/Target.cpp b/mlir/lib/Target/LLVM/XeVM/Target.cpp
index de69dd84d8f6e..4285a4e37becf 100644
--- a/mlir/lib/Target/LLVM/XeVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/XeVM/Target.cpp
@@ -13,7 +13,6 @@
 
 #include "mlir/Target/LLVM/XeVM/Target.h"
 
-#include "MCTargetDesc/SPIRVBaseInfo.h"
 #include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
 #include "mlir/Dialect/GPU/IR/GPUDialect.h"
 #include "mlir/Dialect/LLVMIR/XeVMDialect.h"
@@ -40,12 +39,6 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
-// From llvm/lib/Target/SPIRV
-#if LLVM_HAS_SPIRV_TARGET
-#include "SPIRVCommandLine.h"
-#include "SPIRVSubtarget.h"
-#include "SPIRVTargetMachine.h"
-#endif
 
 #include <cstdint>
 #include <cstdlib>
@@ -246,10 +239,6 @@ class SPIRVSerializer : public SerializeGPUModuleBase {
 
   static void init();
 
-  /// Runs the serialization pipeline, returning `std::nullopt` on error.
-  std::optional<SmallVector<char, 0>> run() override;
-
-protected:
   /// Serializes the LLVM module to an object format, depending on the
   /// compilation target selected in target options.
   FailureOr<SmallVector<char, 0>>
@@ -276,99 +265,27 @@ void SPIRVSerializer::init() {
   });
 }
 
-static const std::vector<std::string> getDefaultSPIRVExtensions() {
-  return {
-      "SPV_EXT_relaxed_printf_string_address_space",
-      "SPV_INTEL_cache_controls",
-      "SPV_INTEL_variable_length_array",
-  };
-}
-
-std::optional<SmallVector<char, 0>> SPIRVSerializer::run() {
-  // Translate the module to LLVM IR.
-  llvm::LLVMContext llvmContext;
-  std::unique_ptr<llvm::Module> llvmModule = translateToLLVMIR(llvmContext);
-  if (!llvmModule) {
-    getOperation().emitError() << "Failed creating the llvm::Module.";
-    return std::nullopt;
-  }
-
+FailureOr<SmallVector<char, 0>>
+SPIRVSerializer::moduleToObject(llvm::Module &llvmModule) {
 #define DEBUG_TYPE "serialize-to-llvm"
   LLVM_DEBUG({
     llvm::dbgs() << "LLVM IR for module: " << getGPUModuleOp().getNameAttr()
                  << "\n";
-    llvm::dbgs() << *llvmModule << "\n";
+    llvm::dbgs() << llvmModule << "\n";
     llvm::dbgs().flush();
   });
 #undef DEBUG_TYPE
 
   // Return LLVM IR if the compilation target is `offload`.
   if (targetOptions.getCompilationTarget() == gpu::CompilationTarget::Offload)
-    return SerializeGPUModuleBase::moduleToObject(*llvmModule);
-
-#if LLVM_HAS_SPIRV_TARGET
-  setDataLayoutAndTriple(*llvmModule);
-
-  // Create the target machine.
-  FailureOr<llvm::TargetMachine *> targetMachine = getOrCreateTargetMachine();
-  if (failed(targetMachine)) {
-    getOperation().emitError()
-        << "Target Machine unavailable for triple " << triple
-        << ", can't output compilation target.\n";
-    return std::nullopt;
-  }
-  // Setup allowed SPIR-V extensions.
-  std::set<llvm::SPIRV::Extension::Extension> AllowedExtIds;
-  llvm::StringRef UnknownExt = llvm::SPIRVExtensionsParser::checkExtensions(
-      getDefaultSPIRVExtensions(), AllowedExtIds);
-  if (!UnknownExt.empty()) {
-    std::string ErrMsg{"Unknown SPIR-V extension: "};
-    ErrMsg.append(UnknownExt.str());
-    getOperation().emitError() << ErrMsg;
-    return std::nullopt;
-  }
-
-  llvm::SPIRVTargetMachine *STM =
-      static_cast<llvm::SPIRVTargetMachine *>(*targetMachine);
-  const_cast<llvm::SPIRVSubtarget *>(STM->getSubtargetImpl())
-      ->initAvailableExtensions(AllowedExtIds);
-
-  if (initialLlvmIRCallback)
-    initialLlvmIRCallback(*llvmModule);
-
-  // Link bitcode files.
-  handleModulePreLink(*llvmModule);
-  {
-    auto libs = loadBitcodeFiles(*llvmModule);
-    if (!libs)
-      return std::nullopt;
-    if (!libs->empty())
-      if (failed(linkFiles(*llvmModule, std::move(*libs))))
-        return std::nullopt;
-    handleModulePostLink(*llvmModule);
-  }
-
-  if (linkedLlvmIRCallback)
-    linkedLlvmIRCallback(*llvmModule);
+    return SerializeGPUModuleBase::moduleToObject(llvmModule);
 
-  // Optimize the module.
-  if (failed(optimizeModule(*llvmModule, optLevel)))
-    return std::nullopt;
-
-  if (optimizedLlvmIRCallback)
-    optimizedLlvmIRCallback(*llvmModule);
-
-  // Return the serialized object.
-  return moduleToObject(*llvmModule);
-#else
-  getOperation().emitError("The `SPIRV` target was not built. Please enable "
-                           "it when building LLVM.");
-  return std::nullopt;
+#if !LLVM_HAS_SPIRV_TARGET
+  return getGPUModuleOp()->emitError(
+      "The `SPIRV` target was not built. Please enable "
+      "it when building LLVM.");
 #endif // LLVM_HAS_SPIRV_TARGET
-}
 
-FailureOr<SmallVector<char, 0>>
-SPIRVSerializer::moduleToObject(llvm::Module &llvmModule) {
   FailureOr<llvm::TargetMachine *> targetMachine = getOrCreateTargetMachine();
   if (failed(targetMachine))
     return getGPUModuleOp().emitError()



More information about the Mlir-commits mailing list