[Mlir-commits] [mlir] [MLIR][ModuleTranslation] Add disableVerification parameter (NFC) (PR #94445)
Christian Ulmann
llvmlistbot at llvm.org
Wed Jun 5 02:12:09 PDT 2024
https://github.com/Dinistro created https://github.com/llvm/llvm-project/pull/94445
This commit adds a boolean parameter that allows downstream users to disable the verification when translating an MLIR module to LLVM IR. This is helpful for debugging broken LLVM IR modules post translation.
>From 068204a7d38bec7ac6bad6f5f8134e5d984324d1 Mon Sep 17 00:00:00 2001
From: Christian Ulmann <christian.ulmann at nextsilicon.com>
Date: Wed, 5 Jun 2024 06:47:49 +0000
Subject: [PATCH] [MLIR][ModuleTranslation] Add disableVerification parameter
(NFC)
This commit adds a boolean parameter that allows downstream users to
disable the verification when translating an MLIR module to LLVM IR.
This is helpful for debugging broken LLVM IR modules post translation.
---
mlir/include/mlir/Target/LLVMIR/Export.h | 3 ++-
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h | 3 ++-
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 5 +++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/Target/LLVMIR/Export.h b/mlir/include/mlir/Target/LLVMIR/Export.h
index f9a6db0fc94d5..2244968655138 100644
--- a/mlir/include/mlir/Target/LLVMIR/Export.h
+++ b/mlir/include/mlir/Target/LLVMIR/Export.h
@@ -26,7 +26,8 @@ class Operation;
/// LLVMTranslationDialectInterface.
std::unique_ptr<llvm::Module>
translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- llvm::StringRef name = "LLVMDialectModule");
+ llvm::StringRef name = "LLVMDialectModule",
+ bool disableVerification = false);
} // namespace mlir
#endif // MLIR_TARGET_LLVMIR_EXPORT_H
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 310a43e0de96b..85fdfed3bdbeb 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -57,7 +57,8 @@ class ComdatSelectorOp;
/// needs to look up block and function mappings.
class ModuleTranslation {
friend std::unique_ptr<llvm::Module>
- mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef);
+ mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef,
+ bool);
public:
/// Stores the mapping between a function name and its LLVM IR representation.
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 1ec0736ec08bf..9d3666ec20f34 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1783,7 +1783,7 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
std::unique_ptr<llvm::Module>
mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- StringRef name) {
+ StringRef name, bool disableVerification) {
if (!satisfiesLLVMModule(module)) {
module->emitOpError("can not be translated to an LLVMIR module");
return nullptr;
@@ -1832,7 +1832,8 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
if (failed(translator.convertFunctions()))
return nullptr;
- if (llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
+ if (!disableVerification &&
+ llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
return nullptr;
return std::move(translator.llvmModule);
More information about the Mlir-commits
mailing list